mod atlases;
mod common;
mod custom;
mod draw_pipe;
mod flat_round;
mod images;
mod round_2col;
mod shaded_round;
mod shaded_square;
mod shaders;
use kas::draw::WindowCommon;
use kas::geom::{Offset, Rect};
use shaders::ShaderManager;
use wgpu::TextureFormat;
pub use custom::{CustomPipe, CustomPipeBuilder, CustomWindow, DrawCustom};
pub(crate) const RENDER_TEX_FORMAT: TextureFormat = TextureFormat::Bgra8UnormSrgb;
type Scale = [f32; 4];
#[derive(Debug)]
struct ClipRegion {
rect: Rect,
offset: Offset,
order: u64,
}
impl Default for ClipRegion {
fn default() -> Self {
ClipRegion {
rect: Rect::ZERO,
offset: Offset::ZERO,
order: 1,
}
}
}
pub struct DrawPipe<C> {
pub(crate) adapter: wgpu::Adapter,
pub(crate) device: wgpu::Device,
queue: wgpu::Queue,
staging_belt: wgpu::util::StagingBelt,
bgl_common: wgpu::BindGroupLayout,
light_norm_buf: wgpu::Buffer,
bg_common: Vec<(wgpu::Buffer, wgpu::BindGroup)>,
images: images::Images,
text: kas::text::raster::State,
shaded_square: shaded_square::Pipeline,
shaded_round: shaded_round::Pipeline,
flat_round: flat_round::Pipeline,
round_2col: round_2col::Pipeline,
custom: C,
}
kas::impl_scope! {
#[impl_default(where CW: Default)]
pub struct DrawWindow<CW: CustomWindow> {
pub(crate) common: WindowCommon,
scale: Scale,
clip_regions: Vec<ClipRegion> = vec![Default::default()],
images: images::Window,
shaded_square: shaded_square::Window,
shaded_round: shaded_round::Window,
flat_round: flat_round::Window,
round_2col: round_2col::Window,
custom: CW,
}
}