{-# OPTIONS_HADDOCK hide #-}
--------------------------------------------------------------------------------
-- |
-- Module      :  Graphics.UI.GLUT.QueryUtils
-- Copyright   :  (c) Sven Panne 2002-2018
-- License     :  BSD3
--
-- Maintainer  :  Sven Panne <svenpanne@gmail.com>
-- Stability   :  stable
-- Portability :  portable
--
-- This is a purely internal module with utilities to query GLUT state.
--
--------------------------------------------------------------------------------

module Graphics.UI.GLUT.QueryUtils (
  Getter, simpleGet, layerGet, deviceGet
) where

import Foreign.C.Types ( CInt )
import Graphics.Rendering.OpenGL ( GLenum )

import Graphics.UI.GLUT.Raw

--------------------------------------------------------------------------------

type PrimGetter =                GLenum -> IO CInt
type Getter a   = (CInt -> a) -> GLenum -> IO a

makeGetter :: PrimGetter -> Getter a
makeGetter :: PrimGetter -> Getter a
makeGetter PrimGetter
g CInt -> a
f = (CInt -> a) -> IO CInt -> IO a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap CInt -> a
f (IO CInt -> IO a) -> PrimGetter -> GLenum -> IO a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrimGetter
g

simpleGet, layerGet, deviceGet :: Getter a
simpleGet :: Getter a
simpleGet = PrimGetter -> Getter a
forall a. PrimGetter -> Getter a
makeGetter PrimGetter
forall (m :: * -> *). MonadIO m => GLenum -> m CInt
glutGet
layerGet :: Getter a
layerGet  = PrimGetter -> Getter a
forall a. PrimGetter -> Getter a
makeGetter PrimGetter
forall (m :: * -> *). MonadIO m => GLenum -> m CInt
glutLayerGet
deviceGet :: Getter a
deviceGet = PrimGetter -> Getter a
forall a. PrimGetter -> Getter a
makeGetter PrimGetter
forall (m :: * -> *). MonadIO m => GLenum -> m CInt
glutDeviceGet