{-# OPTIONS_HADDOCK hide #-}
module Graphics.Gloss.Internals.Interface.Window
( createWindow )
where
import Graphics.Gloss.Data.Color
import Graphics.Gloss.Internals.Color
import Graphics.Gloss.Internals.Interface.Backend
import Graphics.Gloss.Internals.Interface.Debug
import Graphics.Rendering.OpenGL (($=))
import qualified Graphics.Rendering.OpenGL.GL as GL
import Data.IORef (IORef, newIORef)
import Control.Monad
createWindow
:: Backend a
=> a
-> Display
-> Color
-> [Callback]
-> (IORef a -> IO ())
-> IO ()
createWindow
backend
display
clearColor
callbacks
eatBackend
= do
let debug = False
backendStateRef <- newIORef backend
when debug
$ do putStr $ "* displayInWindow\n"
initializeBackend backendStateRef debug
when debug
$ do putStr $ "* c window\n\n"
openWindow backendStateRef display
installDisplayCallback backendStateRef callbacks
installWindowCloseCallback backendStateRef
installReshapeCallback backendStateRef callbacks
installKeyMouseCallback backendStateRef callbacks
installMotionCallback backendStateRef callbacks
installIdleCallback backendStateRef callbacks
GL.depthFunc $= Just GL.Always
GL.clearColor $= glColor4OfColor clearColor
when debug
$ do dumpBackendState backendStateRef
dumpFramebufferState
dumpFragmentState
eatBackend backendStateRef
when debug
$ do putStr $ "* entering mainloop..\n"
runMainLoop backendStateRef
when debug
$ putStr $ "* all done\n"