1
0
Fork 0
mirror of https://github.com/ocornut/imgui.git synced 2026-01-11 00:04:24 +00:00

Backends: GLFW, SDL2: ImplXXX_GetContentScaleXXX() helpers return 1.0f on emscripten / apple / android (#8742, #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.
This commit is contained in:
Pascal Thomet 2025-06-27 13:40:48 +02:00 committed by ocornut
parent 7c51c0e3de
commit 18dca11dd0
4 changed files with 9 additions and 4 deletions

View file

@ -61,6 +61,9 @@ Other changes:
- Demo: Added "Text -> Font Size" demo section. (#8738) [@Demonese]
- CI: Fixed dllimport/dllexport tests. (#8757) [@AidanSun05]
- CI: Updated to use latest Windows image + VS2022.
- Backends: GLFW, SDL2 made ImGui_ImplGLFW_GetContentScaleXXX() and
ImGui_ImplSDL2_GetContentScaleXXXX() helpers return 1.0f on Emscripten
and Android platforms, matching macOS logic. (#8742, #8733) [@pthom]
- Backends: SDL3: avoid calling SDL_StartTextInput() again if already active.
(fixes e.g.: an issue on iOS where the keyboard animation will popup every
time the user types a key + probably other things) (#8727) [@morrazzzz]