Trait veloren_voxygen::render::pipelines::AtlasData

source ·
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 Types§

source

type SliceMut<'a>: Iterator where Self: 'a

Abstracts over a slice into the texture data, as returned by AtlasData::slice_mut.

Required Associated Constants§

source

const TEXTURES: usize

The number of texture channels that this atlas has.

Required Methods§

source

fn blank_with_size(sz: Vec2<u16>) -> Self

Return blank atlas data upon which texels can be applied.

source

fn as_texture_data(&self) -> [(TextureFormat, &[u8]); Self::TEXTURES]

Return an array of texture formats and data for each texture layer in the atlas.

source

fn layout() -> Vec<BindGroupLayoutEntry>

Return a layout entry that corresponds to the texture layers in the atlas.

source

fn slice_mut(&mut self, range: Range<usize>) -> Self::SliceMut<'_>

Take a sub-slice of the texture data for each layer in the atlas.

Provided Methods§

source

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.

Object Safety§

This trait is not object safe.

Implementors§