using only system_clock

main
Benjamin Kraft 1 year ago
parent 51a9ab9a60
commit ec43d86155
  1. 4
      src/FPS.cpp
  2. 4
      src/Simulation.cpp

@ -2,7 +2,7 @@
#include <QTimer> #include <QTimer>
FPS::FPS() { FPS::FPS() {
previousFrame = high_resolution_clock::now(); previousFrame = system_clock::now();
timeSinceUpdate = nanoseconds(0); timeSinceUpdate = nanoseconds(0);
framesSinceUpdate = 0; framesSinceUpdate = 0;
current = 0; current = 0;
@ -15,7 +15,7 @@ FPS::FPS() {
void FPS::newFrame() { void FPS::newFrame() {
framesSinceUpdate++; framesSinceUpdate++;
auto thisFrame = high_resolution_clock::now(); auto thisFrame = system_clock::now();
timeSinceUpdate += thisFrame - previousFrame; timeSinceUpdate += thisFrame - previousFrame;
previousFrame = thisFrame; previousFrame = thisFrame;
} }

@ -11,7 +11,7 @@ Simulation::Simulation() {
QTimer::connect(timer, &QTimer::timeout, this, &Simulation::update); QTimer::connect(timer, &QTimer::timeout, this, &Simulation::update);
timer->setInterval(updateInterval); timer->setInterval(updateInterval);
timer->start(); timer->start();
lastUpdate = high_resolution_clock::now(); lastUpdate = system_clock::now();
}; };
void Simulation::draw(QPainter *p, int screenSize) { void Simulation::draw(QPainter *p, int screenSize) {
@ -22,7 +22,7 @@ void Simulation::draw(QPainter *p, int screenSize) {
} }
void Simulation::update() { void Simulation::update() {
auto thisUpdate = high_resolution_clock::now(); auto thisUpdate = system_clock::now();
auto ms = (int)duration_cast<milliseconds>(thisUpdate - lastUpdate).count(); auto ms = (int)duration_cast<milliseconds>(thisUpdate - lastUpdate).count();
lastUpdate = thisUpdate; lastUpdate = thisUpdate;

Loading…
Cancel
Save