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
impl<'texture, R: Renderable> Texture<'texture, R>
ip Texture
Sourcepub fn new(
data: &'texture [u8],
dims: (usize, usize, usize),
ele_type: BufferElementType,
elements_per_data: u32,
) -> Self
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
Sourcepub fn data_type(&self) -> (u32, BufferElementType)
pub fn data_type(&self) -> (u32, BufferElementType)
Get the data slice for the texture
Sourcepub fn create_client(&self, renderer: &mut R)
pub fn create_client(&self, renderer: &mut R)
Create the client texture
Sourcepub fn borrow_client(&self) -> Ref<'_, R::Texture>
pub fn borrow_client(&self) -> Ref<'_, R::Texture>
Borrow the client