Closed ewichuu closed 1 week ago
Check if it happens with the unmodified vanilla example for dx11. It that works, you can compare your app with that code.
Then, I scale it up to 1920x1080 (proper d3d11 scaling with ResizeBuffers),
To debug an issue it is better to not made statements alluding that xx or xx has been done correctly, because it may shield you from seeing the error.
Printing io.MousePos and ImGui::GetCursorPos(), both say the same thing and seem to be totally correct
It’s not correct if it doesn’t line up with your OS mouse cursor.
Setting io.DisplaySize when resizing the window, doesn't seem to have any effect
You should never set this value yourself as the backend does it.
Setting io.MouseDrawCursor to true for debugging which, for some reason, completely fixes this issue.
Your issue is that there is a mismatch between OS mouse positions and positions renderer at the end of your pipeline. It could be down to wrong scaling of your framebuffer or many other possible causes. When you enable io.MouseDrawCursor it doesn’t fix the issue, but because imgui renders the cursor itself, its position in your window will match the coordinates of other imgui rendered items. But it’s not matching actually mouse OS coordinates so you’ll have a jump/gap when moving the mouse accross the edges of your window.
I'm really not sure what code to show for this,
The purpose of the “Minimal, Complete and Verifiable Example” is that put the work of narrowing down the issue to the code that causes it. If you disable/comment unrelated code and keep a minimum of code that exhibits the issues it is easier to study and share. Many times you’ll solve your problem.
Thanks a lot for the fast reply. I did what you said disabling and commenting all parts of the code to narrow down the issue, and like I suspected, it's not an ImGui issue at all. I also was scaling the buffers correctly - the problem was the swapchain.
Not sure why, but having the swapchain scaling mode to DXGI_SCALING_STRETCH
caused this issue. Changing it to DXGI_SCALING_NONE
completely fixed it, and this time properly. Thank you!
Version/Branch of Dear ImGui:
Version 1.91.1, Branch: docking
Back-ends:
imgui_impl_win32.cpp + imgui_impl_dx11.cpp
Compiler, OS:
Windows 11 + MSVC
Full config/build information:
Details:
Hello, I'm pretty sure this is not an issue on ImGui's part and I'm doing something wrong, but I can't find anyone else with the same issue, so I'd really appreciate some pointers.
My GUI looks and controls great at my app's start resolution of 1280x720, as you can see in the video. Then, I scale it up to 1920x1080 (proper d3d11 scaling with ResizeBuffers), and you can see how the buttons and menus highlight as if the cursor was hovering over them... a few pixels below where they should. Then, I go borderless fullscreen, which should still be 1920x1080, but it gets even worse and outright unusable.
As you can see, scaling to 1920x1080 makes the UI get blurry too, which is weird because I assume it shouldn't scale with the window unless I manually tell it to?
Notably this... cursor position offset for lack of a better term does not seem to be present horizontally, even at fullscreen (as in it doesn't highlight more pixels to the left/right than it should like it does vertically)
Some things I've tried:
io.MousePos
andImGui::GetCursorPos()
, both say the same thing and seem to be totally correct (0, 0 on top left corner, 1919, 1079 on bottom right corner)io.DisplaySize
when resizing the window, doesn't seem to have any effectio.MouseDrawCursor
totrue
for debugging which, for some reason, completely fixes this issue.I'm not exactly sure what
io.MouseDrawCursor
does that can somehow solve this? I'm happy with keeping it totrue
but it really doesn't feel like that's what should fix this issue.Screenshots/Video:
https://github.com/user-attachments/assets/cb968cc4-06cd-4e5f-95ea-b4b34f155902
Minimal, Complete and Verifiable Example code:
I'm really not sure what code to show for this, it's just the demo window. If you need something specific tell me and I'll show it, sorry!