Repository navigation
[rcore] Make GetWindowScaleDPI() consistent on all backends - #6402
Conversation
|
@Ne0nWinds I'm checking this PR and thinking if this is the best/right approach for the user. The idea behind returning 1.0f for screen scaling matching logical-physical units was for convenience for the user if no HighDPI was enabled (and managed internally)... but now I think about the possibility of user deciding to manage HighDPI on their side; in that case it would have no way to get the current display scaling DPI factor. What do you think? |
|
@raysan5 Yeah, I think it'd much better if That allows the user to have much more control. If they want the existing float GetDPIScale() {
float scale = 1.0f;
if (!IsWindowFullscreen() && IsWindowState(FLAG_WINDOW_HIGHDPI))
{
scale = GetWindowDPIScale().x;
}
return scale;
}I think it's probably better to just let the user decide how they want to handle high-dpi scaling when Maybe we could even make a small example for how to have custom logic for high-dpi, too. For this PR, I could remove all the changes to other backends and only change |
|
@Ne0nWinds Ok, let's return the current scale DPI so user can manage it at user side if desired.
Definitely a usage example could be useful.
Ok, leet's do it. Note that |
GetWindowScaleDPI() consistent on all desktop and web backendsGetWindowScaleDPI() consistent on all backends
| { | ||
| Vector2 scale = GetWindowScaleDPI(); | ||
| Vector2 scale = { 1.0f, 1.0f }; | ||
| if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI) && !FLAG_IS_SET(CORE.Window.flags, FLAG_FULLSCREEN_MODE)) scale = GetWindowScaleDPI(); |
There was a problem hiding this comment.
I don't have an apple device to test this, but this shouldn't change the behavior
|
One note: it looks like the scissor rendering mode on Minimal repro: int main(void)
{
SetConfigFlags(FLAG_WINDOW_HIGHDPI);
InitWindow(800, 450, "scissor");
while (!WindowShouldClose())
{
// issue only happens in fullscreen
if (IsKeyPressed(KEY_F)) ToggleFullscreen();
BeginDrawing();
ClearBackground(DARKBLUE);
BeginScissorMode(100, 100, 200, 100);
ClearBackground(RED);
EndScissorMode();
// draw where the red scissored rectangle should appear
DrawRectangleLines(100, 100, 200, 100, GREEN);
EndDrawing();
}
CloseWindow();
return 0;
}It's wrong both before and after my PR (if you compare with The fullscreen scissor logic is unchanged for |
|
@Ne0nWinds Thanks for the full review. I'm testing on macOS later today. About Android, it's been a while I didn't work with that platform, maybe @Bigfoot71 can help on that regards (if not too busy). I will also try to setup an Android env for testing. |
|
@Ne0nWinds tested on macBook Air M4 laptop, it works as expected |



GLFWreturn1.0whenFLAG_WINDOW_HIGHDPIis not set, while all other backends return the actual window DPI.This PR makes
GLFWmatch the other backends.Many places in
rcorerelied on the old behavior ofGLFW. They've been updated tooRelated PRs:
#6372: Bug in various examples with
GetWindowScaleDPI()#6352: Win32 HighDPI Support, where I first noticed this issue