Struct macroquad::texture::Texture2D[][src]

pub struct Texture2D { /* fields omitted */ }
Expand description

Texture, data stored in GPU memory

Implementations

Creates an empty Texture2D.

Example
let texture = Texture2D::empty();

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);

Uploads Image data to this texture.

Returns the width of this texture.

Returns the height of this texture.

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.

Unloads texture from GPU memory.

Using a deleted texture could give different results on different platforms and is not recommended.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.