Struct sdl2::render::TextureCreator [−][src]
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
impl<T> TextureCreator<T>
[src]
Texture-creating methods for the renderer
pub fn raw(&self) -> *mut SDL_Renderer
[src]
pub fn default_pixel_format(&self) -> PixelFormatEnum
[src]
pub fn create_texture<F>(
&self,
format: F,
access: TextureAccess,
width: u32,
height: u32
) -> Result<Texture<'_>, TextureValueError> where
F: Into<Option<PixelFormatEnum>>,
[src]
&self,
format: F,
access: TextureAccess,
width: u32,
height: u32
) -> Result<Texture<'_>, TextureValueError> where
F: Into<Option<PixelFormatEnum>>,
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.
pub fn create_texture_static<F>(
&self,
format: F,
width: u32,
height: u32
) -> Result<Texture<'_>, TextureValueError> where
F: Into<Option<PixelFormatEnum>>,
[src]
&self,
format: F,
width: u32,
height: u32
) -> Result<Texture<'_>, TextureValueError> where
F: Into<Option<PixelFormatEnum>>,
Shorthand for create_texture(format, TextureAccess::Static, width, height)
pub fn create_texture_streaming<F>(
&self,
format: F,
width: u32,
height: u32
) -> Result<Texture<'_>, TextureValueError> where
F: Into<Option<PixelFormatEnum>>,
[src]
&self,
format: F,
width: u32,
height: u32
) -> Result<Texture<'_>, TextureValueError> where
F: Into<Option<PixelFormatEnum>>,
Shorthand for create_texture(format, TextureAccess::Streaming, width, height)
pub fn create_texture_target<F>(
&self,
format: F,
width: u32,
height: u32
) -> Result<Texture<'_>, TextureValueError> where
F: Into<Option<PixelFormatEnum>>,
[src]
&self,
format: F,
width: u32,
height: u32
) -> Result<Texture<'_>, TextureValueError> where
F: Into<Option<PixelFormatEnum>>,
Shorthand for create_texture(format, TextureAccess::Target, width, height)
pub fn create_texture_from_surface<S: AsRef<SurfaceRef>>(
&self,
surface: S
) -> Result<Texture<'_>, TextureValueError>
[src]
&self,
surface: S
) -> Result<Texture<'_>, TextureValueError>
Creates a texture from an existing surface.
Remarks
The access hint for the created texture is TextureAccess::Static
.
pub unsafe fn raw_create_texture(&self, raw: *mut SDL_Texture) -> Texture<'_>
[src]
Create a texture from its raw SDL_Texture
.
Auto Trait Implementations
impl<T> !RefUnwindSafe for TextureCreator<T>
impl<T> !Send for TextureCreator<T>
impl<T> !Sync for TextureCreator<T>
impl<T> Unpin for TextureCreator<T>
impl<T> !UnwindSafe for TextureCreator<T>
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, 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>,