From 685dcd76c144e9d8e29bbadc02532e3227e08c7b Mon Sep 17 00:00:00 2001 From: maksut Date: Fri, 13 Oct 2023 21:45:40 +0100 Subject: [PATCH] Fix GetFPS so it doesn't hold on last time from previous window --- src/rcore.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/rcore.c b/src/rcore.c index 3efa67b2c..dfc797925 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -1235,9 +1235,14 @@ int GetFPS(void) if (fpsFrame == 0) return 0; - if ((GetTime() - last) > FPS_STEP) + float newTime = (float)GetTime(); + + if (last > newTime) + last = newTime; // Last value is from a previous window so reset it + + if ((newTime - last) > FPS_STEP) { - last = (float)GetTime(); + last = newTime; index = (index + 1)%FPS_CAPTURE_FRAMES_COUNT; average -= history[index]; history[index] = fpsFrame/FPS_CAPTURE_FRAMES_COUNT;