-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unrounded font size / Avoid floating point rounding error #3309
Unrounded font size / Avoid floating point rounding error #3309
Conversation
If size_for_clamping is not an integer, the result of (window->Pos + size_for_clamping) - size_for_clamping can be (window->Pos - eps). Later Pos is floored to an integer, and this can cause an unintended -1. This bug made popup modals drift upwards on their own in some situations, including in the ImGui demo window.
Do you happen to use non-round font size? That may cause drifting windows
and is not supported.
…On June 19, 2020 02:00:32 johannes-athlos ***@***.***> wrote:
Platform: Win32, DX11
Branch: dockingI had a problem that popup modals were sometimes drifting
upwards on their own. This also happened in the "Delete?" sample modal in
the demo window.
I added a breakpoint to window->Pos and saw that inside ClampWindowRect,
Pos.y went from 472.0 -> 471.999969, and later in the code this got floored
to 471.0.
Avoiding unnecessary (a+b)-b calculation fixes the problem for me.
You can view, comment on, or merge this pull request online at:
#3309
Commit Summary
Avoid floating point rounding error
File Changes
M imgui.cpp (2)
Patch Links:
https://github.com/ocornut/imgui/pull/3309.patch
https://github.com/ocornut/imgui/pull/3309.diff
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
As a side-effect, some rounding error may be neutralized however this isn't the intent. (#3309)
Hello @johannes-athlos, Could you figure out a repro for the issue you describe (before merging my/your commit) or try to clarify what causes it? As mentioned, font size need to be rounded. |
Your commit also fixes the issue. I'm using the default font and styling, except that I had set |
Right.. I don't have a good answer to that problem presently. |
Thanks for the answer. I'll leave |
Platform: Win32, DX11
Branch: docking
I had a problem that popup modals were sometimes drifting upwards on their own, exactly 1 pixel per frame. This also happened in the "Delete?" sample modal in the demo window.
I added a breakpoint to window->Pos and saw that inside ClampWindowRect,
Pos.y
went from 472.0 -> 471.999969, and later in the code this got floored to 471.0.Avoiding unnecessary (a+b)-b calculation fixes the problem for me.