affection/src/Affection.hs

37 lines
851 B
Haskell
Raw Normal View History

2016-03-25 08:41:22 +00:00
module Affection
2016-03-25 10:43:31 +00:00
( withAllAffection
, withWindow
, withDefaultWindow
, delaySec
2016-03-26 02:50:39 +00:00
, module Affection.Render
, module Affection.Types
2016-03-25 08:41:22 +00:00
) where
2016-03-25 10:43:31 +00:00
import SDL
import Data.Text
2016-04-26 20:33:35 +00:00
import GEGL
2016-03-25 10:43:31 +00:00
2016-03-25 15:58:46 +00:00
import Affection.Render
import Affection.Types
2016-03-25 10:43:31 +00:00
withAllAffection :: IO () -> IO ()
withAllAffection ops = do
initializeAll
ops
quit
2016-03-26 02:50:39 +00:00
withWindow :: Monad m => Text -> WindowConfig -> RendererConfig -> RenderT m a -> IO ()
2016-03-25 15:58:46 +00:00
withWindow title wconf rconf ops = do
window <- createWindow title wconf
renderer <- createRenderer window (-1) rconf
2016-04-26 20:33:35 +00:00
gegl_init
2016-03-25 15:58:46 +00:00
inRender renderer $ ops
2016-04-26 20:33:35 +00:00
gegl_exit
2016-03-25 10:43:31 +00:00
destroyWindow window
2016-03-26 02:50:39 +00:00
withDefaultWindow :: Monad m => Text -> (RenderT m a) -> IO ()
2016-03-25 15:58:46 +00:00
withDefaultWindow title ops = withWindow title defaultWindow defaultRenderer ops
2016-03-25 10:43:31 +00:00
delaySec :: Int -> IO ()
delaySec dur = delay (fromIntegral $ dur * 1000)