aap/librw

imgui does not accept io.DeltaTime=0

madebr opened this issue · 0 comments

After bumping to imgui 1.83.0, imguitest occasionally crashes with an assertion error:

imguitest: /home/maarten/programming/librw/skeleton/imgui/imgui.cpp:7147: void ImGui::ErrorCheckNewFrameSanityChecks(): Assertion `(g.IO.DeltaTime > 0.0f || g.FrameCount == 0) && "Need a positive DeltaTime!"' failed.

https://github.com/ocornut/imgui/blob/cc40ae2101acd1fb4e0585a46198e6fd12960617/imgui.cpp#L7195

I traced it back to io.DeltaTime being zero.

When using linux+gl3+sdl2, this value is derived from SDL_GetTicks:

librw/skeleton/sdl2.cpp

Lines 300 to 303 in b164e49

float currTime = SDL_GetTicks();
float timeDelta = (currTime - lastTime) * 0.001f;
EventHandler(IDLE, &timeDelta);

io.DeltaTime is set here:

io.DeltaTime = timeDelta;

My old machine is too fast 😄