Re: Limit framerate to exactly 60
Posted: Sun Apr 07, 2019 9:36 am
You can manually throttle thread update rate instead of using OS sleep function by spinning the CPU instead. That way you will have very precise and reliable control over the frame timing. The downside is that it stresses the CPU core to 100% at all times. The OS gives no guarantees that the program will wake up after sleep in exactly specified amount of time. It could wake up sooner than specified, or much later.Shadowblitz16 wrote: ↑Fri Mar 22, 2019 12:14 am I would like to know how to safeguard against gigantic deltas.
Instead of using love.timer.sleep you'd run an infinite loop that checks if it's time to update yet.
Code: Select all
while currentTime < targetTime do currentTime = love.timer.getTime ( ) end
targetTime = currentTime + 1/60