#![cfg_attr(docsrs, feature(doc_auto_cfg))]
pub mod draw;
mod draw_shaded;
pub mod options;
mod shaded_theme;
mod surface;
use crate::draw::{CustomPipeBuilder, DrawPipe};
use kas::runner::{self, Result};
use wgpu::rwh;
pub use draw_shaded::{DrawShaded, DrawShadedImpl};
pub use options::Options;
pub use shaded_theme::ShadedTheme;
pub extern crate wgpu;
pub struct Instance<CB: CustomPipeBuilder> {
options: Options,
instance: wgpu::Instance,
custom: CB,
}
impl<CB: CustomPipeBuilder> Instance<CB> {
pub fn new(options: Options, custom: CB) -> Self {
let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor {
backends: options.backend(),
..Default::default()
});
Instance {
options,
instance,
custom,
}
}
}
impl<CB: CustomPipeBuilder> runner::GraphicsInstance for Instance<CB> {
type Shared = DrawPipe<CB::Pipe>;
type Surface<'a> = surface::Surface<'a, CB::Pipe>;
fn new_shared(&mut self, surface: Option<&Self::Surface<'_>>) -> Result<Self::Shared> {
DrawPipe::new(
&self.instance,
&mut self.custom,
&self.options,
surface.map(|s| &s.surface),
)
}
fn new_surface<'window, W>(
&mut self,
window: W,
transparent: bool,
) -> Result<Self::Surface<'window>>
where
W: rwh::HasWindowHandle + rwh::HasDisplayHandle + Send + Sync + 'window,
Self: Sized,
{
surface::Surface::new(&self.instance, window, transparent)
}
}