mirror of
https://github.com/lisk77/comet.git
synced 2025-10-25 22:28:50 +00:00
initial commit
This commit is contained in:
commit
6154c72b0e
55 changed files with 9481 additions and 0 deletions
44
crates/comet_resources/src/vertex.rs
Normal file
44
crates/comet_resources/src/vertex.rs
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
use wgpu::Color;
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, bytemuck::Pod, bytemuck::Zeroable, PartialEq)]
|
||||
pub struct Vertex {
|
||||
position: [f32; 3],
|
||||
tex_coords: [f32; 2],
|
||||
}
|
||||
|
||||
impl Vertex {
|
||||
pub fn new(position: [f32; 3], tex_coords: [f32; 2]) -> Self {
|
||||
Self {
|
||||
position,
|
||||
tex_coords
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_position(&mut self, new_position: [f32;3]) {
|
||||
self.position = new_position
|
||||
}
|
||||
|
||||
pub fn set_tex_coords(&mut self, new_tex_coords: [f32; 2]) {
|
||||
self.tex_coords = new_tex_coords
|
||||
}
|
||||
|
||||
pub fn desc() -> wgpu::VertexBufferLayout<'static> {
|
||||
wgpu::VertexBufferLayout {
|
||||
array_stride: std::mem::size_of::<Vertex>() as wgpu::BufferAddress,
|
||||
step_mode: wgpu::VertexStepMode::Vertex,
|
||||
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,
|
||||
format: wgpu::VertexFormat::Float32x2,
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue