Tweaked FPS implementation
This commit is contained in:
@@ -28,16 +28,21 @@ public:
|
|||||||
typedef std::chrono::high_resolution_clock Clock;
|
typedef std::chrono::high_resolution_clock Clock;
|
||||||
|
|
||||||
FrameRate() = default;
|
FrameRate() = default;
|
||||||
|
|
||||||
|
//DOCS: for usage purposes, this returns -1 unless a new framerate value is set
|
||||||
int Calculate() {
|
int Calculate() {
|
||||||
frameCount++;
|
frameCount++;
|
||||||
if (Clock::now() - tick >= std::chrono::duration<int>(1)) {
|
if (Clock::now() - tick >= std::chrono::duration<int>(1)) {
|
||||||
lastFrameRate = frameCount;
|
lastFrameRate = frameCount;
|
||||||
frameCount = 0;
|
frameCount = 0;
|
||||||
tick = Clock::now();
|
tick = Clock::now();
|
||||||
|
return lastFrameRate;
|
||||||
}
|
}
|
||||||
return lastFrameRate;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetFrameRate() { return lastFrameRate; }
|
int GetFrameRate() { return lastFrameRate; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int frameCount = 0;
|
int frameCount = 0;
|
||||||
int lastFrameRate = 0;
|
int lastFrameRate = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user