Skip to main content

wgpu_noboiler/
vertex.rs

1use std::mem;
2
3use wgpu::{BufferAddress, VertexAttribute, VertexBufferLayout, VertexStepMode};
4
5pub trait Vertex<const SIZE: usize> {
6    fn descriptor<'a>() -> VertexBufferLayout<'a>
7    where
8        Self: Sized,
9    {
10        VertexBufferLayout {
11            array_stride: mem::size_of::<Self>() as BufferAddress,
12            step_mode: Self::STEP_MODE,
13            attributes: &Self::ATTRIBS,
14        }
15    }
16
17    const STEP_MODE: VertexStepMode = VertexStepMode::Vertex;
18    const ATTRIBS: [VertexAttribute; SIZE];
19}