From 512b396c540e702ad4eef0d9877191211074c643 Mon Sep 17 00:00:00 2001 From: pogokeen Date: Fri, 16 Feb 2018 06:38:40 +0000 Subject: [PATCH] screens.cpp: Fixed a bug in FPS calculation git-svn-id: https://svn.eduke32.com/eduke32@6660 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/duke3d/src/screens.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/source/duke3d/src/screens.cpp b/source/duke3d/src/screens.cpp index 46ad8599b..252edaf72 100644 --- a/source/duke3d/src/screens.cpp +++ b/source/duke3d/src/screens.cpp @@ -782,11 +782,12 @@ static void G_ShowCacheLocks(void) static void G_PrintFPS(void) { - static int32_t frameCount = 0, lastFPS = 0, lastFrameTime = 0; + static int32_t frameCount = 0, lastFPS = 0, lastFrameTime = 0, cumulativeFrameDelay = 0; static int32_t minFPS = -1, maxFPS = 0; int32_t frameTime = getticks(); int32_t frameDelay = frameTime - lastFrameTime; + cumulativeFrameDelay += frameDelay; if (frameDelay >= 0) { @@ -826,13 +827,11 @@ static void G_PrintFPS(void) } } - int32_t const thisSec = tabledivide32_noinline(frameTime, 1000); - int32_t const lastSec = tabledivide32_noinline(lastFrameTime, 1000); - - if (thisSec - lastSec) + if (cumulativeFrameDelay >= 1000) { - g_frameRate = lastFPS = tabledivide32_noinline(frameCount, thisSec - lastSec); + g_frameRate = lastFPS = tabledivide32_noinline(1000*frameCount, cumulativeFrameDelay); frameCount = 0; + cumulativeFrameDelay = 0; if (ud.showfps > 1) {