From 31249da5339c75f797bc0a095fd56bc495646c9d Mon Sep 17 00:00:00 2001 From: Quantum Date: Mon, 30 Aug 2021 06:48:41 -0400 Subject: [PATCH] [client] imgui: run animations at consistent speeds Currently, this is visible through how fast the cursor blinks, with it blinking faster at higher refresh rates. This commit makes the timing consistent. --- client/src/app.c | 4 ++++ client/src/main.h | 1 + 2 files changed, 5 insertions(+) diff --git a/client/src/app.c b/client/src/app.c index 58d9e304..037b26c1 100644 --- a/client/src/app.c +++ b/client/src/app.c @@ -811,6 +811,10 @@ int app_renderOverlay(struct Rect * rects, int maxRects) g_state.io->KeyAlt = g_state.modAlt; g_state.io->KeySuper = g_state.modSuper; + uint64_t now = nanotime(); + g_state.io->DeltaTime = (now - g_state.lastImGuiFrame) * 1e-9f; + g_state.lastImGuiFrame = now; + igNewFrame(); if (g_state.overlayInput) diff --git a/client/src/main.h b/client/src/main.h index b75c65c3..19a4132c 100644 --- a/client/src/main.h +++ b/client/src/main.h @@ -60,6 +60,7 @@ struct AppState bool modShift; bool modAlt; bool modSuper; + uint64_t lastImGuiFrame; bool alertShow; char * alertMessage;