Skip to content

fix: initialize rotation rects to fix desktop rendering#24

Closed
TheSecurityDev wants to merge 5 commits intocommaai:platform-offscreenfrom
TheSecurityDev:fix-desktop-rotation-rects
Closed

fix: initialize rotation rects to fix desktop rendering#24
TheSecurityDev wants to merge 5 commits intocommaai:platform-offscreenfrom
TheSecurityDev:fix-desktop-rotation-rects

Conversation

@TheSecurityDev
Copy link
Copy Markdown

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-offscreen instead of master since the former is the branch used by commaai/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

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
Copilot AI review requested due to automatic review settings March 3, 2026 04:15
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_source and CORE.Window.rotation_destination in InitWindow().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/rcore.c
Comment on lines +679 to +681
// 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 };
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Author

@TheSecurityDev TheSecurityDev Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But comma platform needs to override these values inside InitPlatform (init_screen)

@adeebshihadeh
Copy link
Copy Markdown

Fixing in my rebase to raylib 6.0

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.

3 participants