From 8c53a2d7b7bda74786f4d6e35f0bbdcc0f900d6b Mon Sep 17 00:00:00 2001 From: Jarrod Doyle Date: Fri, 20 Oct 2023 11:05:38 +0100 Subject: [PATCH] Add window surface resizing function --- src/gfx/context.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/gfx/context.rs b/src/gfx/context.rs index f10d8cc..3e8b6c6 100644 --- a/src/gfx/context.rs +++ b/src/gfx/context.rs @@ -68,4 +68,13 @@ impl Context { queue, } } + + pub fn resize(&mut self, new_size: PhysicalSize) { + if new_size.width > 0 && new_size.height > 0 { + self.size = new_size; + self.surface_config.width = new_size.width; + self.surface_config.height = new_size.height; + self.surface.configure(&self.device, &self.surface_config); + } + } }