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.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/engine/src/lib.rs b/engine/src/lib.rs
index 9f82b26..ae603b0 100644
--- a/engine/src/lib.rs
+++ b/engine/src/lib.rs
@@ -8,6 +8,7 @@ use glfw::{Window, WindowBuilder};
use crate::camera::Camera;
use crate::object::{Id as ObjectId, Object};
+use crate::renderer::Renderer;
use crate::vector::Vec2;
mod matrix;
@@ -32,7 +33,7 @@ pub struct Engine
/// Objects have to be dropped before window. Otherwise, UB.
objects: BTreeMap<ObjectId, Object>,
window: Window,
- camera: Camera,
+ renderer: Renderer,
delta_time: Duration,
}
@@ -59,15 +60,15 @@ impl Engine
.map_err(Error::ConfigureWindowFailed)?;
window.set_framebuffer_size_callback(move |new_window_size| {
- crate::renderer::set_viewport(&Vec2::ZERO, &new_window_size);
+ Renderer::set_viewport(&Vec2::ZERO, &new_window_size);
});
- crate::renderer::initialize(&window).map_err(Error::InitializeRendererFailed)?;
+ let renderer = Renderer::new(&window).map_err(Error::InitializeRendererFailed)?;
Ok(Self {
window,
+ renderer,
objects: BTreeMap::new(),
- camera: Camera::new(),
delta_time: Duration::ZERO,
})
}
@@ -110,7 +111,7 @@ impl Engine
let window_size = self.window.size().map_err(Error::GetWindowSizeFailed)?;
- crate::renderer::render(self.objects.values(), &window_size, &self.camera);
+ self.renderer.render(self.objects.values(), &window_size);
self.window
.swap_buffers()
@@ -127,12 +128,12 @@ impl Engine
#[must_use]
pub fn camera(&self) -> &Camera
{
- &self.camera
+ self.renderer.camera()
}
pub fn camera_mut(&mut self) -> &mut Camera
{
- &mut self.camera
+ self.renderer.camera_mut()
}
/// Returns the current delta time. Will be 0 if not called from the function