1#[repr(C, align(16))]
2#[derive(Debug, Clone, Copy, bytemuck::Pod, bytemuck::Zeroable)]
3pub struct LineVertexUnit {
4 pub position: [f32; 3],
5 pub color: [u8; 4],
6}
7
8#[repr(C, align(16))]
9#[derive(Debug, Clone, Copy, bytemuck::Pod, bytemuck::Zeroable)]
10pub struct QuadVertexUnit {
11 pub position: [f32; 4],
12 pub texcoord: [f32; 4],
13}
14
15impl QuadVertexUnit {
16 pub fn generate_quad_tri_strip() -> [QuadVertexUnit; 4] {
17 Self::_generate_quad_tri_strip(-1f32, 1f32, 1f32, -1f32)
18 }
19
20 fn _generate_quad_tri_strip(minx: f32, miny: f32, maxx: f32, maxy: f32) -> [QuadVertexUnit; 4] {
21 let (minu, minv, maxu, maxv) = (0.0f32, 0.0f32, 1.0f32, 1.0f32);
22 [
23 QuadVertexUnit {
24 position: [minx, miny, 0f32, 0f32],
25 texcoord: [minu, minv, 0f32, 0f32],
26 },
27 QuadVertexUnit {
28 position: [minx, maxy, 0f32, 0f32],
29 texcoord: [minu, maxv, 0f32, 0f32],
30 },
31 QuadVertexUnit {
32 position: [maxx, miny, 0f32, 0f32],
33 texcoord: [maxu, minv, 0f32, 0f32],
34 },
35 QuadVertexUnit {
36 position: [maxx, maxy, 0f32, 0f32],
37 texcoord: [maxu, maxv, 0f32, 0f32],
38 },
39 ]
40 }
41}