From 1935cfa28a5ca6f8f93abbec6e31cf13dba691e8 Mon Sep 17 00:00:00 2001 From: crispweed Date: Tue, 25 Aug 2020 19:25:50 +0200 Subject: [PATCH] Removed erroneous zero size check related conditional in water example resize() (#534) * The conditional at the start of resize() already tests for and exits on the zero width and height condition. The conditional removed here was then getting run on every other call to resize(), which doesn't seem logical, doesn't correspond to the comment, and seemed to be causing at least one issue with rendered viewport going black during resize. Fixes #532 (probably) Fixes #519 * Defensive coding to prevent various issues when window size goes to zero, e.g. NaN being passed in cgmath::perspective() aspect ratio parameter. Fixes #531 --- examples/framework.rs | 4 ++-- examples/water/main.rs | 7 +------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/examples/framework.rs b/examples/framework.rs index 07bd3d5aa..9f574d6e5 100644 --- a/examples/framework.rs +++ b/examples/framework.rs @@ -250,8 +250,8 @@ fn start( .. } => { log::info!("Resizing to {:?}", size); - sc_desc.width = size.width; - sc_desc.height = size.height; + sc_desc.width = if size.width == 0 { 1 } else { size.width }; + sc_desc.height = if size.height == 0 { 1 } else { size.height }; example.resize(&sc_desc, &device, &queue); swap_chain = device.create_swap_chain(&surface, &sc_desc); } diff --git a/examples/water/main.rs b/examples/water/main.rs index a3fcbc7ba..8b57f050a 100644 --- a/examples/water/main.rs +++ b/examples/water/main.rs @@ -648,13 +648,8 @@ impl framework::Example for Example { // Stop rendering altogether. self.active = None; return; - } else { - // The next frame queued is the wrong size: (0, 0), - // so we skip a frame to avoid crashes where our - // textures are the correct (window) size, and the - // frame is still (0, 0). - self.active = Some(self.current_frame + 1); } + self.active = Some(self.current_frame); // Regenerate all of the buffers and textures.