From 8426db3e46bd709f0df98cf890ffdd73c87ecaef Mon Sep 17 00:00:00 2001 From: ElhamAryanpur Date: Sat, 17 Feb 2024 10:50:08 +0300 Subject: [PATCH] fix: surface error for non zero size on windows --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/render.rs | 27 +++++++++++++++------------ 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5306829..1bc917a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -297,7 +297,7 @@ dependencies = [ [[package]] name = "blue_engine" -version = "0.5.5" +version = "0.5.6" dependencies = [ "android_logger", "bytemuck", diff --git a/Cargo.toml b/Cargo.toml index 343895f..72e9d5f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "blue_engine" -version = "0.5.5" +version = "0.5.6" authors = ["Elham Aryanpur "] edition = "2021" description = "General-Purpose, Easy-to-use, Fast, and Portable graphics engine" diff --git a/src/render.rs b/src/render.rs index b81ffb1..ce5fe0d 100644 --- a/src/render.rs +++ b/src/render.rs @@ -187,18 +187,21 @@ impl Renderer { /// # Arguments /// * `new_size` - The new window size. pub(crate) fn resize(&mut self, new_size: winit::dpi::PhysicalSize) { - self.size = new_size; - self.config.width = new_size.width; - self.config.height = new_size.height; - #[cfg(not(feature = "android"))] - self.surface - .as_ref() - .unwrap() - .configure(&self.device, &self.config); - #[cfg(not(feature = "android"))] - { - self.depth_buffer = - Self::build_depth_buffer("Depth Buffer", &self.device, &self.config); + // check if new_size is non zero + if new_size.width != 0 && new_size.height != 0 { + self.size = new_size; + self.config.width = new_size.width; + self.config.height = new_size.height; + #[cfg(not(feature = "android"))] + self.surface + .as_ref() + .unwrap() + .configure(&self.device, &self.config); + #[cfg(not(feature = "android"))] + { + self.depth_buffer = + Self::build_depth_buffer("Depth Buffer", &self.device, &self.config); + } } }