Open sjmeagher opened 1 year ago
I have experienced this same issue this week as well, I just assumed it was a known limitation. If that fix works then that would be very useful to include.
Ok. I'll make a PR in the next couple of days.
Hello, thanks for opening the issue. No need for a PR if it is the same change. I'll need to investigate this. The problem is that there are many different ways to handle scaling/DPI/multi-DPI and many of those scaling-relating changes are pushing toward one way and preventing others from being used. This is why there are so many variations of "scaling fix" in issues and pr at the moment, in particularly for Mac. I'll need to sit down with a Mac for a longer while and tackle a shared design for that.
Thanks for update. Yes PR would have been patch in original post, so I won't submit a PR.
(Maybe not the right place, but thanks for making and maintaining this awesome piece of software).
I am not sure I understand this.
Adding SDL_RenderSetScale(renderer, io.DisplayFramebufferScale.x, io.DisplayFramebufferScale.y);
in the main loop of our demo app, e.g. right before SDL_SetRenderDrawColor(...)
, seems to be one way of FIXING #5931 / #6121 for me, and then inputs are matching display.
With this setup io.DisplaySize is the "half resolution" version (1 point = 1 imgui unit = 2 pixels).
Which is not the ideal setup but it does work.
AFAIK in hi-dpi mode if we don't call SDL_RenderSetScale(renderer, 2, 2)
then we get the result of #5931 / #6121.
Your message however suggest the exact opposite thing.
(This is in reference to commit 2efebe33)
That placement of
SDL_RenderSetScale(renderer, io.DisplayFramebufferScale.x, io.DisplayFramebufferScale.y);
visually undoes the
SDL_RenderSetScale(renderer, 2.0f, 2.0f);
at line 43 of the example I gave.
The effect is that the renderer is not visually scaled.
E.g. here it is without SDL_RenderSetScale(renderer, io.DisplayFramebufferScale.x, io.DisplayFramebufferScale.y);
(i.e comment out line 146 of demo app).
and here it is with (i.e. keep line 146 of demo app).
Version/Branch of Dear ImGui:
Version: 1.89.2 Branch: master, commit d7c8516
Back-end/Renderer/Compiler/OS
Back-ends: imgui_impl_sdl.cpp + imgui_impl_sdl_sdlrenderer.cpp Compiler: Apple clang version 12.0.0 (clang-1200.0.32.29) Operating System: macOS 10.15.7
My Issue/Question:
If
SDL_RenderSetScale
sets scale to anything other than 1, this ruins mouse coordinates.Standalone, minimal, complete and verifiable example: insert
SDL_RenderSetScale(renderer, 2.0f, 2.0f);
after line 43 ofexample_sdl_sdlrenderer/main.cpp
.Partial solution
Following patch to imgui_impl_sdl.cpp restores correct mouse coordinates for purposes of clicking a button, but leaves window repositioning wrong.
UPDATE : Complete fix?
Following patch addresses both window movement and button clicking