From 28a01aaab7f672e07ee95eb3c27096b489669be0 Mon Sep 17 00:00:00 2001 From: maksut Date: Sat, 14 Oct 2023 15:44:42 +0100 Subject: [PATCH] do not rely on GetTime --- src/rcore.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/rcore.c b/src/rcore.c index dfc797925..e4c852843 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -1230,19 +1230,16 @@ int GetFPS(void) static int index = 0; static float history[FPS_CAPTURE_FRAMES_COUNT] = { 0 }; - static float average = 0, last = 0; + static float average = 0, wait = 0; float fpsFrame = GetFrameTime(); if (fpsFrame == 0) return 0; - float newTime = (float)GetTime(); + wait += fpsFrame; - if (last > newTime) - last = newTime; // Last value is from a previous window so reset it - - if ((newTime - last) > FPS_STEP) + if (wait > FPS_STEP) { - last = newTime; + wait = 0; index = (index + 1)%FPS_CAPTURE_FRAMES_COUNT; average -= history[index]; history[index] = fpsFrame/FPS_CAPTURE_FRAMES_COUNT;