Skip to content
This repository has been archived by the owner on Jun 18, 2021. It is now read-only.

Water example viewport goes black momentarily on resize #532

Closed
crispweed opened this issue Aug 24, 2020 · 1 comment · Fixed by #534
Closed

Water example viewport goes black momentarily on resize #532

crispweed opened this issue Aug 24, 2020 · 1 comment · Fixed by #534
Labels
bug Something isn't working

Comments

@crispweed
Copy link
Contributor

Looking at the resize function for this example, I see:

        if sc_desc.width == 0 && sc_desc.height == 0 {
            // 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);
        }

That doesn't seem to make sense, and changing to the following resolves the issue for me (viewport no longer goes black momentarily on resize):

       if sc_desc.width == 0 && sc_desc.height == 0 {
            // Stop rendering altogether.
            self.active = None;
            return;
        } 

        self.active = Some(self.current_frame);
@kvark
Copy link
Member

kvark commented Aug 24, 2020

Sounds reasonable. Want to make a small PR?

@kvark kvark added the bug Something isn't working label Aug 24, 2020
kvark pushed a commit that referenced this issue Aug 25, 2020
…e 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
kejor pushed a commit to kejor/wgpu-rs that referenced this issue Nov 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants