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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
use crate::canvas::managed::handles::{CanvasTextureHandle, CanvasImageHandle, CanvasFontHandle};
use std::sync::Arc;
use vulkano::buffer::BufferAccess;
use std::collections::HashMap;
#[derive(Default, Debug, Clone, Copy)]
pub struct TextureVertex3D {
pub v_position: [f32; 3],
pub ti_position: [f32; 2],
}
vulkano::impl_vertex!(TextureVertex3D, v_position, ti_position);
#[derive(Default, Debug, Clone, Copy)]
pub struct ColorVertex3D {
pub v_position: [f32; 3],
pub color: [f32; 4],
}
vulkano::impl_vertex!(ColorVertex3D, v_position, color);
#[derive(Default, Debug, Clone, Copy)]
pub struct ImageVertex3D {
pub v_position: [f32; 3],
pub ti_position: [f32; 2],
}
vulkano::impl_vertex!(ImageVertex3D, v_position, ti_position);
#[derive(Default, Debug, Clone, Copy)]
pub struct Vertex3D {
pub v_position: [f32; 3],
pub color : [f32; 4],
pub ti_position: [f32; 2],
}
vulkano::impl_vertex!(Vertex3D, v_position, color, ti_position);
#[derive(Default, Debug, Clone, Copy)]
pub struct TextVertex3D {
pub position: [f32; 3],
}
vulkano::impl_vertex!(TextVertex3D, position);
#[derive(Default, Debug, Clone, Copy)]
pub struct GlyphInstance {
pub screen_position: (f32, f32),
pub atlas_position: (f32, f32),
pub atlas_size: (f32, f32),
pub scale: f32,
}
vulkano::impl_vertex!(GlyphInstance, screen_position, atlas_position, atlas_size, scale);
#[derive(Debug, Clone)]
pub enum VertexTypes {
TextureType(Vec<TextureVertex3D>, Arc<CanvasTextureHandle>),
ImageType(Vec<ImageVertex3D>, Arc<CanvasImageHandle>),
ColorType(Vec<ColorVertex3D>),
ThreeDType(Vec<Vertex3D>),
}
#[derive(Clone)]
pub struct CanvasFrameAllocation {
pub colored_vertex_buffer: Vec<Arc<(dyn BufferAccess + Send + Sync)>>,
pub textured_vertex_buffer: HashMap<Arc<CanvasTextureHandle>, Arc<(dyn BufferAccess + Send + Sync)>>,
pub image_vertex_buffer: HashMap<Arc<CanvasImageHandle>, Arc<(dyn BufferAccess + Send + Sync)>>,
pub text_instances: HashMap<Arc<CanvasFontHandle>, Arc<(dyn BufferAccess + Send + Sync)>>,
}