-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[rcore] GetWindowScaleDPI()
inconsistency : RGFW
and GLFW
backends disagree
#4142
Comments
Regarding GLFW's
|
I think GLFW backend is correct. |
This looks like a problem with RGFW itself rather than rcore_desktop_rgfw.c. It would be better to move the issue to the RGFW repo |
The GLFW backend returns DPI scales factors. Shouldn't If yes, then the issue is in the RGFW backend side. (and maybe also on the RGFW repo if DPI scale is not detected correctly) edit : i've just noticed you're the author of RGFW :-D |
GLFWAPI void glfwGetWindowContentScale(GLFWwindow* handle,
float* xscale, float* yscale)
{
if (xscale)
*xscale = 0.f;
if (yscale)
*yscale = 0.f;
_GLFW_REQUIRE_INIT();
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
_glfw.platform.getWindowContentScale(window, xscale, yscale);
} https://github.com/glfw/glfw/blob/b35641f4a3c62aa86a0b3c983d163bc0fe36026d/src/window.c#L752 |
I'm confused with the wording "glfwGetWindowContentScale" seems like it should be the content scale for that window Do you know if Vector2 GetWindowScaleDPI(void)
{
RGFW_monitor monitor = RGFW_window_getMonitor(platform.window);
return (Vector2){((u32)monitor.scaleX), ((u32) monitor.scaleX)};
} returns the same output as GLFW? |
I tested both backends. With a 1280x720 window, here are the result of both on my Linux system :
Here the test code i used : #include "raylib.h"
void update();
void draw();
int main( int argc , char **argv )
{
// SetWindowState( FLAG_MSAA_4X_HINT );
// SetConfigFlags(FLAG_WINDOW_HIGHDPI); // <======= ???
InitWindow( 1280 , 720 , "Test" );
ClearWindowState( FLAG_VSYNC_HINT );
SetTargetFPS( 60 );
//SetWindowState( FLAG_WINDOW_RESIZABLE );
while( ! WindowShouldClose() )
{
update();
BeginDrawing();
{
ClearBackground( RAYWHITE );
draw();
}
EndDrawing();
}
CloseWindow();
}
void update()
{
if ( IsKeyPressed( KEY_F ) )
{
// SetWindowSize( 1280 , 720 );
// ClearWindowState( FLAG_WINDOW_RESIZABLE );
ToggleFullscreen();
// SetWindowState( FLAG_WINDOW_RESIZABLE );
// SetWindowSize( 1280 , 720 );
}
else
if ( ! IsWindowFullscreen() && IsKeyPressed( KEY_B ) )
{
ToggleBorderlessWindowed();
}
}
void draw()
{
int sw = GetScreenWidth();
int sh = GetScreenHeight();
int rw = GetRenderWidth();
int rh = GetRenderHeight();
Vector2 dpi = GetWindowScaleDPI();
int monitor = GetCurrentMonitor();
int mw = GetMonitorWidth( monitor );
int mh = GetMonitorHeight( monitor );
Rectangle infoRect = { 0.0 , 0.0 , sw , sh };
// Draw the border of the screen :
DrawRectangleLinesEx( infoRect , 300.0f , RED );
// Draw the text NOT in the center :
DrawText( TextFormat( "Screen : %d x %d" , sw , sh ) , 10 , 10 , 30 , BROWN );
DrawText( TextFormat( "Render : %d x %d" , rw , rh ) , 10 , 40 , 30 , DARKGREEN );
DrawText( TextFormat( "Monitor[%d] : %d x %d" , monitor , mw , mh ) , 10 , 70 , 30 , DARKBLUE );
DrawText( TextFormat( "DPI : %f x %f" , dpi.x , dpi.y ) , 10 , 100 , 30 , BLACK );
DrawText( TextFormat( "infoRect : %f x %f" , infoRect.width , infoRect.height ) , 10 , 140 , 30 , RED ); // <===
} |
Could you try to change it to Vector2 GetWindowScaleDPI(void)
{
RGFW_monitor monitor = RGFW_window_getMonitor(platform.window);
return (Vector2){monitor.scaleX, monitor.scaleX};
} instead? |
actually I'll test this myself |
just tested. I don't think it has to return the exact same value as GLFW, because the GLFW documentation remains quite vague regarding the way the DPI scales are computed. They say there is a mix of this and mix of that, and that, at the end, it is system dependent. However, if your RGFW framework tries to match the DPI scale of the system, I think we should also open an issue on your repo, because the value does not change when I change the system display DPI setting to 200%. edit : also, other backends (SDL, Android; DRM) just return |
@SuperUserNameMan I get {1.0, 1.0} on both glfw and rgfw no matter what settings I have. Could be something with manjaro. |
No don't worry. I'm on Linux Mint with MATE desktop. I must have a default DPI hardcoded somewhere on my distro that explains my strange The most important, is that it matches when you change the DPI scale of your display settings. |
Note that this If |
Thanks for all the analysis. I'm uncertain when some of these need to be happening though. I guess the trick will be to see how the raylib/examples can be kept simple. |
Testing the RGFW backend and comparing with GLFW :
GetWindowSCaleDPI()
don't return similar values.On my Linux desktop :
incorrectunexpected{ 1.145833 , 1.145833 }
value despite the display scale is set to 100%.I don't know which one is correct. Maybe none ? (edit: i think GLFW backend is correct, but it needs a tiny fix somewhere else to solve #3972)
raylib/src/platforms/rcore_desktop_glfw.c
Lines 935 to 941 in 9764fef
raylib/src/platforms/rcore_desktop_rgfw.c
Lines 641 to 649 in 9764fef
The text was updated successfully, but these errors were encountered: