module Graphics.Gloss.Internals.Render.Common where
import Graphics.Gloss.Internals.Interface.Backend
import Graphics.Rendering.OpenGL (($=))
import qualified Graphics.Rendering.OpenGL.GL as GL
import Unsafe.Coerce
import Data.IORef
gf :: Float -> GL.GLfloat
gf x = unsafeCoerce x
gsizei :: Int -> GL.GLsizei
gsizei x = unsafeCoerce x
renderAction
:: Backend a
=> IORef a
-> IO ()
-> IO ()
renderAction backendRef action
= do
GL.matrixMode $= GL.Projection
GL.preservingMatrix
$ do
GL.loadIdentity
(sizeX, sizeY) <- getWindowDimensions backendRef
let (sx, sy) = (fromIntegral sizeX / 2, fromIntegral sizeY / 2)
GL.ortho (sx) sx (sy) sy 0 (100)
GL.matrixMode $= GL.Modelview 0
action
GL.matrixMode $= GL.Projection
GL.matrixMode $= GL.Modelview 0