-
-
Notifications
You must be signed in to change notification settings - Fork 11k
Backends: Glfw, SDL2: ImplXXXGetContentScale shall return 1 on emscripten / apple / android #8742
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
base: master
Are you sure you want to change the base?
Conversation
Thanks for the PR. There is a Is the value of |
…pten / apple / android This is a fix related to ocornut#8733 We can divide platforms into two cases based on how they report screen geometry: Case 1: Platforms which report screen size in "physical pixels": Windows (for "Dpi aware" apps), Linux (with Wayland) Case 2: Platforms which report screen size in "density-independent pixels": macOS, iOS, Android, emscripten As a consequence, there are two important things we need to know: FramebufferScale: The scaling factor FrameBufferSize / ScreenSize In case 1, the framebuffer size is equal to the screen size and DisplayFramebufferScale=1. In case 2, the framebuffer size is equal to the screen size multiplied by a factor, for example DisplayFramebufferScale=2. ContentScale The scaling factor for the content that we will display In case 1, the content scale will often need to be > 1 (e.g., 2), because we will need to display bigger elements so that they show with a correct physical size on the screen. In case 2, the content scale is equal to 1 This commit fixes ContentScale for platforms in case 2.
fixed, sorry |
This unofficial port offers a better support for HighDPI. See - https://emscripten.org/docs/compiling/Contrib-Ports.html - https://github.com/pongasoft/emscripten-glfw
This was done using the flag This way, we use emscripten-glfw, which offers a better support for HighDPI.
Note: an alternative (but faulty) solution would have been to stick to #ifdef __EMSCRIPTEN__
glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE);
#endif This solution works partially (the FrameBufferScale is passed). However, it will create a window with a bad size as soon as the browser zoom level is not 100%. It is therefore not applicable. |
@@ -32,8 +32,9 @@ EMS = | |||
##--------------------------------------------------------------------- | |||
|
|||
# ("EMS" options gets added to both CPPFLAGS and LDFLAGS, whereas some options are for linker only) | |||
EMS += -s DISABLE_EXCEPTION_CATCHING=1 | |||
LDFLAGS += -s USE_GLFW=3 -s USE_WEBGPU=1 | |||
# Note: For glfw, we use emscripten-glfw port (contrib.glfw3) instead of (-s USE_GLFW=3) to get a better support for High DPI displays. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just an FYI, emscripten-glfw offers much more than better support for Hi DPI, like for example gamepad support, copy/paste, workaround for meta key (broken with -s USE_GLFW=3
), etc...
This is a fix related to #8733
We can divide platforms into two cases based on how they report screen geometry:
Case 1: Platforms which report screen size in "physical pixels": Windows (for "Dpi aware" apps), Linux (with Wayland)
Case 2: Platforms which report screen size in "density-independent pixels": macOS, iOS, Android, emscripten
As a consequence, there are two important things we need to know:
FramebufferScale: The scaling factor FrameBufferSize / ScreenSize
ContentScale The scaling factor for the content that we will display
This commit fixes ContentScale for platforms in case 2.