Struct sdl2::render::Texture
[−]
[src]
pub struct Texture { // some fields omitted }
A texture for a rendering context.
Every Texture is owned by a Renderer. If a Texture is accessed after the corresponding Renderer is dropped, then the program will panic (clarification: will not crash).
A Texture can be safely dropped before or after the Renderer is dropped.
Methods
impl Texture
[src]
fn query(&self) -> TextureQuery
Queries the attributes of the texture.
fn set_color_mod(&mut self, red: u8, green: u8, blue: u8)
Sets an additional color value multiplied into render copy operations.
fn color_mod(&self) -> (u8, u8, u8)
Gets the additional color value multiplied into render copy operations.
fn set_alpha_mod(&mut self, alpha: u8)
Sets an additional alpha value multiplied into render copy operations.
fn alpha_mod(&self) -> u8
Gets the additional alpha value multiplied into render copy operations.
fn set_blend_mode(&mut self, blend: BlendMode)
Sets the blend mode for a texture, used by Renderer::copy()
.
fn blend_mode(&self) -> BlendMode
Gets the blend mode used for texture copy operations.
fn update(&mut self, rect: Option<Rect>, pixel_data: &[u8], pitch: usize) -> SdlResult<()>
Updates the given texture rectangle with new pixel data.
pitch
is the number of bytes in a row of pixel data, including padding
between lines
- If
rect
isNone
, the entire texture is updated.
fn update_yuv(&mut self, rect: Option<Rect>, y_plane: &[u8], y_pitch: usize, u_plane: &[u8], u_pitch: usize, v_plane: &[u8], v_pitch: usize) -> SdlResult<()>
Updates a rectangle within a planar YV12 or IYUV texture with new pixel data.
fn with_lock<F, R>(&mut self, rect: Option<Rect>, func: F) -> SdlResult<R> where F: FnOnce(&mut [u8], usize) -> R
Locks the texture for write-only pixel access. The texture must have been created with streaming access.
F
is a function that is passed the write-only texture buffer,
and the pitch of the texture (size of a row in bytes).
Remarks
As an optimization, the pixels made available for editing don't necessarily contain the old texture data. This is a write-only operation, and if you need to keep a copy of the texture data you should do that at the application level.
unsafe fn gl_bind_texture(&mut self) -> (f32, f32)
Binds an OpenGL/ES/ES2 texture to the current context for use with when rendering OpenGL primitives directly.
unsafe fn gl_unbind_texture(&mut self)
Unbinds an OpenGL/ES/ES2 texture from the current context.
fn gl_with_bind<R, F: FnOnce(f32, f32) -> R>(&mut self, f: F) -> R
Binds and unbinds an OpenGL/ES/ES2 texture from the current context.