Skip to content

SDL2 Backends/examples does not detect system scale factor properly #8756

Open

Description

@d235j

Version/Branch of Dear ImGui:

d99ab9f

Back-ends:

Various (see below)

Compiler, OS:

Linux (Intel i5-7200U, kernel 6.14, mesa 25.1.4)

Full config/build information:

Dear ImGui 1.92.1 WIP (19201)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=201103
define: __linux__
define: __GNUC__=13
--------------------------------
io.BackendPlatformName: imgui_impl_glfw (3310)
io.BackendRendererName: imgui_impl_vulkan
io.ConfigFlags: 0x00000003
 NavEnableKeyboard
 NavEnableGamepad
io.ConfigNavCaptureKeyboard
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x0000001E
 HasMouseCursors
 HasSetMousePos
 RendererHasVtxOffset
 RendererHasTextures
--------------------------------
io.Fonts: 1 fonts, Flags: 0x00000000, TexSize: 512,128
io.Fonts->FontLoaderName: stb_truetype
io.DisplaySize: 1280.00,720.00
io.DisplayFramebufferScale: 1.00,1.00
--------------------------------
style.WindowPadding: 8.00,8.00
style.WindowBorderSize: 1.00
style.FramePadding: 4.00,3.00
style.FrameRounding: 0.00
style.FrameBorderSize: 0.00
style.ItemSpacing: 8.00,4.00
style.ItemInnerSpacing: 4.00,4.00

Details:

The following backends keep the scale factor at 1 on my system (display settings have it set to 2):

imgui_impl_glfw.cpp+imgui_impl_vulkan.cpp: FontScaleDpi=1.000, crisp but tiny text
imgui_impl_glfw.cpp+imgui_impl_opengl2.cpp: FontScaleDpi=1.000, crisp but tiny text

The following backends set the scale factor correctly on my system:
imgui_impl_glfw.cpp+imgui_impl_opengl3.cpp: FontScaleDpi=2.000, crisp text
imgui_impl_sdl3.cpp+imgui_impl_opengl3.cpp: FontScaleDpi=2.000, crisp text
imgui_impl_sdl3.cpp+imgui_impl_sdlgpu3.cpp: FontScaleDpi=2.000, crisp text
imgui_impl_sdl3.cpp+imgui_impl_sdlrenderer3.cpp: FontScaleDpi=2.000, crisp text
imgui_impl_sdl3.cpp+imgui_impl_vulkan.cpp: FontScaleDpi=2.000, text rendering corrupted due to issue #8755

The following backends set the scale factor strangely:
imgui_impl_sdl2.cpp+imgui_impl_opengl2.cpp: FontScaleDpi=2.881, blurry text
imgui_impl_sdl2.cpp+imgui_impl_opengl3.cpp: FontScaleDpi=2.881, blurry text
imgui_impl_sdl2.cpp+imgui_impl_sdlrenderer2.cpp: FontScaleDpi=2.881, blurry text

Screenshots/Video:

As the examples were used and the issue is scale factor, this would not provide much if any insight. If screenshots are desired I can post some.

Minimal, Complete and Verifiable Example code:

Testing was done with the imgui examples.

Activity

  1. changed the title [-]Imgui does not detect system scale factor properly with certain backends[/-] [+]Backends/examples does not detect system scale factor properly[/+] on Jun 29, 2025
  2. ocornut commented on Sep 12, 2025

    @ocornut
    Owner

    Hello,
    Sorry for my late answer.

    This seems the same as #8921 but this provides some additional information so I can recoup things between them. Thanks!
    Your GLFW version is 3310 (3.3.1) so it has the glfwGetWindowContentScale(), glfwGetMonitorContentScale().

    (1) Could you clarify if this is on X11 or Wayland?

    (2)

    The following backends set the scale factor correctly on my system

    FYI out of clarify, none of the backends are ever setting style.FontScaleDpi.
    It's only ever set in the main.cpp of each example, but the GLFW+OpenGL2 and GLFW+Vulkan examples forgot to set it until now (pushed fixes now: 9f13684, cd476b2), hence the 1.0f value for those two, and value should be consistent per Platform Backend and unrelated to the Renderer backend.
    Thanks for confirming that those numbers are all based on examples btw.

    (3)
    So the only issue left is seemingly the SDL2 backend:

    imgui_impl_sdl2.cpp+imgui_impl_opengl2.cpp: FontScaleDpi=2.881, blurry text
    imgui_impl_sdl2.cpp+imgui_impl_opengl3.cpp: FontScaleDpi=2.881, blurry text
    imgui_impl_sdl2.cpp+imgui_impl_sdlrenderer2.cpp: FontScaleDpi=2.881, blurry text

    Could you confirm the following values:

    • value of float main_scale = ImGui_ImplSDL2_GetContentScaleForDisplay(0);
    • value of io.DisplayFrameBufferScale after calling ImGui_ImplSDL2_NewFrame()

    What puzzles me is that there's no specific reason for FontScaleDpi=2.881 to output blurry text. The font will big much bigger, but should not be blurry (unless maybe io.DisplayFrameBufferScale is severely wrecked).

  3. d235j commented on Sep 12, 2025

    @d235j
    Author

    It has been a while, but I most likely was running Wayland. I'll retest when I have a chance.

  4. changed the title [-]Backends/examples does not detect system scale factor properly[/-] [+]SDL2 Backends/examples does not detect system scale factor properly[/+] on Sep 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ 换网址