screens.cpp: Fixed a bug in FPS calculation

git-svn-id: https://svn.eduke32.com/eduke32@6660 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
pogokeen 2018-02-16 06:38:40 +00:00
parent 8ebb8083a5
commit 512b396c54

View file

@ -782,11 +782,12 @@ static void G_ShowCacheLocks(void)
static void G_PrintFPS(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; static int32_t minFPS = -1, maxFPS = 0;
int32_t frameTime = getticks(); int32_t frameTime = getticks();
int32_t frameDelay = frameTime - lastFrameTime; int32_t frameDelay = frameTime - lastFrameTime;
cumulativeFrameDelay += frameDelay;
if (frameDelay >= 0) if (frameDelay >= 0)
{ {
@ -826,13 +827,11 @@ static void G_PrintFPS(void)
} }
} }
int32_t const thisSec = tabledivide32_noinline(frameTime, 1000); if (cumulativeFrameDelay >= 1000)
int32_t const lastSec = tabledivide32_noinline(lastFrameTime, 1000);
if (thisSec - lastSec)
{ {
g_frameRate = lastFPS = tabledivide32_noinline(frameCount, thisSec - lastSec); g_frameRate = lastFPS = tabledivide32_noinline(1000*frameCount, cumulativeFrameDelay);
frameCount = 0; frameCount = 0;
cumulativeFrameDelay = 0;
if (ud.showfps > 1) if (ud.showfps > 1)
{ {