1
1
mirror of https://github.com/z0w0/helm.git synced 2024-08-15 15:20:25 +03:00

Merge pull request #124 from nikita-leonov/bugfix-update-limit

Fixed an incorrect computation of delay.
This commit is contained in:
Zack Corr 2017-10-16 09:28:51 +10:00 committed by GitHub
commit 916d71380f

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