Struct Texture

Source
pub struct Texture<'texture, R: Renderable + ?Sized> {
    pub data: &'texture [u8],
    pub dims: (usize, usize, usize),
    pub elements_per_data: u32,
    pub ele_type: BufferElementType,
    /* private fields */
}
Expand description

A texture is managed by the library as a byte slice which has up to three dimensions - minimally a width, with a 2D texture having a non-zero height, and a 3D texture with a non-zero depth

The ‘elements’ that make up each entry of the texture can be multiples of 1 to 4 of a fundamental element type (int or float, of 8, 16 or 32 bits as permitted)

After the texture has been created, it may be instantiated within the client, when a texture client handle is created by the client; this must be easily Cloned, particuarly if the texture is used in more than one instantiable object

Fields§

§data: &'texture [u8]

The underlying data for the texture

§dims: (usize, usize, usize)

Width, height, and depth of the texture - width must be non-zero

If height is zero then the texture is 1D, and depth must be 0

If height is non-zero and depth is zero then the texture is 2D

§elements_per_data: u32

Number of elements per texture entry (1,2,3 or 4)

An RGB texture would be 3; an RGBA texture 4.

§ele_type: BufferElementType

The type of each element

For most image textures this is Int8

Implementations§

Source§

impl<'texture, R: Renderable> Texture<'texture, R>

ip Texture

Source

pub fn new( data: &'texture [u8], dims: (usize, usize, usize), ele_type: BufferElementType, elements_per_data: u32, ) -> Self

Create a new Texture object with no additional attributes

Source

pub fn dims(&self) -> &(usize, usize, usize)

Get the dimensions of the texture

Source

pub fn data(&self) -> &[u8]

Get the data slice for the texture

Source

pub fn data_type(&self) -> (u32, BufferElementType)

Get the data slice for the texture

Source

pub fn create_client(&self, renderer: &mut R)

Create the client texture

Source

pub fn borrow_client(&self) -> Ref<'_, R::Texture>

Borrow the client

Trait Implementations§

Source§

impl<'texture, R> Debug for Texture<'texture, R>
where R: Renderable,

Source§

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

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

impl<'texture, R> Display for Texture<'texture, R>
where R: Renderable,

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'texture, R> !Freeze for Texture<'texture, R>

§

impl<'texture, R> !RefUnwindSafe for Texture<'texture, R>

§

impl<'texture, R> Send for Texture<'texture, R>
where <R as Renderable>::Texture: Send,

§

impl<'texture, R> !Sync for Texture<'texture, R>

§

impl<'texture, R> Unpin for Texture<'texture, R>
where <R as Renderable>::Texture: Unpin,

§

impl<'texture, R> UnwindSafe for Texture<'texture, R>
where <R as Renderable>::Texture: UnwindSafe,

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

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>,

Source§

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.