2022-01-31 18:15:07 +00:00
|
|
|
#[repr(C)]
|
|
|
|
#[derive(Copy, Clone, bytemuck::Pod, bytemuck::Zeroable)]
|
|
|
|
pub struct Vertex {
|
|
|
|
pub position: [f32; 3],
|
2022-02-02 20:15:58 +00:00
|
|
|
pub normal: [f32; 3],
|
2022-01-31 19:23:03 +00:00
|
|
|
pub tex_coords: [f32; 2],
|
2022-01-31 18:15:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Vertex {
|
|
|
|
pub fn desc<'a>() -> wgpu::VertexBufferLayout<'a> {
|
|
|
|
wgpu::VertexBufferLayout {
|
|
|
|
array_stride: std::mem::size_of::<Vertex>() as wgpu::BufferAddress,
|
|
|
|
step_mode: wgpu::VertexStepMode::Vertex,
|
2022-01-31 19:23:03 +00:00
|
|
|
attributes: &[
|
|
|
|
wgpu::VertexAttribute {
|
|
|
|
offset: 0,
|
|
|
|
shader_location: 0,
|
|
|
|
format: wgpu::VertexFormat::Float32x3,
|
|
|
|
},
|
|
|
|
wgpu::VertexAttribute {
|
|
|
|
offset: std::mem::size_of::<[f32; 3]>() as wgpu::BufferAddress,
|
|
|
|
shader_location: 1,
|
2022-02-02 20:15:58 +00:00
|
|
|
format: wgpu::VertexFormat::Float32x3,
|
|
|
|
},
|
|
|
|
wgpu::VertexAttribute {
|
|
|
|
offset: std::mem::size_of::<[f32; 6]>() as wgpu::BufferAddress,
|
|
|
|
shader_location: 2,
|
2022-01-31 19:23:03 +00:00
|
|
|
format: wgpu::VertexFormat::Float32x2,
|
|
|
|
},
|
|
|
|
],
|
2022-01-31 18:15:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub type Index = u32;
|
|
|
|
|
|
|
|
pub struct MeshData {
|
|
|
|
pub vertices: Vec<Vertex>,
|
|
|
|
pub indices: Vec<Index>,
|
|
|
|
}
|