1pub const fn vertex(position: [f32; 3], color: [f32; 3], tex_coords: [f32; 2]) -> Vertex {
3 Vertex {
4 position,
5 color,
6 tex_coords,
7 }
8}
9
10#[repr(C)]
11#[derive(Copy, Clone, Debug, bytemuck::Pod, bytemuck::Zeroable)]
12pub struct Vertex {
14 position: [f32; 3],
15 color: [f32; 3],
16 tex_coords: [f32; 2],
17}
18
19impl Vertex {
20 const ATTRIBS: [wgpu::VertexAttribute; 3] =
21 wgpu::vertex_attr_array![0 => Float32x3, 1 => Float32x3, 2 => Float32x2];
22
23 pub fn desc<'a>() -> wgpu::VertexBufferLayout<'a> {
24 wgpu::VertexBufferLayout {
25 array_stride: std::mem::size_of::<Vertex>() as wgpu::BufferAddress,
26 step_mode: wgpu::VertexStepMode::Vertex,
27 attributes: &Self::ATTRIBS,
28 }
29 }
30}