From 7fd38979640883c3bba33e32bf8580334c624706 Mon Sep 17 00:00:00 2001 From: Jarrod Doyle Date: Fri, 20 Oct 2023 11:15:11 +0100 Subject: [PATCH] Resize the window surface when the window is resized --- src/core/app.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/core/app.rs b/src/core/app.rs index 82cfeda..ecf566d 100644 --- a/src/core/app.rs +++ b/src/core/app.rs @@ -45,7 +45,7 @@ impl App { } } - pub fn run(self) { + pub fn run(mut self) { let mut camera_controller = camera::CameraController::new( &self.render_ctx, camera::Camera::new( @@ -91,6 +91,12 @@ impl App { window_id, } if window_id == self.render_ctx.window.id() => match event { WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit, + WindowEvent::Resized(physical_size) => { + self.render_ctx.resize(*physical_size); + } + WindowEvent::ScaleFactorChanged { new_inner_size, .. } => { + self.render_ctx.resize(**new_inner_size); + } _ => { camera_controller.process_events(event); }