tamara-schmitz / CPPsoftwareRenderer

3D SoftwareRenderer written in C++11 using SDL
MIT License
0 stars 0 forks source link

Timer improvements: add wait loop #20

Open tamara-schmitz opened 7 years ago

tamara-schmitz commented 7 years ago

The timer class is quite imprecise in its method of ensuring that the framerate does not exceed the user specified maximum. A better way of doing things is to sleep less through nanosleep than required and then wait the remaining time through busy waiting (e.g. while loop until target time reached).

The current sleepoverrun may still be useful though as it could help determine how early the busy waiting loop should start. Though the algorithm could use some improvements.