Struct sdl2::render::TextureCreator

source ·
pub struct TextureCreator<T> { /* private fields */ }
Expand description

Creates Textures that cannot outlive the creator

The TextureCreator does not hold a lifetime to its Canvas by design choice.

If a Canvas is dropped before its TextureCreator, it is still safe to use.

It is, however, useless.

Any Texture created here can only be drawn onto the original Canvas. A Texture used in a Canvas must come from a TextureCreator coming from that same Canvas. Using a Texture to render to a Canvas not being the parent of the Texture’s TextureCreator is undefined behavior.

Implementations

Texture-creating methods for the renderer

Creates a texture for a rendering context.

If format is None, the format will be the one the parent Window or Surface uses.

If format is Some(pixel_format), the default will be overridden, and the texture will be created with the specified format if possible. If the PixelFormat is not supported, this will return an error.

You should prefer the default format if possible to have performance gains and to avoid unsupported Pixel Formats that can cause errors. However, be careful with the default PixelFormat if you want to create transparent textures.

Shorthand for create_texture(format, TextureAccess::Static, width, height)

Shorthand for create_texture(format, TextureAccess::Streaming, width, height)

Shorthand for create_texture(format, TextureAccess::Target, width, height)

Creates a texture from an existing surface.

Remarks

The access hint for the created texture is TextureAccess::Static.

Create a texture from its raw SDL_Texture.

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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

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.