Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect bounds check for set_scissor_rect #167

Merged
merged 2 commits into from
Mar 26, 2023

Conversation

Gorialis
Copy link
Contributor

In EguiNode::run, an attempt is made to fix for bad scissor rect bounds by the width & height of the scissor rect to the physical window.
However, this only works if the scissor rect starts at (0, 0); if it isn't, then the scissor rect may still go out of bounds of the window.

This can cause a panic from wgpu when window.resolution.set(x, y) is called from WASM with a resolution lower than the current setting, as when the window updates, but the egui draw commands haven't been updated, the scissor rect can extend outside of the render target if it has an offset top-left corner.
image

This PR changes it so that the scissor rect bound check subtracts the upper left coordinate, ensuring that the scissor rect remains within the bounds of the window even if the draw command doesn't originate at the top left.

I have tested and confirmed this change fixes the panic and doesn't appear to have any rendering inconsistencies either from WASM or Windows.

@mvlabat
Copy link
Owner

mvlabat commented Mar 26, 2023

Great catch, thank you for the fix!

@mvlabat mvlabat merged commit 5d311c0 into mvlabat:main Mar 26, 2023
StrikeForceZero pushed a commit to StrikeForceZero/bevy_egui that referenced this pull request Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants