Repository navigation
context: clamp to_window_coords result to window bounds - #7
Merged
Merged
Conversation
Without the clamp a widget corner outside the window (e.g. when a ruis::window is dragged past the app window's left or top edge) produces a negative value which wraps to a huge number when cast to uint32_t, corrupting the scissor rectangle so the widget's contents disappear instead of being clipped at the window edge (the GL variant already clamps).
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7 +/- ##
=====================================
Coverage 0.00% 0.00%
=====================================
Files 24 24
Lines 1389 1388 -1
Branches 499 499
=====================================
+ Misses 1389 1388 -1 ☔ View full report in Codecov by Harness. |
igagis
reviewed
Nov 25, 2026
igagis
reviewed
Nov 25, 2026
igagis
reviewed
Nov 25, 2026
igagis
reviewed
Nov 25, 2026
… using vector ops
igagis
approved these changes
Nov 25, 2026
igagis
approved these changes
Nov 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In the Vulkan variant, when a clipped widget (e.g. a ruis::window) is dragged so part of it extends past the app window's left or top edge, its contents disappear entirely. The OpenGL variant clips correctly at the window edge.
Root cause
context::to_window_coords()converts NDC -> window pixels withstatic_cast<uint32_t>and had no clamp (the GL variant clamps viap = max(p, {0,0})).An off-screen corner has NDC < -1, so
(ndc + 1) * 0.5 * sizeis a negative float. Cast to uint32_t it wraps to ~2^32. The scissor rectangle is then built from min/max of the two corners, so its origin lands on the widget's right edge x with a near-2^32 width - the entire visible portion ends up outside the scissor and nothing is drawn.Fix
Clamp the computed pixel coords to
[0, w] x [0, h]before the uint32_t cast (mirrors the GL clamp, and also clamps the max side so the scissor can never overshoot the render area).Verified: full build + all tests pass; manual run confirms the window now clips at the app window edge instead of its contents vanishing.