module Graphics.UI.GLWindow
(
LoopFunc
, init
, setFullscreen
, kill
, frame
, time
, dtime
, width
, height
, scrWidth
, scrHeight
, loop
) where
import Foreign.C
import Foreign.Ptr
import Control.Applicative
import Prelude hiding (init)
foreign import ccall unsafe "WindowInit"
c_init :: CUInt -> CUInt -> IO (CInt)
init :: Integer -> Integer -> IO (Integer)
init glMajor glMinor = fromIntegral <$> c_init (fromIntegral glMajor) (fromIntegral glMinor)
foreign import ccall unsafe "WindowKill"
kill :: IO ()
foreign import ccall unsafe "WindowSetFullscreen"
c_fullscreen :: CInt -> IO ()
setFullscreen :: Bool -> IO ()
setFullscreen f = if f then c_fullscreen 1
else c_fullscreen 0
foreign import ccall unsafe "WindowFrame"
c_frame :: IO (CUInt)
frame :: IO (Integer)
frame = fromIntegral <$> c_frame
foreign import ccall unsafe "WindowTime"
c_time :: IO (CDouble)
time :: IO (Double)
time = realToFrac <$> c_time
foreign import ccall unsafe "WindowDTime"
c_dtime :: IO (CDouble)
dtime :: IO (Double)
dtime = realToFrac <$> c_dtime
foreign import ccall unsafe "WindowWidth"
c_width :: IO (CUInt)
width :: IO (Integer)
width = fromIntegral <$> c_width
foreign import ccall unsafe "WindowHeight"
c_height :: IO (CUInt)
height :: IO (Integer)
height = fromIntegral <$> c_height
foreign import ccall unsafe "WindowScrWidth"
c_scrWidth :: IO (CUInt)
scrWidth :: IO (Integer)
scrWidth = fromIntegral <$> c_scrWidth
foreign import ccall unsafe "WindowScrHeight"
c_scrHeight :: IO (CUInt)
scrHeight :: IO (Integer)
scrHeight = fromIntegral <$> c_scrHeight
type LoopFunc = IO ()
foreign import ccall "WindowLoop"
c_loop :: FunPtr (LoopFunc) -> IO ()
loop :: LoopFunc -> IO ()
loop lf = mkLoop lf >>= c_loop
foreign import ccall "wrapper"
mkLoop :: LoopFunc -> IO( FunPtr (LoopFunc) )