From 2dd2aead13f62a3658bdddb3777a383a19949c97 Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Sun, 23 Aug 2015 01:52:03 +1000 Subject: [PATCH] Tweaked FPS implementation --- utilities/frame_rate.hpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/utilities/frame_rate.hpp b/utilities/frame_rate.hpp index 3a52c2f..31970db 100644 --- a/utilities/frame_rate.hpp +++ b/utilities/frame_rate.hpp @@ -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(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;