Fix highdpi screens on SDL examples with viewports #2306
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
(Dup of #2284, done over the
docking
branch now, as requested by @ocornut)imgui_impl_opengl3.cpp
andimgui_impl_opengl2.cpp
currently have a bug in thedocking
branch when used with a HighDPI configuration. I discovered this bug while testing ImGui in an application that turns on HighDPI (not to improve rendering of imgui itself, but rather the application itself over which ImGui is drawn).To reproduce this bug, you can use any OpenGL-based example. I personally use SDL so it's possible to trigger this by modifying
example_sdl_opengl3/main.cpp
to addSDL_WINDOW_ALLOWHIGHDPI
when callingSDL_CreateWindow()
. After having added this flag, running the example immediately produces a broken output like this:The bug is in
ImGui_ImplOpenGL3_RenderDrawData
: thedraw_data->DisplayPos
variable is not scaled by the current framebuffer scale.This PR fixes this bug for both OpenGL2 and OpenGL3 implementation. Moreover, it activates HighDPI rendering on SDL examples. This is not strictly required to fix any bug, but I think it's a good idea to keep it active because it increases the amount of code being tested by running the examples, and is thus easier to uncover hidden bugs with highdpi scaling.