pub trait AtlasData {
type SliceMut<'a>: Iterator
where Self: 'a;
const TEXTURES: usize;
// Required methods
fn blank_with_size(sz: Vec2<u16>) -> Self;
fn as_texture_data(&self) -> [(TextureFormat, &[u8]); Self::TEXTURES];
fn layout() -> Vec<BindGroupLayoutEntry>;
fn slice_mut(&mut self, range: Range<usize>) -> Self::SliceMut<'_>;
// Provided method
fn create_textures(
&self,
renderer: &mut Renderer,
atlas_size: Vec2<u16>,
) -> [Texture; Self::TEXTURES] { ... }
}
Expand description
A trait implemented by texture atlas groups.
Terrain, figures, sprites, etc. all use texture atlases but have different requirements, such as that layers provided by each atlas. This trait abstracts over these cases.
Required Associated Constants§
Required Associated Types§
Sourcetype SliceMut<'a>: Iterator
where
Self: 'a
type SliceMut<'a>: Iterator where Self: 'a
Abstracts over a slice into the texture data, as returned by
AtlasData::slice_mut
.
Required Methods§
Sourcefn blank_with_size(sz: Vec2<u16>) -> Self
fn blank_with_size(sz: Vec2<u16>) -> Self
Return blank atlas data upon which texels can be applied.
Sourcefn as_texture_data(&self) -> [(TextureFormat, &[u8]); Self::TEXTURES]
fn as_texture_data(&self) -> [(TextureFormat, &[u8]); Self::TEXTURES]
Return an array of texture formats and data for each texture layer in the atlas.
Provided Methods§
Sourcefn create_textures(
&self,
renderer: &mut Renderer,
atlas_size: Vec2<u16>,
) -> [Texture; Self::TEXTURES]
fn create_textures( &self, renderer: &mut Renderer, atlas_size: Vec2<u16>, ) -> [Texture; Self::TEXTURES]
Create textures on the GPU corresponding to the layers in the atlas.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.