diff options
| author | Micha White <botahamec@outlook.com> | 2022-11-27 22:43:56 -0500 |
|---|---|---|
| committer | Micha White <botahamec@outlook.com> | 2022-11-27 22:43:56 -0500 |
| commit | 1b894125ccc1932cd291c0e9a3b6b88c61ab3747 (patch) | |
| tree | 32ef36558cdd04204030eeb39770400bf7f00a74 /alligator_render/src | |
| parent | 75752a400925738d90c2267b4c15ef2b554725fe (diff) | |
Fixed leak that occurs when window is minimized
Diffstat (limited to 'alligator_render/src')
| -rw-r--r-- | alligator_render/src/renderer.rs | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/alligator_render/src/renderer.rs b/alligator_render/src/renderer.rs index 27e7884..ee507bd 100644 --- a/alligator_render/src/renderer.rs +++ b/alligator_render/src/renderer.rs @@ -385,19 +385,23 @@ impl Renderer { } Event::MainEventsCleared => { f(&mut self); - match self.render() { - Ok(_) => {} - // reconfigure the surface if it's been lost - Err(wgpu::SurfaceError::Lost) => { - self.reconfigure(); - } - // if we ran out of memory, then we'll die - Err(wgpu::SurfaceError::OutOfMemory) => { - *control_flow = ControlFlow::ExitWithCode(1); + if self.window.inner_size().width != 0 && self.window.inner_size().height != 0 { + match self.render() { + Ok(_) => {} + // reconfigure the surface if it's been lost + Err(wgpu::SurfaceError::Lost) => { + self.reconfigure(); + } + // if we ran out of memory, then we'll die + Err(wgpu::SurfaceError::OutOfMemory) => { + *control_flow = ControlFlow::ExitWithCode(1); + } + // otherwise, we'll just log the error + Err(e) => log::error!("{}", e), } - // otherwise, we'll just log the error - Err(e) => log::error!("{}", e), - }; + } else { + *control_flow = ControlFlow::Wait; + } profiling::finish_frame!(); } _ => {} |
