summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMicha White <botahamec@outlook.com>2022-11-27 22:43:56 -0500
committerMicha White <botahamec@outlook.com>2022-11-27 22:43:56 -0500
commit1b894125ccc1932cd291c0e9a3b6b88c61ab3747 (patch)
tree32ef36558cdd04204030eeb39770400bf7f00a74
parent75752a400925738d90c2267b4c15ef2b554725fe (diff)
Fixed leak that occurs when window is minimized
-rw-r--r--alligator_render/src/renderer.rs28
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!();
}
_ => {}