|
|
|
@ -34,27 +34,14 @@ Let's define our `VertexBufferDescriptor`.
|
|
|
|
|
```rust
|
|
|
|
|
impl Vertex for ModelVertex {
|
|
|
|
|
fn desc<'a>() -> wgpu::VertexBufferDescriptor<'a> {
|
|
|
|
|
use std::mem;
|
|
|
|
|
wgpu::VertexBufferDescriptor {
|
|
|
|
|
stride: mem::size_of::<ModelVertex>() as wgpu::BufferAddress,
|
|
|
|
|
stride: std::mem::size_of::<ModelVertex>() as wgpu::BufferAddress,
|
|
|
|
|
step_mode: wgpu::InputStepMode::Vertex,
|
|
|
|
|
attributes: &[
|
|
|
|
|
wgpu::VertexAttributeDescriptor {
|
|
|
|
|
offset: 0,
|
|
|
|
|
shader_location: 0,
|
|
|
|
|
format: wgpu::VertexFormat::Float3,
|
|
|
|
|
},
|
|
|
|
|
wgpu::VertexAttributeDescriptor {
|
|
|
|
|
offset: mem::size_of::<[f32; 3]>() as wgpu::BufferAddress,
|
|
|
|
|
shader_location: 1,
|
|
|
|
|
format: wgpu::VertexFormat::Float2,
|
|
|
|
|
},
|
|
|
|
|
wgpu::VertexAttributeDescriptor {
|
|
|
|
|
offset: mem::size_of::<[f32; 5]>() as wgpu::BufferAddress,
|
|
|
|
|
shader_location: 2,
|
|
|
|
|
format: wgpu::VertexFormat::Float3,
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
attributes: &wgpu::vertex_attr_array![
|
|
|
|
|
0 => Float3,
|
|
|
|
|
1 => Float2,
|
|
|
|
|
2 => Float3
|
|
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|