1
1
mirror of https://github.com/z0w0/helm.git synced 2024-09-11 04:15:32 +03:00

Fixed an incorrect computation of delay.

This commit is contained in:
Nikita Leonov 2017-10-08 13:00:39 -07:00
parent 89c8a56238
commit 377700d5ce

View File

@ -167,9 +167,10 @@ delayIfNeeded
-> Double -- ^ Current time.
-> IO () -- ^ An IO monad that delays the main thread to ensure that frames are not rendered faster than limit allows.
delayIfNeeded Unlimited _ _ = return ()
delayIfNeeded (Limited fpsLimit) lastRender currentTime = do
if delay > 0
delayIfNeeded (Limited fpsLimit) lastRender currentTime = if delay > 0
then threadDelay delay
else putStrLn "Warning: FPS degradation. You may want to tune your update or FPS limits."
where
delay = ceiling $ 1000*(currentTime - lastRender) - (fromIntegral fpsLimit)
microsecondsLimitPerFrame = ceiling $ 1000000.0 / (fromIntegral fpsLimit)
microsecondsForLastFrame = ceiling $ currentTime - lastRender
delay = microsecondsLimitPerFrame - microsecondsForLastFrame