Implemented a simpler frame rate system

This commit is contained in:
Kayne Ruse
2013-06-23 15:05:52 +10:00
parent 3232925ccd
commit 7ad855348f
4 changed files with 31 additions and 27 deletions
+21 -3
View File
@@ -21,6 +21,24 @@
*/
#include "frame_rate.hpp"
int FrameRate::frameCount = 0;
int FrameRate::lastFrameRate = 0;
FrameRate::Clock::time_point FrameRate::tick = FrameRate::Clock::now();
#include <chrono>
typedef std::chrono::high_resolution_clock Clock;
static int frameCount = 0;
static int lastFrameRate = 0;
static Clock::time_point tick = Clock::now();
int ClockFrameRate() {
frameCount++;
if (Clock::now() - tick >= std::chrono::duration<int>(1)) {
lastFrameRate = frameCount;
frameCount = 0;
tick = Clock::now();
}
return lastFrameRate;
}
int GetFrameRate() {
return lastFrameRate;
}