summaryrefslogtreecommitdiff
path: root/engine/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'engine/src/lib.rs')
-rw-r--r--engine/src/lib.rs23
1 files changed, 15 insertions, 8 deletions
diff --git a/engine/src/lib.rs b/engine/src/lib.rs
index c4711f2..806d7ec 100644
--- a/engine/src/lib.rs
+++ b/engine/src/lib.rs
@@ -33,23 +33,29 @@ pub use glfw::window::Key;
pub use glfw::WindowSize;
#[derive(Debug)]
-pub struct Engine
+pub struct Engine<CameraT>
{
/// Objects have to be dropped before window. Otherwise, UB.
objects: BTreeMap<ObjectId, Object>,
light_source: Option<LightSource>,
window: Window,
- renderer: Renderer,
+ renderer: Renderer<CameraT>,
delta_time: Duration,
}
-impl Engine
+impl<CameraT> Engine<CameraT>
+where
+ CameraT: Camera,
{
/// Creates and initializes a new engine.
///
/// # Errors
/// Will return `Err` if window creation or window configuration fails.
- pub fn new(window_size: &WindowSize, window_title: &str) -> Result<Self, Error>
+ pub fn new(
+ window_size: &WindowSize,
+ window_title: &str,
+ camera: CameraT,
+ ) -> Result<Self, Error>
{
let window_builder = WindowBuilder::new();
@@ -66,10 +72,11 @@ impl Engine
.map_err(Error::ConfigureWindowFailed)?;
window.set_framebuffer_size_callback(move |new_window_size| {
- Renderer::set_viewport(&Vec2::ZERO, &new_window_size);
+ Renderer::<CameraT>::set_viewport(&Vec2::ZERO, &new_window_size);
});
- let renderer = Renderer::new(&window).map_err(Error::InitializeRendererFailed)?;
+ let renderer =
+ Renderer::new(&window, camera).map_err(Error::InitializeRendererFailed)?;
Ok(Self {
window,
@@ -156,12 +163,12 @@ impl Engine
}
#[must_use]
- pub fn camera(&self) -> &Camera
+ pub fn camera(&self) -> &CameraT
{
self.renderer.camera()
}
- pub fn camera_mut(&mut self) -> &mut Camera
+ pub fn camera_mut(&mut self) -> &mut CameraT
{
self.renderer.camera_mut()
}