module Utilities where import qualified Graphics.UI.SDL as SDL -- | Get current ticks value. getTicks :: IO Int getTicks = do t <- SDL.getTicks return (fromIntegral (toInteger t)) -- | Wait for a specified number of ticks. waitTicks :: Int -> IO () waitTicks = SDL.delay . fromIntegral -- | Some OpenGL functions only work for images with dimensions that -- are powers of two. This utility function computes the next power -- of two. nextPowerOfTwo :: (Integral a) => a -> a nextPowerOfTwo x = 2 ^ ceiling (logBase 2 (fromIntegral x)) nextPowerOfTwoFraction :: (Integral a, Integral b, Floating c) => a -> b -> c nextPowerOfTwoFraction x y = fromIntegral x / fromIntegral (nextPowerOfTwo y)