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
Unification of HDPI scaling across platforms #677
Comments
+1 |
Look, a can of worms! I wonder what's inside. This adds the first platform specific window hint, transforming a compile-time option to a run-time per-window one.
Hello, I was looking for updates on this issue and I just read this commit. Am I correct saying that |
I don't believe this feature is needed on Linux. On Linux, HDPI is defined by the desktop enviroment, and there are many desktop enviroment. Each DE will report the HDPI scale in a different way (may be a configuration file, using a library or a configuration system like dconf). Best way is to check how the DEs that you want to support HDPI report these and implement a solution for them. |
By my understanding of this documentation
and by the X11 behaviour described in this comment
the new feature should only affect Windows and macOS OSs. |
I am (still) seeing the same issues as originally reported by @badlogic on master (34d20b0). On Windows 10 the window size is equal to framebuffer size on systems that report a content scaling of 2.0. Is this the intended behaviour? If so what tools are there to make sure I am creating the window at the right size? |
That is the intended behavior. The window size and framebuffer size will always match on Windows and X11. On those platforms, the window (and framebuffer) is resized according to the monitor's scale. If you have Edit: If you then move it to a monitor with scaling factor 1.5, it will resize (window and framebuffer) to 960x720. |
@elmindreda ugh, i deleted the comment because I realized I was accidentally still linking against the glfw that I installed with apt and your response was not showing at the time. So what is the proper way to deal with the differences across platforms then? i.e. On windows and ubuntu I get the same value for window size and framebuffer but what I really want to get from window size is the original size I put in because i.e. I use that to setup certain projections. To handle this case properly, will I need to check platform and the scalefactor and do the right thing accordingly? Wouldn't it be better if glfw decides on one way of how to go about this and consistently does it across platforms? I am propably missing something, just thinking out loud. Thanks! |
Just to illustrate why I agree with @badlogic that the way osx does it is better (i.e. separate between window size and framebuffer size). Let's say you have some code that works in a sequence like this:
While in a lot of high end code, you'll hopefully not encounter this, it is very common for basic examples (where glfw is used very often). On osx, the above still works perfectly fine. On linux (and windows) this wont work anymore without doing a lot of extra lifting to determine if we are on a hidpi display or not etc. Either way, I think it would be lovely if glfw would pick one way (i.e. either the windows/linux or osx) and stick with it. |
GlfwMouseInput - add a conversion between window coordinates and canvas point coordinates. glfw/glfw#677
On Mac OS X, GLFW reports screen sizes and framebuffer sizes properly if upscaling is enabled in the OS. E.g. on a "retina" display at 2x upscaling, creating a window at 900x600 screen size will result in a 1800x1200 frame buffer size.
For the same scenario on Windows, with HDPI scaling set to 200%, the window size is actually interpreted as the framebuffer size, not the screen size. This results in a window of framebuffer size 900x600 pixels instead of 1800x1200 pixels. The window's screen size is then actually smaller as what was specified during window creation (450x300 at 200% upscaling). However, GLFW reports the framebuffer size as the screen size (900x600), which makes detection and handling of HDPI upscaling impossible on Windows.
I have not tested this on Linux. My assumption would be that it probably works like on Windows (screen size == framebuffer size irrespective of upscaling settings).
It'd be great if this worked the same on all operating systems, preferably the way it works on Mac OS X, with the screen size and framebuffer size being reported according to the upscaling setting of the OS.
If fixing this transparently is not possible, it'd be great if GLFW could expose the upscaling factor so users can perform platform specific work-arounds.
The text was updated successfully, but these errors were encountered: