mirror of
https://github.com/ocornut/imgui.git
synced 2025-12-24 07:08:54 +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:
@@ -29,6 +29,7 @@
|
||||
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2025-07-08: Made ImGui_ImplGlfw_GetContentScaleForWindow(), ImGui_ImplGlfw_GetContentScaleForMonitor() helpers return 1.0f on Emscripten and Android platforms, matching macOS logic. (#8742, #8733)
|
||||
// 2025-06-18: Added support for multiple Dear ImGui contexts. (#8676, #8239, #8069)
|
||||
// 2025-06-11: Added ImGui_ImplGlfw_GetContentScaleForWindow(GLFWwindow* window) and ImGui_ImplGlfw_GetContentScaleForMonitor(GLFWmonitor* monitor) helper to facilitate making DPI-aware apps.
|
||||
// 2025-03-10: Map GLFW_KEY_WORLD_1 and GLFW_KEY_WORLD_2 into ImGuiKey_Oem102.
|
||||
@@ -876,7 +877,7 @@ static void ImGui_ImplGlfw_UpdateGamepads()
|
||||
// - Some accessibility applications are declaring virtual monitors with a DPI of 0.0f, see #7902. We preserve this value for caller to handle.
|
||||
float ImGui_ImplGlfw_GetContentScaleForWindow(GLFWwindow* window)
|
||||
{
|
||||
#if GLFW_HAS_PER_MONITOR_DPI && !defined(__APPLE__)
|
||||
#if GLFW_HAS_PER_MONITOR_DPI && !(defined(__APPLE__) || defined(__EMSCRIPTEN__) || defined(__ANDROID__))
|
||||
float x_scale, y_scale;
|
||||
glfwGetWindowContentScale(window, &x_scale, &y_scale);
|
||||
return x_scale;
|
||||
@@ -888,7 +889,7 @@ float ImGui_ImplGlfw_GetContentScaleForWindow(GLFWwindow* window)
|
||||
|
||||
float ImGui_ImplGlfw_GetContentScaleForMonitor(GLFWmonitor* monitor)
|
||||
{
|
||||
#if GLFW_HAS_PER_MONITOR_DPI && !defined(__APPLE__)
|
||||
#if GLFW_HAS_PER_MONITOR_DPI && !(defined(__APPLE__) || defined(__EMSCRIPTEN__) || defined(__ANDROID__))
|
||||
float x_scale, y_scale;
|
||||
glfwGetMonitorContentScale(monitor, &x_scale, &y_scale);
|
||||
return x_scale;
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2025-07-08: Made ImGui_ImplSDL2_GetContentScaleForWindow(), ImGui_ImplSDL2_GetContentScaleForDisplay() helpers return 1.0f on Emscripten and Android platforms, matching macOS logic. (#8742, #8733)
|
||||
// 2025-06-11: Added ImGui_ImplSDL2_GetContentScaleForWindow(SDL_Window* window) and ImGui_ImplSDL2_GetContentScaleForDisplay(int display_index) helper to facilitate making DPI-aware apps.
|
||||
// 2025-04-09: Don't attempt to call SDL_CaptureMouse() on drivers where we don't call SDL_GetGlobalMouseState(). (#8561)
|
||||
// 2025-03-21: Fill gamepad inputs and set ImGuiBackendFlags_HasGamepad regardless of ImGuiConfigFlags_NavEnableGamepad being set.
|
||||
@@ -719,7 +720,7 @@ float ImGui_ImplSDL2_GetContentScaleForWindow(SDL_Window* window)
|
||||
float ImGui_ImplSDL2_GetContentScaleForDisplay(int display_index)
|
||||
{
|
||||
#if SDL_HAS_PER_MONITOR_DPI
|
||||
#ifndef __APPLE__
|
||||
#if !defined(__APPLE__) && !defined(__EMSCRIPTEN__) && !defined(__ANDROID__)
|
||||
float dpi = 0.0f;
|
||||
if (SDL_GetDisplayDPI(display_index, &dpi, nullptr, nullptr) == 0)
|
||||
return dpi / 96.0f;
|
||||
|
||||
@@ -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]
|
||||
|
||||
2
imgui.h
2
imgui.h
@@ -29,7 +29,7 @@
|
||||
// Library Version
|
||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
|
||||
#define IMGUI_VERSION "1.92.1 WIP"
|
||||
#define IMGUI_VERSION_NUM 19201
|
||||
#define IMGUI_VERSION_NUM 19202
|
||||
#define IMGUI_HAS_TABLE // Added BeginTable() - from IMGUI_VERSION_NUM >= 18000
|
||||
#define IMGUI_HAS_TEXTURES // Added ImGuiBackendFlags_RendererHasTextures - from IMGUI_VERSION_NUM >= 19198
|
||||
|
||||
|
||||
Reference in New Issue
Block a user