1mod atlases;
11mod common;
12mod custom;
13mod draw_pipe;
14mod flat_round;
15mod images;
16mod round_2col;
17mod shaded_round;
18mod shaded_square;
19mod shaders;
20mod text_pipe;
21
22use kas::draw::WindowCommon;
23use kas::geom::{Offset, Rect};
24use shaders::ShaderManager;
25use wgpu::TextureFormat;
26
27pub use custom::{CustomPipe, CustomPipeBuilder, CustomWindow, DrawCustom};
28
29pub(crate) const RENDER_TEX_FORMAT: TextureFormat = TextureFormat::Bgra8UnormSrgb;
34
35type Scale = [f32; 4];
36
37#[derive(Debug)]
38struct ClipRegion {
39 rect: Rect,
40 offset: Offset,
41 order: u64,
42}
43
44impl Default for ClipRegion {
45 fn default() -> Self {
46 ClipRegion {
47 rect: Rect::ZERO,
48 offset: Offset::ZERO,
49 order: 1,
50 }
51 }
52}
53
54pub struct DrawPipe<C> {
56 pub(crate) adapter: wgpu::Adapter,
57 pub(crate) device: wgpu::Device,
58 queue: wgpu::Queue,
59 staging_belt: wgpu::util::StagingBelt,
60 bgl_common: wgpu::BindGroupLayout,
61 light_norm_buf: wgpu::Buffer,
62 bg_common: Vec<(wgpu::Buffer, wgpu::BindGroup)>,
63 images: images::Images,
64 shaded_square: shaded_square::Pipeline,
65 shaded_round: shaded_round::Pipeline,
66 flat_round: flat_round::Pipeline,
67 round_2col: round_2col::Pipeline,
68 custom: C,
69}
70
71kas::impl_scope! {
72 #[impl_default(where CW: Default)]
74 pub struct DrawWindow<CW: CustomWindow> {
75 pub(crate) common: WindowCommon,
76 scale: Scale,
77 clip_regions: Vec<ClipRegion> = vec![Default::default()],
78 images: images::Window,
79 shaded_square: shaded_square::Window,
80 shaded_round: shaded_round::Window,
81 flat_round: flat_round::Window,
82 round_2col: round_2col::Window,
83 custom: CW,
84 }
85}