Struct macroquad::texture::Texture2D [−][src]
pub struct Texture2D { /* fields omitted */ }
Expand description
Texture, data stored in GPU memory
Implementations
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, );
Creates a Texture2D from an Image.
Creates a Texture2D from a miniquad Texture
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);
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);
Returns the handle for this texture.
Updates this texture from the screen.
Returns an Image from the pixel data in this texture.
This operation can be expensive.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Texture2D
impl UnwindSafe for Texture2D
Blanket Implementations
Mutably borrows from an owned value. Read more