Struct gfx_graphics::Texture

source ·
pub struct Texture<R>where
    R: Resources,{
    pub surface: Texture<R, R8_G8_B8_A8>,
    pub sampler: Sampler<R>,
    pub view: ShaderResourceView<R, [f32; 4]>,
}
Expand description

Represents a texture.

Fields§

§surface: Texture<R, R8_G8_B8_A8>

Pixel storage for texture.

§sampler: Sampler<R>

Sampler for texture.

§view: ShaderResourceView<R, [f32; 4]>

View used by shader.

Implementations§

source§

impl<R> Texture<R>where R: Resources,

source

pub fn empty<F, C>( context: &mut TextureContext<F, R, C> ) -> Result<Texture<R>, Error>where F: Factory<R>, C: Buffer<R>,

Returns empty texture.

source

pub fn from_path<F, C, P>( context: &mut TextureContext<F, R, C>, path: P, flip: Flip, settings: &TextureSettings ) -> Result<Texture<R>, Error>where F: Factory<R>, C: Buffer<R>, P: AsRef<Path>,

Creates a texture from path.

source

pub fn from_image<F, C>( context: &mut TextureContext<F, R, C>, img: &ImageBuffer<Rgba<u8>, Vec<u8, Global>>, settings: &TextureSettings ) -> Result<Texture<R>, Error>where F: Factory<R>, C: Buffer<R>,

Creates a texture from image.

source

pub fn from_memory_alpha<F, C>( context: &mut TextureContext<F, R, C>, buffer: &[u8], width: u32, height: u32, settings: &TextureSettings ) -> Result<Texture<R>, Error>where F: Factory<R>, C: Buffer<R>,

Creates texture from memory alpha.

source

pub fn update<F, C>( &mut self, context: &mut TextureContext<F, R, C>, img: &ImageBuffer<Rgba<u8>, Vec<u8, Global>> ) -> Result<(), Error>where F: Factory<R>, C: Buffer<R>,

Updates the texture with an image.

Trait Implementations§

source§

impl<R> Clone for Texture<R>where R: Clone + Resources,

source§

fn clone(&self) -> Texture<R>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<F, R, C> CreateTexture<TextureContext<F, R, C>> for Texture<R>where F: Factory<R>, R: Resources, C: Buffer<R>,

source§

fn create<S>( context: &mut TextureContext<F, R, C>, _format: Format, memory: &[u8], size: S, settings: &TextureSettings ) -> Result<Texture<R>, <Texture<R> as TextureOp<TextureContext<F, R, C>>>::Error>where S: Into<[u32; 2]>,

Create texture from memory.
source§

impl<R> Debug for Texture<R>where R: Debug + Resources,

source§

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

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

impl<R> ImageSize for Texture<R>where R: Resources,

source§

fn get_size(&self) -> (u32, u32)

Get the image size.
§

fn get_width(&self) -> u32

Gets the image width.
§

fn get_height(&self) -> u32

Gets the image height.
source§

impl<R> PartialEq<Texture<R>> for Texture<R>where R: PartialEq<R> + Resources,

source§

fn eq(&self, other: &Texture<R>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<F, R> TextureOp<F> for Texture<R>where R: Resources,

§

type Error = Error

The error when performing an operation.
source§

impl<F, R, C> UpdateTexture<TextureContext<F, R, C>> for Texture<R>where F: Factory<R>, R: Resources, C: Buffer<R>,

source§

fn update<O, S>( &mut self, context: &mut TextureContext<F, R, C>, format: Format, memory: &[u8], offset: O, size: S ) -> Result<(), <Texture<R> as TextureOp<TextureContext<F, R, C>>>::Error>where O: Into<[u32; 2]>, S: Into<[u32; 2]>,

Update the texture. Read more
source§

impl<R> StructuralPartialEq for Texture<R>where R: Resources,

Auto Trait Implementations§

§

impl<R> !RefUnwindSafe for Texture<R>

§

impl<R> Send for Texture<R>

§

impl<R> Sync for Texture<R>

§

impl<R> Unpin for Texture<R>

§

impl<R> !UnwindSafe for Texture<R>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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.