Imported update to FrameRate
This commit is contained in:
+11
-13
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user