module Graphics.Gloss.Internals.Render.Common where
import Graphics.Rendering.OpenGL (($=))
import qualified Graphics.Rendering.OpenGL.GL as GL
import Unsafe.Coerce
gf :: Float -> GL.GLfloat
gf x = unsafeCoerce x
gsizei :: Int -> GL.GLsizei
gsizei x = unsafeCoerce x
renderAction
:: (Int, Int)
-> IO ()
-> IO ()
renderAction (sizeX, sizeY) action
= do
GL.matrixMode $= GL.Projection
GL.preservingMatrix
$ do
GL.loadIdentity
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