Struct rich_sdl2_rust::texture::Texture
source · pub struct Texture<'renderer> { /* private fields */ }
Expand description
A texture used to draw the image to Renderer
.
Implementations§
source§impl<'renderer> Texture<'renderer>
impl<'renderer> Texture<'renderer>
sourcepub fn new(
renderer: &'renderer Renderer<'renderer>,
access: TextureAccess
) -> Result<Self>
pub fn new( renderer: &'renderer Renderer<'renderer>, access: TextureAccess ) -> Result<Self>
Constructs a texture from the renderer with access type.
§Errors
Returns Err
if failed to allocate, no rendering context was active, the format was unsupported, or the width or height were out of range.
sourcepub fn from_surface(
renderer: &'renderer Renderer<'renderer>,
surface: &'renderer impl Surface
) -> Self
pub fn from_surface( renderer: &'renderer Renderer<'renderer>, surface: &'renderer impl Surface ) -> Self
Constructs a texture from the Surface
. The texture will be readonly and the access type will be TextureAccess::Static
.
sourcepub fn set_alpha_mod(&self, alpha: u8) -> Result<()>
pub fn set_alpha_mod(&self, alpha: u8) -> Result<()>
sourcepub fn set_color_mod(&self, _: Rgb)
pub fn set_color_mod(&self, _: Rgb)
Sets the color mod of the texture.
sourcepub fn lock(&'renderer mut self, area: Option<Rect>) -> Lock<'renderer>
pub fn lock(&'renderer mut self, area: Option<Rect>) -> Lock<'renderer>
Obtains the lock for the texture in area, or whole if None
.
sourcepub fn bind_to_current_gl_context(&self) -> Result<(f32, f32)>
pub fn bind_to_current_gl_context(&self) -> Result<(f32, f32)>
Binds the texture to the current OpenGL context. And returns the size in the context.
§Errors
Returns Err
if failed to bind the texture.
sourcepub fn unbind_from_current_gl_context(&self) -> Result<()>
pub fn unbind_from_current_gl_context(&self) -> Result<()>
Unbinds the texture to the current OpenGL context.
§Errors
Returns Err
if failed to unbind the texture.
Trait Implementations§
Auto Trait Implementations§
impl<'renderer> RefUnwindSafe for Texture<'renderer>
impl<'renderer> !Send for Texture<'renderer>
impl<'renderer> !Sync for Texture<'renderer>
impl<'renderer> Unpin for Texture<'renderer>
impl<'renderer> UnwindSafe for Texture<'renderer>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more