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
mod custom;
mod draw_pipe;
mod draw_text;
mod flat_round;
mod shaded_round;
mod shaded_square;
mod shaders;
use kas::draw::Font;
use kas::geom::Rect;
use wgpu::{CompareFunction, DepthStencilStateDescriptor, TextureFormat};
use wgpu_glyph::GlyphBrush;
pub(crate) use shaders::ShaderManager;
pub use custom::{CustomPipe, CustomPipeBuilder, CustomWindow, DrawCustom};
const DEPTH_FORMAT: TextureFormat = TextureFormat::Depth32Float;
pub(crate) const TEX_FORMAT: TextureFormat = TextureFormat::Bgra8UnormSrgb;
const fn new_depth_desc(depth_compare: CompareFunction) -> DepthStencilStateDescriptor {
DepthStencilStateDescriptor {
format: DEPTH_FORMAT,
depth_write_enabled: true,
depth_compare,
stencil_front: wgpu::StencilStateFaceDescriptor::IGNORE,
stencil_back: wgpu::StencilStateFaceDescriptor::IGNORE,
stencil_read_mask: 0,
stencil_write_mask: 0,
}
}
const DEPTH_DESC: DepthStencilStateDescriptor = new_depth_desc(CompareFunction::Always);
const GLPYH_DEPTH_DESC: DepthStencilStateDescriptor = new_depth_desc(CompareFunction::GreaterEqual);
#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub(crate) struct Rgb {
pub r: f32,
pub g: f32,
pub b: f32,
}
impl From<kas::draw::Colour> for Rgb {
fn from(c: kas::draw::Colour) -> Self {
Rgb {
r: c.r,
g: c.g,
b: c.b,
}
}
}
pub struct DrawPipe<C> {
fonts: Vec<Font<'static>>,
shaded_square: shaded_square::Pipeline,
shaded_round: shaded_round::Pipeline,
flat_round: flat_round::Pipeline,
custom: C,
}
pub struct DrawWindow<CW: CustomWindow> {
depth: Option<wgpu::TextureView>,
clip_regions: Vec<Rect>,
shaded_square: shaded_square::Window,
shaded_round: shaded_round::Window,
flat_round: flat_round::Window,
custom: CW,
glyph_brush: GlyphBrush<'static, DepthStencilStateDescriptor>,
}