init
This commit is contained in:
commit
b8eea76bf9
8 changed files with 2602 additions and 0 deletions
28
src/vertex.rs
Normal file
28
src/vertex.rs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, bytemuck::Pod, bytemuck::Zeroable)]
|
||||
pub struct Vertex {
|
||||
position: [f32; 2],
|
||||
color: [f32; 3],
|
||||
}
|
||||
|
||||
impl Vertex {
|
||||
pub fn new(position: [f32; 2], color: [f32; 3]) -> Vertex {
|
||||
Vertex {position, color}
|
||||
}
|
||||
|
||||
pub fn new_white(position: [f32; 2]) -> Vertex {
|
||||
Vertex {position, color: [1.0, 1.0, 1.0]}
|
||||
}
|
||||
|
||||
const ATTRIBS: [wgpu::VertexAttribute; 2] = wgpu::vertex_attr_array![0 => Float32x2, 1 => Float32x3];
|
||||
|
||||
pub const fn desc() -> wgpu::VertexBufferLayout<'static> {
|
||||
use std::mem;
|
||||
wgpu::VertexBufferLayout {
|
||||
array_stride: mem::size_of::<Self>() as wgpu::BufferAddress,
|
||||
step_mode: wgpu::VertexStepMode::Vertex,
|
||||
attributes: &Self::ATTRIBS,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue