79601936

Date: 2025-05-01 13:35:43
Score: 1
Natty:
Report link

A nicer way of doing this is by using the std::chrono library.

// Needed for `1s` syntax
using namespace std::chrono_literals;

// Your code
auto const old = last;
last = steady_clock::now();
const duration<float> frameTime = last - old;

// Use `frameTime` as your delta time
auto fps = 1s / frameTime;
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Gabor Galgoczy