1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use std::sync::Arc;
use bytemuck::{Pod, Zeroable};
use easygpu::{
buffers::{IndexBuffer, VertexBuffer},
color::Rgba8,
};
#[repr(C)]
#[derive(Copy, Clone, Debug, Pod, Zeroable)]
pub(crate) struct Vertex {
pub position: [f32; 3],
pub color: Rgba8,
}
pub struct Shape {
pub index_count: u32,
pub vertices: Arc<VertexBuffer>,
pub indices: Arc<IndexBuffer>,
}
impl Shape {
pub fn draw<'a, 'b>(&'a self, pass: &'b mut easygpu::wgpu::RenderPass<'a>) {
pass.set_vertex_buffer(0, self.vertices.slice());
pass.set_index_buffer(self.indices.slice(), easygpu::wgpu::IndexFormat::Uint16);
pass.draw_indexed(0..self.index_count, 0, 0..1)
}
}