use bytemuck::{Pod, Zeroable};
use std::sync::Arc;
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)
}
}