pub struct Texture<'renderer> { /* private fields */ }
Expand description

A texture used to draw the image to Renderer.

Implementations§

source§

impl<'renderer> Texture<'renderer>

source

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.

source

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.

source

pub fn alpha_mod(&self) -> u8

Returns the alpha mod of the texture.

source

pub fn set_alpha_mod(&self, alpha: u8) -> Result<()>

Sets the alpha mod of the texture.

§Errors

Returns Err if setting the alpha mod is unsupported.

§Panics

Panics if some unrecoverable error is occurred.

source

pub fn color_mod(&self) -> Rgb

Returns the color mod of the texture.

source

pub fn set_color_mod(&self, _: Rgb)

Sets the color mod of the texture.

source

pub fn lock(&'renderer mut self, area: Option<Rect>) -> Lock<'renderer>

Obtains the lock for the texture in area, or whole if None.

source

pub fn clip(&self) -> &Option<Rect>

Return the clip area of the texture if available.

source

pub fn set_clip(&mut self, clip: Option<Rect>)

Sets the clip area.

source

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.

source

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§

source§

impl Debug for Texture<'_>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Drop for Texture<'_>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl QueryExt for Texture<'_>

source§

fn format(&self) -> PixelFormatKind

Returns the format of the texture.
source§

fn access(&self) -> TextureAccess

Returns the access of the texture.
source§

fn size(&self) -> Size

Returns the size of the texture.

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.