fix: initialize rotation rects to fix desktop rendering#24
fix: initialize rotation rects to fix desktop rendering#24TheSecurityDev wants to merge 5 commits intocommaai:platform-offscreenfrom
Conversation
Temp windows (e.g., for monitor queries) set rotation rects, and CloseWindow didn't reset them, causing the next window's blit to use wrong rects. Reset to zero so InitWindow guard can reinitialize properly.
- Set identity rotation rects in InitWindow for all platforms - Comma platform overrides with device-specific rotation in InitPlatform - Reset rects in CloseWindow to prevent state poisoning - Ensures FBO blit works on desktop without rotation
…soning" This reverts commit fc93575.
There was a problem hiding this comment.
Pull request overview
Initializes default rotation/copy rectangles in raylib’s core window initialization so desktop/offscreen rendering has non-empty source/destination rects for the final blit step (addressing openpilot issue #37533).
Changes:
- Add default initialization of
CORE.Window.rotation_sourceandCORE.Window.rotation_destinationinInitWindow().
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Initialize default rotation rects | ||
| CORE.Window.rotation_source = (Rectangle){ 0.0f, 0.0f, (float)CORE.Window.screen.width, -(float)CORE.Window.screen.height }; | ||
| CORE.Window.rotation_destination = (Rectangle){ 0.0f, 0.0f, (float)CORE.Window.screen.width, (float)CORE.Window.screen.height }; |
There was a problem hiding this comment.
These defaults are initialized before InitPlatform(), but several platform backends can update CORE.Window.screen.width/height during InitPlatform() (e.g., GLFW sets them from the monitor when the requested size is 0). In those cases these rects remain stale/empty and EndDrawing() will still copy the render texture into a 0x0 destination. Consider moving this initialization to after InitPlatform() (once screen dimensions are finalized) or recomputing based on the actual rotated_fb/render sizes.
There was a problem hiding this comment.
But comma platform needs to override these values inside InitPlatform (init_screen)
|
Fixing in my rebase to raylib 6.0 |
Fixes commaai/openpilot#37533. Comma platform should still override these default rotations later, but for desktop rendering we need non-empty defaults, otherwise so the render texture is copied to an empty rect. I guess this change became necessary due to vendored raylib with offscreen support.
Opening against
platform-offscreeninstead ofmastersince the former is the branch used bycommaai/dependencies.https://github.com/commaai/dependencies/blob/2e9aed768a3ec2bdc6d18313b86b422969460b61/raylib/build.sh#L66-L71
This is what I'm testing with in
pyproject.toml:raylib @ git+https://github.com/TheSecurityDev/openpilot-dependencies.git@5c8119b047c7f911f264c34266c658d345ed993b#subdirectory=raylib