summaryrefslogtreecommitdiff
path: root/engine/src/lib.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2023-10-23 22:38:12 +0200
committerHampusM <hampus@hampusmat.com>2023-10-23 22:38:12 +0200
commitc846fe5e269a827b3c324fb66b75be3fabc56a57 (patch)
treeb8204121ae095b62078e157afe1f2df0ec7290df /engine/src/lib.rs
parent386aad9dac7c22cabb0f1bbba33d248c40bb0310 (diff)
feat(engine): add camera
Diffstat (limited to 'engine/src/lib.rs')
-rw-r--r--engine/src/lib.rs11
1 files changed, 10 insertions, 1 deletions
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<ObjectId, Object>,
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