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
This commit is contained in:
crispweed authored and GitHub committed 2020-08-25 13:25:50 -04:00
1 parent 7396e92fcb
commit 1935cfa28a
2 files changed
+3 -8

No files matched your search

+2 -2
View File
@@ -250,8 +250,8 @@ fn start<E: Example>(
..
} => {
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);
}
+1 -6
View File
@@ -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.