summaryrefslogtreecommitdiff
path: root/engine/src
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2023-11-27 21:29:43 +0100
committerHampusM <hampus@hampusmat.com>2023-11-27 21:37:37 +0100
commita20192060679ee05d5a567eb4179e60d80f7f21e (patch)
tree9df01273f57ee7ab2e330f55767428f32b6e4c3c /engine/src
parentd3f8b55aa971d1ef00345e80bc40365927bf08e5 (diff)
chore: replace Engine::new window params with window settings
Diffstat (limited to 'engine/src')
-rw-r--r--engine/src/lib.rs32
1 files changed, 26 insertions, 6 deletions
diff --git a/engine/src/lib.rs b/engine/src/lib.rs
index 806d7ec..2016ec1 100644
--- a/engine/src/lib.rs
+++ b/engine/src/lib.rs
@@ -51,11 +51,7 @@ where
///
/// # Errors
/// Will return `Err` if window creation or window configuration fails.
- pub fn new(
- window_size: &WindowSize,
- window_title: &str,
- camera: CameraT,
- ) -> Result<Self, Error>
+ pub fn new(window_settings: &WindowSettings, camera: CameraT) -> Result<Self, Error>
{
let window_builder = WindowBuilder::new();
@@ -64,7 +60,7 @@ where
window_builder.hint(glfw::window::Hint::OpenGLDebugContext, 1);
let window = window_builder
- .create(window_size, window_title)
+ .create(&window_settings.size, &window_settings.title)
.map_err(Error::CreateWindowFailed)?;
window
@@ -247,3 +243,27 @@ pub enum Error
#[error("Rendering failed")]
RenderingFailed(#[source] renderer::Error),
}
+
+#[derive(Debug)]
+pub struct WindowSettings
+{
+ size: WindowSize,
+ title: Box<str>,
+}
+
+#[derive(Debug, Default)]
+pub struct WindowSettingsBuilder {}
+
+impl WindowSettingsBuilder
+{
+ #[must_use]
+ pub fn new() -> Self
+ {
+ Self::default()
+ }
+
+ pub fn build(&self, size: WindowSize, title: impl Into<Box<str>>) -> WindowSettings
+ {
+ WindowSettings { size, title: title.into() }
+ }
+}