pub mod raster;
pub mod camera;
pub mod light;
pub mod depth;
pub mod vtex;
pub use camera::Camera3D;
pub use light::Light;
pub use depth::DepthQueue;
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,
}
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;
}
}