Imported update to FrameRate

This commit is contained in:
Kayne Ruse
2013-06-04 21:11:21 +10:00
parent a8b798ddff
commit a260f29d4f
4 changed files with 39 additions and 17 deletions
+11 -13
View File
@@ -22,29 +22,27 @@
#ifndef FRAMERATE_HPP_
#define FRAMERATE_HPP_
#include <ctime>
#include <chrono>
class FrameRate {
public:
FrameRate() {
frameCount = lastFrameRate = tick = 0;
}
int Calculate() {
typedef std::chrono::high_resolution_clock Clock;
FrameRate() = delete;
static int Calculate() {
frameCount++;
if (clock() - tick >= CLOCKS_PER_SEC) {
if (Clock::now() - tick >= std::chrono::duration<int>(1)) {
lastFrameRate = frameCount;
frameCount = 0;
tick = clock();
tick = Clock::now();
}
return lastFrameRate;
}
int GetFrameRate() const {
return lastFrameRate;
}
static int GetFrameRate() { return lastFrameRate; }
private:
int frameCount;
int lastFrameRate;
int tick;
static int frameCount;
static int lastFrameRate;
static Clock::time_point tick;
};
#endif