OS DPI scale not applied to UI
- Dominant language
- C++
- Stars
- 47
- Forks
- 5
- PR merge metrics
- No merged PRs in 30d
Description
Windows (and similarly also Linux) has an option to specify an OS DPI scale that apps should apply to their content such that text is readable also on high-DPI displays (see below).
gvk-pipeline-explorer seems to ignore this scale for now, which causes the UI to be almost unreadable on such high-DPI displays without either lowering the screen resolution or going very close to the monitor.
If a reference for how to achieve this with ImGui is helpful, I have previously added such code in my own graphics library sgl (see links below). The code is unfortunately not very well cleaned up.
- Windows gets told the app is DPI aware at https://github.com/chrismile/sgl/blob/master/src/Utils/AppSettings.cpp#L167 (but I assume gvk may already be doing something like that via GLFW, as otherwise the app should usually just be zommed in). Here, I use `DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2` if possible to tell it the app is able to adapt the DPI scale per monitor.
- The OS DPI scale is computed in a system-dependent way in https://github.com/chrismile/sgl/blob/master/src/Graphics/Utils/HiDPI.cpp. I have a custom code path using `GetDpiForWindow` on Windows, but `glfwGetMonitorContentScale` in GLFW might be sufficient. I have this as a fallback in the code, but so far it always uses the primary monitor (so the app in this case wouldn't be per-monitor DPI aware).
- The OS DPI scale is incorporated in font sizes and the ImGui style object in https://github.com/chrismile/sgl/blob/master/src/ImGui/ImGuiWrapper.cpp. When the DPI scale changes (e.g., because the window was moved to another monitor), the fonts are freed and reloaded (though not from disk, just from memory; I load them to disk only once).
- `glfwSetFramebufferSizeCallback` and `glfwSetWindowContentScaleCallback` are used to trigger the font reloading when the DPI scale changed.
Contributor guide
Assessment
This issue has not been assessed yet.