44 lines
1.3 KiB
Rust
44 lines
1.3 KiB
Rust
pub trait Vertex {
|
|
fn desc() -> wgpu::VertexBufferLayout<'static>;
|
|
}
|
|
|
|
#[repr(C)]
|
|
#[derive(Copy, Clone, Debug, bytemuck::Pod, bytemuck::Zeroable)]
|
|
pub struct ModelVertex {
|
|
pub position: [f32; 3],
|
|
pub tex_coords: [f32; 2],
|
|
pub normal: [f32; 3],
|
|
}
|
|
|
|
impl Vertex for ModelVertex {
|
|
fn desc() -> wgpu::VertexBufferLayout<'static> {
|
|
todo!();
|
|
}
|
|
}
|
|
|
|
impl Vertex for ModelVertex {
|
|
fn desc() -> wgpu::VertexBufferLayout<'static> {
|
|
use std::mem;
|
|
wgpu::VertexBufferLayout {
|
|
array_stride: mem::size_of::<ModelVertex>() as wgpu::BufferAddress,
|
|
step_mode: wgpu::VertexStepMode::Vertex,
|
|
attributes: &[
|
|
wgpu::VertexAttribute {
|
|
offset: 0,
|
|
shader_location: 0,
|
|
format: wgpu::VertexFormat::Float32x3,
|
|
},
|
|
wgpu::VertexAttribute {
|
|
offset: mem::size_of::<[f32; 3]>() as wgpu::BufferAddress,
|
|
shader_location: 1,
|
|
format: wgpu::VertexFormat::Float32x2,
|
|
},
|
|
wgpu::VertexAttribute {
|
|
offset: mem::size_of::<[f32; 5]>() as wgpu::BufferAddress,
|
|
shader_location: 2,
|
|
format: wgpu::VertexFormat::Float32x3,
|
|
},
|
|
],
|
|
}
|
|
}
|
|
} |