Skip to content

[examples] Fix 2D camera offsets - #6372

Merged
raysan5 merged 2 commits into
raysan5:masterfrom
Ne0nWinds:examples-render-scale-fix
Nov 7, 2026
Merged

raysan5 merged 2 commits into
raysan5:masterfrom
Ne0nWinds:examples-render-scale-fix

Conversation

@Ne0nWinds

@Ne0nWinds Ne0nWinds commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

A few of the examples used GetWindowScaleDPI() to calculate the camera offset. This is wrong, and can be seen by enabling FLAG_WINDOW_HIGHDPI on GLFW or by using the SDL or RGFW backends on core_2d_camera_split_screen:

GLFW with HighDPI disabled

test1234

SDL, RGFW, or GLFW w/ HighDPI enabled

image

This PR fixes 3 different examples:
core_2d_camera_split_screen and magnifying_glass both draw into fixed-size textures, so it doesn't make sense to scale the camera offset based on window DPI. We can remove the DPI window scaling entirely.

core_2d_camera_mouse_zoom has a different problem: GetWindowScaleDPI() behaves differently on GLFW than it does for other backends. With the high-dpi flag turned off, GLFW makes GetWindowScaleDPI() return 1.0, while other backends return the actual window DPI.

To fix core_2d_camera_mouse_zoom, I manually calculated the camera offset scale instead of using GetWindowScaleDPI(). This makes it work correctly on all existing backends (until we fix the underlying problem with GetWindowScaleDPI).

@raysan5
raysan5 merged commit b72f037 into raysan5:master Nov 7, 2026
17 checks passed
@raysan5

raysan5 commented Nov 7, 2026

Copy link
Copy Markdown
Owner

@Ne0nWinds Good catch! thanks for the review!

@Ne0nWinds
Ne0nWinds deleted the examples-render-scale-fix branch November 7, 2026 18:15
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.

2 participants