module Irg.Lab1.GL.Utility (
  GameState(..),
  MouseClicks,
  ReshapeCallback,
  DisplayCallback,
  KeyboardCallback,
  MouseCallback,
  getWindowSize
) where

--import qualified Graphics.GL.Compatibility33 as GL
import qualified Graphics.UI.GLUT as GLUT
import Data.IORef
import Irg.Lab1.Geometry.Shapes

getWindowSize :: Num a => IO (a, a)
getWindowSize = do
  GLUT.Size width height <- GLUT.get GLUT.windowSize
  return (fromIntegral width,fromIntegral height)

data GameState = GameState {
  drawOrObj :: String,
  mouseClicks :: MouseClicks,
  drawnPolys :: [Polygon],
  leftestPix :: GLUT.GLdouble,
  rightestPix :: GLUT.GLdouble,
  upestPix :: GLUT.GLdouble,
  downestPix :: GLUT.GLdouble
} deriving (Eq)

type MouseClicks = IORef [(GLUT.GLfloat, GLUT.GLfloat)]
type ReshapeCallback = GameState -> GLUT.Size -> IO ()
type DisplayCallback = GameState -> IO ()
type KeyboardCallback = GameState -> Char -> GLUT.Position -> IO ()
type MouseCallback = GameState -> GLUT.MouseButton -> GLUT.KeyState -> GLUT.Position -> IO ()
