-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
[core] Bad GetScreenWidth/GetScreenHeight values after resizing windows with FLAG_WINDOW_HIGHDPI #1982
Comments
When working with high dpi, we have the concept of physical size and logical size. Here it is confusing if GetScreenWidth/GetScreenHeight are supposed to be the logical or the physical size, but since at startup they return the logical size, I guess it is supposed to also return the logical size after a window resize. Maybe a less confusing API would be to have a different set of functions with explicit naming:
but of course, this would be a breaking change. Here is an interesting resource from the documentation of glium, a library to use opengl api with rust programming language https://docs.rs/glium/0.22.0/glium/glutin/dpi/index.html |
I have made more tests and the problem also exists on linux (manjaro), but everything works fine on macos. To summarize, on window and linux, there is a bug where GetScreenWidth/GetScreenHeight are returning the physical size instead of the logical size after a window resize. |
Hi @ArnaudValensi, actually raylib had some issues managing HighDPI so About logical and physical size, we can also add a virtual size, for example, in case we are using a Considering all the possibilities is not easy, there could be multiple side cases. Obviously there is a lot of room for improvement in raylib. |
Hi @raysan5, Thank you for your answer :) I would be happy to help. As a first step, I can try to make GetScreenWidth / GetScreenHeight return consistent value before and after a screen resize. Here is the current behavior: MacOS: Before resize: return the logical size. I think it is the expected behavior. Windows and Linux: Before resize: return the logical size. What do you think? |
Observing this, I suspect this is correct. My suspicion is that the information should be in terms of the simplest thing the application needs to know and does not require anything sophisticated to work with. To know that rendering is at a higher resolution via stages of interpolations and/or vectoring is more demanding and also not clear what of that information is useful to the graphical application and under whose control. This might mean more inside openGL than directly. It could be relevant with regard to font rendering perhaps. I am too ignorant to have any insight on the layering of abstractions that might work best. (Observing the complexity of Microsoft Terminal development, it seems I am not alone in that.) |
@ArnaudValensi Thanks for reviewing this issue! The expected behaviour is:
This way the user can manage HighDPI if required using I took a look to the possible problem and it directed me to: // GLFW3 WindowSize Callback, runs when window is resizedLastFrame
// NOTE: Window resizing not allowed by default
static void WindowSizeCallback(GLFWwindow *window, int width, int height)
{
// Reset viewport and projection matrix for new size
SetupViewport(width, height);
CORE.Window.currentFbo.width = width;
CORE.Window.currentFbo.height = height;
CORE.Window.resizedLastFrame = true;
if (IsWindowFullscreen()) return;
// Set current screen size
CORE.Window.screen.width = width;
CORE.Window.screen.height = height;
// NOTE: Postprocessing texture is not scaled to new size
} It seems GLFW could be managing the The |
@raysan5 I found an issue in this function, but also at the initialization. I fixed it here: #1987 |
@ArnaudValensi thanks again for this great improvement! |
@raysan5 you're welcome :) Thank you for raylib ;) |
Issue description
Hi,
When using FLAG_WINDOW_HIGHDPI, the GetScreenWidth/GetScreenHeight functions are giving bad values after a window resize. See the video below.
In this example, the GuiStatusBar disappears after a window resize.
Environment
Issue Screenshot
8KBajZI0BV.mp4
Code Example
You can reproduce by doing a
make run
in the following repo https://github.com/ArnaudValensi/raylib-highdpi-issueThe text was updated successfully, but these errors were encountered: