Struct macroquad::texture::Texture2D [−][src]
Texture, data stored in GPU memory
Implementations
impl Texture2D
[src]
pub fn empty() -> Texture2D
[src]
pub fn from_file_with_format<'a>(
bytes: &[u8],
format: Option<ImageFormat>
) -> Texture2D
[src]
bytes: &[u8],
format: Option<ImageFormat>
) -> Texture2D
Creates a Texture2D from a slice of bytes that contains an encoded image.
If format
is None, it will make an educated guess on the
ImageFormat.
Example
let texture = Texture2D::from_file_with_format( include_bytes!("../examples/rust.png"), None, );
pub fn from_image(image: &Image) -> Texture2D
[src]
Creates a Texture2D from an Image.
pub fn from_miniquad_texture(texture: Texture) -> Texture2D
[src]
Creates a Texture2D from a miniquad Texture
pub fn from_rgba8(width: u16, height: u16, bytes: &[u8]) -> Texture2D
[src]
Creates a Texture2D from a slice of bytes in an R,G,B,A sequence, with the given width and height.
Example
// Create a 2x2 texture from a byte slice with 4 rgba pixels let bytes: Vec<u8> = vec![255, 0, 0, 192, 0, 255, 0, 192, 0, 0, 255, 192, 255, 255, 255, 192]; let texture = Texture2D::from_rgba8(2, 2, &bytes);
pub fn update(&self, image: &Image)
[src]
Uploads Image data to this texture.
pub fn width(&self) -> f32
[src]
Returns the width of this texture.
pub fn height(&self) -> f32
[src]
Returns the height of this texture.
pub fn set_filter(&self, filter_mode: FilterMode)
[src]
Sets the FilterMode of this texture.
Use Nearest if you need integer-ratio scaling for pixel art, for example.
Example
let texture = Texture2D::empty(); texture.set_filter(FilterMode::Linear);
pub fn raw_miniquad_texture_handle(&self) -> Texture
[src]
Returns the handle for this texture.
pub fn grab_screen(&self)
[src]
Updates this texture from the screen.
pub fn get_texture_data(&self) -> Image
[src]
Returns an Image from the pixel data in this texture.
This operation can be expensive.
pub fn delete(&self)
[src]
Unloads texture from GPU memory.
Using a deleted texture could give different results on different platforms and is not recommended.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Texture2D
impl Send for Texture2D
impl Sync for Texture2D
impl Unpin for Texture2D
impl UnwindSafe for Texture2D
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,