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 (newIORef)
import Control.Monad
createWindow
:: Backend a
=> a
-> String
-> (Int, Int)
-> (Int, Int)
-> Color
-> [Callback]
-> IO ()
createWindow
backend
windowName
(sizeX, sizeY)
(posX, posY)
clearColor
callbacks
= do
let debug = False
backendStateRef <- newIORef backend
when debug
$ do putStr $ "* displayInWindow\n"
initializeBackend backendStateRef debug
when debug
$ do putStr $ "* creating window\n\n"
openWindow backendStateRef windowName (sizeX, sizeY) (posX, posY)
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
when debug
$ do putStr $ "* entering mainloop..\n"
runMainLoop backendStateRef
when debug
$ putStr $ "* all done\n"
return ()