-
-
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] Incorrect monitor resolution #4522
Comments
Thank you for your response. I just merged your pull request locally and I get 1.000000 from GetMonitorScale(), exactly the same value I get from GetWindowScaleDPI(). The thing is SDL3 returns the virtual size, which is the size I have to work with:
Output: Display size: 3328x2080 UPDATE: I just recompiled the same test program for Windows and it shows a Display Size of 2560x1600 (the physical size of the monitor). As for GetMonitorScale() and GetWindowScaleDPI(), both return 2.0. And setting the size of the window to 2560x1600 displays a full screen window on Windows, but a smaller one on Linux. To be honest, the virtual display size on X11 looks like a mess to me, because you need to use that size instead of the physical size of the monitor and it seems there is some kind of internal interpolation (correct me if I am wrong). |
Yes, I know. I used the GLFW backend. The SDL3 test program is not using raylib, it is using SDL3 directly.
I don't know either, I just know that it's the size I have to work with under X11. I think Wayland is different... |
Interesting, I just installed Linux Mint 22 and tried different scaling settings. When I use an integer scaling (200%), the display resolution shown by xrandr matches the physical display resolution (2560x1600) and GetWindowScaleDPI() returns 2, which is correct. But when I use fractional scaling (say 150%), the resolution shown by xrandr is scaled accordingly (so it does not match the physical resolution of the monitor anymore) and GetWindowScaleDPI() still shows 2. SDL3 works as expected in this case, because it seems fractional scaling is accomplished by altering the physical resolution of the monitor (at least on X11). This is why you have to work with a "virtual" resolution. On Windows you can use fractional scaling but still work with the physical resolution of the monitor. |
I have been doing some more testing... I have recompiled raylib with the new RGFW backend and now it behaves likes SDL3. Now GetMonitorWidth()/GetMonitorHeight() return the "virtual" resolution of the monitor (3328x2080), the same resolution shown by xrandr. HOWEVER, now I cannot use SetWindowSize() after InitWindow(), it is just ignored. |
Hi there again! I finally found the issue. It is an upstream issue of GLFW -> glfw/glfw#1961 As I said, both the SDL3 and RGFW backends return the proper values. It's a shame I can't use either of those because RGFW seems to be terribly broken and the framerate with SDL3 is not stable (I don't know why, but it is something that also happens using SDL3 directly). |
What specifically is broken?
That's strange, I'll look into this ASAP |
Apart from SetWindowSize() not working, try the following code:
This is what I get using the RGFW backend: This is the LOG output using the RGFW backend: And this is the LOG using the default GLFW backend, which works fine: |
I was curious about this example and discovered a tangential issue. I used the @xroberx code exactly and compiled it (using my VCrayApp script) using Visual Studio Build Tools and Visual Studio 2022 Developer Command Prompt v17.11.5 (latest) for x64. The Here is the closer-to-expected result on my Windows 10 desktop. The screen capture was with HyperSnap Version 9.5.2 (64-bit). I used the capture mode for the complete current Window (having the cursor, which is also captured). An interesting feature of the captured PNG image is that it is 802 pixels wide and 639 pixels deep. And that includes the GUI title bar and frame of the application area: a (single pixel?) frame of the same default color as the title bar. This might not be apparent in the GitHub rendering of this image, but I attest that it is present and visible when viewing the PNG off-line. We can see that the drawn rectangle overlays the top and right edge of the frame, but no rectangle appears at (or atop) the left and bottom frame lines. My speculation is that those parts of the rectangle are outside the frame and do not appear. Here's an example used to confirm that a cache of raylib 5.6-dev code compiles correctly and is demonstrated by a simple program using an The @xroberx problem is not confirmed in this case. But we now have something concerning the precision of framing and how there may be rounding issues in the box drawing at the edge of the displayed application area. |
@xroberx Do you mind opening the RGFW issue separately so I can look into it? |
@xroberx @raysan5 @ColleagueRiley
I have dug around and found the defect to be a problem in
The coordinates of the initial corner point should be |
@orcmid Yes, but, strangely, the RGFW one is given a viewport but the GLFW one isn't. Is that the proper behavior? |
I don't know enough to go that deep. I am relying entirely on the definition of |
@orcmid I did a quick test and I think there might be a problem with |
It seems to me that the definition of I find it weird that |
Sorry if I barge into a wrong discussion, but it seems similar to the issue that I encounter. If I am not mistaken there was a change regarding compilation for wayland recently and my problem may be unrelated (notice the difference in the name of the platform near the bottom of both logs below: Issue descriptionI try out raylib as a dependency for a zig project. With some version prior to 5.1-dev scaling (hyprland with x1.5) worked correctly, the exact version was this one:
But then I decided to upgrade to 5.5:
Now the camera viewport does not fit the window size (green is just ClearBackground called with Here are two initialization logs for comparison (GetWindowScaleDPI returns 1 in both cases): Code exampleZig version used: 0.14.0-dev.2211+05a3ac43e ZIP archive with source code (2 files): raylib-scale-issue-zig.zip Command to compile and run with:
|
Issue description
The monitor of my laptop has a resolution of 2560x1600. I have configured scaling to 1.25x through Xfce, which sets virtual resolution to 3328x2080 as can be seen in the output of the xrandr command. However, when I call GetMonitorWidth()/GetMonitorHeight(), I get the physical resolution of the monitor (2560x1600), not the virtual one. Also, GetWindowScaleDPI() returns 1.
SDL3 returns the virtual resolution on X11, so I don't think it's a misconfiguration on my part.
Environment
Hardware: Ryzen 7 8845HS laptop with Radeon 780M integrated graphics, 2560x1600 pixels monitor
Software: Linux 6.11.9, XFCE 4.18, Xorg-server 21.1.4
Issue Screenshot
Code Example
InitWindow(WIDTH, HEIGHT, "Test"); int w = GetMonitorWidth(0); int scale = GetWindowScaleDPI();
The text was updated successfully, but these errors were encountered: