diff --git a/src/FPS.cpp b/src/FPS.cpp index 0014f59..305f764 100644 --- a/src/FPS.cpp +++ b/src/FPS.cpp @@ -3,7 +3,7 @@ FPS::FPS() { previousFrame = high_resolution_clock::now(); - timeSinceUpdate = milliseconds(0); + timeSinceUpdate = nanoseconds(0); framesSinceUpdate = 0; current = 0; @@ -16,7 +16,7 @@ FPS::FPS() { void FPS::newFrame() { framesSinceUpdate++; auto thisFrame = high_resolution_clock::now(); - timeSinceUpdate += duration_cast(thisFrame - previousFrame); + timeSinceUpdate += thisFrame - previousFrame; previousFrame = thisFrame; } @@ -25,7 +25,7 @@ void FPS::setUpdateInterval(int milli) { } void FPS::updateCurrent() { - current = framesSinceUpdate * 1000 / timeSinceUpdate.count(); + current = framesSinceUpdate * 1000 * 1000 * 1000 / timeSinceUpdate.count(); framesSinceUpdate = 0; - timeSinceUpdate = milliseconds(0); + timeSinceUpdate = nanoseconds(0); } diff --git a/src/FPS.h b/src/FPS.h index 28ab80b..70a2c48 100644 --- a/src/FPS.h +++ b/src/FPS.h @@ -8,7 +8,7 @@ using namespace std::chrono; class FPS : public QObject { QTimer * timer; time_point previousFrame; - milliseconds timeSinceUpdate; + nanoseconds timeSinceUpdate; size_t framesSinceUpdate; public: FPS();