From b647cd35f13f456419ad2a94e3897dd10f2a34e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Capucho?= Date: Fri, 4 Jun 2021 22:05:47 +0100 Subject: [PATCH] Don't draw when window size is minimized --- voxygen/src/render/renderer.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/voxygen/src/render/renderer.rs b/voxygen/src/render/renderer.rs index d660154c0c..6870c32e42 100644 --- a/voxygen/src/render/renderer.rs +++ b/voxygen/src/render/renderer.rs @@ -135,6 +135,10 @@ pub struct Renderer { profiler: wgpu_profiler::GpuProfiler, profile_times: Vec, profiler_features_enabled: bool, + + // This checks is added because windows resizes the window to 0,0 when + // minimizing and this causes a bunch of validation errors + is_minimized: bool, } impl Renderer { @@ -391,6 +395,8 @@ impl Renderer { profiler, profile_times: Vec::new(), profiler_features_enabled, + + is_minimized: false, }) } @@ -481,6 +487,7 @@ impl Renderer { pub fn on_resize(&mut self, dims: Vec2) -> Result<(), RenderError> { // Avoid panics when creating texture with w,h of 0,0. if dims.x != 0 && dims.y != 0 { + self.is_minimized = false; // Resize swap chain self.resolution = dims; self.sc_desc.width = dims.x; @@ -547,6 +554,8 @@ impl Renderer { }, } } + } else { + self.is_minimized = true; } Ok(()) @@ -723,6 +732,10 @@ impl Renderer { "Renderer::start_recording_frame" ); + if self.is_minimized { + return Ok(None); + } + // Try to get the latest profiling results if self.mode.profiler_enabled { // Note: this lags a few frames behind