soulweaver91/project-carrot

Find a way to bring FPS to exactly 70

Opened this issue · 1 comments

Right now, the core timer is based on QTimer. It only supports intervals rounding to whole milliseconds, so effectively there is a new frame every 14 ms instead of the desired ~14.29 ms, resulting in an effective FPS of ~71.43.

There should be a way to bring this to exactly 70 FPS. (Ideally, game logic loop should be separated at some level from the graphics loop anyway – right now they are tied together very closely.)

Attempted some approaches:

  • Custom while loop, instead of relying on a QTimer, and sleeping with QThread::usleep with timekeeping by QElapsedTimer::nsecsElapsed(). The loop ended up going from too fast to too slow.
  • Altering the QTimer between 14 and 15 ms, again keeping time with QElapsedTimer. It managed to slightly drop the FPS to a relatively stable ~71 (14.05 ms/frame), but that still isn't good enough to claim it runs at 70 FPS.