From e7dc17a7e32f4a0ef3a66cffaf1d41c485d1245c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 22 Mar 2020 10:22:03 +0100 Subject: [PATCH] ImGuiIntegration: avoid assertions with zero delta time. Since v1.68, ImGui disallows zero delta time to "prevent subtle issues", but due to a four-year-old bug in SDL2, this *does* cause subtle issues. Co-authored-by: Andrew Huang --- src/Magnum/ImGuiIntegration/Context.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Magnum/ImGuiIntegration/Context.cpp b/src/Magnum/ImGuiIntegration/Context.cpp index c58e358e0..113baa407 100644 --- a/src/Magnum/ImGuiIntegration/Context.cpp +++ b/src/Magnum/ImGuiIntegration/Context.cpp @@ -272,6 +272,17 @@ void Context::newFrame() { ImGuiIO& io = ImGui::GetIO(); io.DeltaTime = _timeline.previousFrameDuration(); + /* Since v1.68 and https://github.com/ocornut/imgui/commit/3c07ec6a6126fb6b98523a9685d1f0f78ca3c40c, + ImGui disallows zero delta time to "prevent subtle issues". + Unfortunately that *does* cause subtle issues, especially in combination + with SDL2 on Windows -- when the window is being dragged across the + screen, SDL temporarily halts all event processing and then fires all + pending events at once, causing zero delta time. A bugreport for this + is opened since 2016 -- https://bugzilla.libsdl.org/show_bug.cgi?id=2077 + but there was nothing done last time I checked (March 2020). More info + also at https://github.com/mosra/magnum-integration/issues/57 */ + if(ImGui::GetFrameCount() != 0) + io.DeltaTime = Math::max(io.DeltaTime, std::numeric_limits::epsilon()); /* Fire delayed mouse events. This sets MouseDown both in case the press happened in this frame but also if both press and release happened at