From 1e0b55e7f56bcaf8cd0e2a2fd946b711d3b1bb62 Mon Sep 17 00:00:00 2001 From: havoc Date: Sun, 12 Jul 2009 22:25:26 +0000 Subject: [PATCH] stabilize showfps a bit git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9055 d7cf8633-e32d-0410-b094-e92efae38249 --- sbar.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sbar.c b/sbar.c index 5db9491f..6dc02b98 100644 --- a/sbar.c +++ b/sbar.c @@ -1110,12 +1110,15 @@ void Sbar_ShowFPS(void) static double nexttime = 0, lasttime = 0; static double framerate = 0; static int framecount = 0; - double interval = 0.25; + double interval = 1; double newtime; - newtime = realtime; + newtime = Sys_DoubleTime(); if (newtime >= nexttime) { - framerate = framecount / (newtime - lasttime); + if (framecount > 1) // frames per second + framerate = framecount / interval; + else // seconds per frame + framerate = framecount / (newtime - lasttime); if (nexttime < newtime - interval * 1.5) nexttime = newtime; lasttime = newtime; @@ -1126,7 +1129,7 @@ void Sbar_ShowFPS(void) calc = framerate; if ((red = (calc < 1.0f))) - dpsnprintf(fpsstring, sizeof(fpsstring), "%4i spf", (int)(1.0f / calc + 0.5)); + dpsnprintf(fpsstring, sizeof(fpsstring), "%4i spf", (int)(1.0 / calc + 0.5)); else dpsnprintf(fpsstring, sizeof(fpsstring), "%4i fps", (int)(calc + 0.5)); } -- 2.39.2