From a20192060679ee05d5a567eb4179e60d80f7f21e Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 27 Nov 2023 21:29:43 +0100 Subject: chore: replace Engine::new window params with window settings --- engine/src/lib.rs | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'engine/src') 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 + pub fn new(window_settings: &WindowSettings, camera: CameraT) -> Result { 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, +} + +#[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>) -> WindowSettings + { + WindowSettings { size, title: title.into() } + } +} -- cgit v1.2.3-18-g5258