Parcourir la source

Make love.timer.getFPS more accurate

Hopefully this was causing issue #377, otherwise, it was still an improvement
Bart van Strien il y a 13 ans
Parent
commit
c2fb5618c1
1 fichiers modifiés avec 3 ajouts et 2 suppressions
  1. 3 2
      src/modules/timer/sdl/Timer.cpp

+ 3 - 2
src/modules/timer/sdl/Timer.cpp

@@ -70,10 +70,11 @@ namespace sdl
 		// Convert to number of seconds
 		dt = (currTime - prevTime)/1000.0;
 
+		int timeSinceLast = (currTime - prevFpsUpdate)/1000.0;
 		// Update FPS?
-		if ((currTime - prevFpsUpdate)/1000.0 > fpsUpdateFrequency)
+		if (timeSinceLast > fpsUpdateFrequency)
 		{
-			fps = frames/fpsUpdateFrequency;
+			fps = frames/timeSinceLast;
 			prevFpsUpdate = currTime;
 			frames = 0;
 		}