Tweaked FPS implementation

This commit is contained in:
2015-08-23 01:52:03 +10:00
parent 03e643a17a
commit 2dd2aead13
+6 -1
View File
@@ -28,16 +28,21 @@ public:
typedef std::chrono::high_resolution_clock Clock;
FrameRate() = default;
//DOCS: for usage purposes, this returns -1 unless a new framerate value is set
int Calculate() {
frameCount++;
if (Clock::now() - tick >= std::chrono::duration<int>(1)) {
lastFrameRate = frameCount;
frameCount = 0;
tick = Clock::now();
return lastFrameRate;
}
return lastFrameRate;
return -1;
}
int GetFrameRate() { return lastFrameRate; }
private:
int frameCount = 0;
int lastFrameRate = 0;