#[cfg(not(target_arch = "wasm32"))]
pub mod raster;
pub mod camera;
pub mod light;
pub mod depth;
pub mod vtex;
#[cfg(target_arch = "wasm32")]
pub mod webgl;
#[cfg(target_arch = "wasm32")]
pub mod audio_web;
pub use camera::Camera3D;
pub use light::Light;
pub use depth::DepthQueue;
#[cfg(not(target_arch = "wasm32"))]
pub struct GfxState {
pub window: Option<minifb::Window>,
pub buffer: Vec<u32>,
pub width: usize,
pub height: usize,
pub color: u32,
pub camera: Camera3D,
pub lights: Vec<Light>,
pub ambient: f32,
pub depth_queue: DepthQueue,
}
#[cfg(not(target_arch = "wasm32"))]
impl GfxState {
pub fn new() -> Self {
Self {
window: None,
buffer: Vec::new(),
width: 0,
height: 0,
color: 0x00FF_FFFF,
camera: Camera3D::default(),
lights: Vec::new(),
ambient: 0.15,
depth_queue: DepthQueue::default(),
}
}
pub fn sync_projection(&mut self) {
self.camera.cx = self.width as f32 / 2.0;
self.camera.cy = self.height as f32 / 2.0;
self.camera.focal = self.height as f32;
self.camera.zdist = 5.0;
}
}
#[cfg(target_arch = "wasm32")]
pub struct GfxState {
pub width: usize,
pub height: usize,
pub color: u32,
pub fill_r: f32,
pub fill_g: f32,
pub fill_b: f32,
pub camera: Camera3D,
pub lights: Vec<Light>,
pub ambient: f32,
pub depth_queue: DepthQueue,
}
#[cfg(target_arch = "wasm32")]
impl GfxState {
pub fn new() -> Self {
Self {
width: 800,
height: 600,
color: 0x00FF_FFFF,
fill_r: 0.0,
fill_g: 0.0,
fill_b: 0.0,
camera: Camera3D::default(),
lights: Vec::new(),
ambient: 0.15,
depth_queue: DepthQueue::default(),
}
}
pub fn sync_projection(&mut self) {
self.camera.cx = self.width as f32 / 2.0;
self.camera.cy = self.height as f32 / 2.0;
self.camera.focal = self.height as f32;
self.camera.zdist = 5.0;
}
}