From c846fe5e269a827b3c324fb66b75be3fabc56a57 Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 23 Oct 2023 22:38:12 +0200 Subject: feat(engine): add camera --- engine/src/lib.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'engine/src/lib.rs') diff --git a/engine/src/lib.rs b/engine/src/lib.rs index ee93695..ce953f8 100644 --- a/engine/src/lib.rs +++ b/engine/src/lib.rs @@ -4,6 +4,7 @@ use std::collections::BTreeMap; use glfw::{Window, WindowBuilder}; +use crate::camera::Camera; use crate::object::{Id as ObjectId, Object}; use crate::vector::Vec2; @@ -13,6 +14,7 @@ mod projection; mod renderer; mod transform; +pub mod camera; pub mod color; pub mod object; pub mod vector; @@ -26,6 +28,7 @@ pub struct Engine /// Objects have to be dropped before window. Otherwise, UB. objects: BTreeMap, window: Window, + camera: Camera, } impl Engine @@ -59,6 +62,7 @@ impl Engine Ok(Self { window, objects: BTreeMap::new(), + camera: Camera::new(), }) } @@ -96,7 +100,7 @@ impl Engine let window_size = self.window.size().map_err(Error::GetWindowSizeFailed)?; - crate::renderer::render(self.objects.values(), &window_size); + crate::renderer::render(self.objects.values(), &window_size, &self.camera); self.window .swap_buffers() @@ -109,6 +113,11 @@ impl Engine Ok(()) } + + pub fn camera(&mut self) -> &mut Camera + { + &mut self.camera + } } /// Engine Error -- cgit v1.2.3-18-g5258