    --------------------------------------------------------------------------------
    -- |
    -- Module      :  Graphics.Rendering.OpenGL.GL.Colors
    -- Copyright   :  (c) Sven Panne 2002-2019
    -- License     :  BSD3
    --
    -- Maintainer  :  Sven Panne <svenpanne@gmail.com>
    -- Stability   :  stable
    -- Portability :  portable
    --
    -- This module corresponds to section 2.14 (Colors and Coloring) of the
    -- OpenGL 2.1 specs.
    --
    --------------------------------------------------------------------------------

    module Graphics.Rendering.OpenGL.GL.Colors (
       -- * Lighting
       lighting, Light(..), light, maxLights,
       FrontFaceDirection(..), frontFace,

       -- * Lighting Parameter Specification
       Face(..),
       materialAmbient, materialDiffuse, materialAmbientAndDiffuse,
       materialSpecular, materialEmission, materialShininess, maxShininess,
       materialColorIndexes,

       ambient, diffuse, specular,
       position, spotDirection, spotExponent, maxSpotExponent, spotCutoff,
       attenuation,

       lightModelAmbient, lightModelLocalViewer, lightModelTwoSide,
       vertexProgramTwoSide,
       LightModelColorControl(..), lightModelColorControl,

       -- * ColorMaterial
       ColorMaterialParameter(..), colorMaterial,

       -- * Flatshading
       ShadingModel(..), shadeModel,

       -- * Color clamping
       ClampTarget(..), ClampMode(..),
       clampColor,
    ) where

    import Control.Monad
    import Data.StateVar
    import Foreign.Marshal.Alloc
    import Foreign.Marshal.Array
    import Foreign.Marshal.Utils
    import Foreign.Ptr
    import Foreign.Storable
    import Graphics.Rendering.OpenGL.GL.Tensor
    import Graphics.Rendering.OpenGL.GL.Capability
    import Graphics.Rendering.OpenGL.GL.Face
    import Graphics.Rendering.OpenGL.GL.PeekPoke
    import Graphics.Rendering.OpenGL.GL.QueryUtils
    import Graphics.Rendering.OpenGL.GL.VertexSpec
    import Graphics.Rendering.OpenGL.GLU.ErrorsInternal
    import Graphics.GL

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

    lighting :: StateVar Capability
    lighting :: StateVar Capability
    lighting = EnableCap -> StateVar Capability
    makeCapability EnableCap
    CapLighting

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

    newtype Light = Light GLsizei
       deriving ( Light -> Light -> Bool
    (Light -> Light -> Bool) -> (Light -> Light -> Bool) -> Eq Light
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Light -> Light -> Bool
    == :: Light -> Light -> Bool
    $c/= :: Light -> Light -> Bool
    /= :: Light -> Light -> Bool
    Eq, Eq Light
    Eq Light =>
    (Light -> Light -> Ordering)
    -> (Light -> Light -> Bool)
    -> (Light -> Light -> Bool)
    -> (Light -> Light -> Bool)
    -> (Light -> Light -> Bool)
    -> (Light -> Light -> Light)
    -> (Light -> Light -> Light)
    -> Ord Light
    Light -> Light -> Bool
    Light -> Light -> Ordering
    Light -> Light -> Light
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: Light -> Light -> Ordering
    compare :: Light -> Light -> Ordering
    $c< :: Light -> Light -> Bool
    < :: Light -> Light -> Bool
    $c<= :: Light -> Light -> Bool
    <= :: Light -> Light -> Bool
    $c> :: Light -> Light -> Bool
    > :: Light -> Light -> Bool
    $c>= :: Light -> Light -> Bool
    >= :: Light -> Light -> Bool
    $cmax :: Light -> Light -> Light
    max :: Light -> Light -> Light
    $cmin :: Light -> Light -> Light
    min :: Light -> Light -> Light
    Ord, Int -> Light -> ShowS
    [Light] -> ShowS
    Light -> String
    (Int -> Light -> ShowS)
    -> (Light -> String) -> ([Light] -> ShowS) -> Show Light
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Light -> ShowS
    showsPrec :: Int -> Light -> ShowS
    $cshow :: Light -> String
    show :: Light -> String
    $cshowList :: [Light] -> ShowS
    showList :: [Light] -> ShowS
    Show )

    marshalLight :: Light -> Maybe GLenum
    marshalLight :: Light -> Maybe GLenum
    marshalLight (Light GLint
    l) = GLint -> Maybe GLenum
    lightIndexToEnum GLint
    l

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

    light :: Light -> StateVar Capability
    light :: Light -> StateVar Capability
    light (Light GLint
    l) = EnableCap -> StateVar Capability
    makeCapability (GLint -> EnableCap
    CapLight GLint
    l)

    maxLights :: GettableStateVar GLsizei
    maxLights :: GettableStateVar GLint
    maxLights = GettableStateVar GLint -> GettableStateVar GLint
    forall a. IO a -> IO a
    makeGettableStateVar ((GLint -> GLint) -> PName1I -> GettableStateVar GLint
    forall p a. GetPName1I p => (GLint -> a) -> p -> IO a
    forall a. (GLint -> a) -> PName1I -> IO a
    getSizei1 GLint -> GLint
    forall a. a -> a
    id PName1I
    GetMaxLights)

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

    data FrontFaceDirection =
         CW
       | CCW
       deriving ( FrontFaceDirection -> FrontFaceDirection -> Bool
    (FrontFaceDirection -> FrontFaceDirection -> Bool)
    -> (FrontFaceDirection -> FrontFaceDirection -> Bool)
    -> Eq FrontFaceDirection
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: FrontFaceDirection -> FrontFaceDirection -> Bool
    == :: FrontFaceDirection -> FrontFaceDirection -> Bool
    $c/= :: FrontFaceDirection -> FrontFaceDirection -> Bool
    /= :: FrontFaceDirection -> FrontFaceDirection -> Bool
    Eq, Eq FrontFaceDirection
    Eq FrontFaceDirection =>
    (FrontFaceDirection -> FrontFaceDirection -> Ordering)
    -> (FrontFaceDirection -> FrontFaceDirection -> Bool)
    -> (FrontFaceDirection -> FrontFaceDirection -> Bool)
    -> (FrontFaceDirection -> FrontFaceDirection -> Bool)
    -> (FrontFaceDirection -> FrontFaceDirection -> Bool)
    -> (FrontFaceDirection -> FrontFaceDirection -> FrontFaceDirection)
    -> (FrontFaceDirection -> FrontFaceDirection -> FrontFaceDirection)
    -> Ord FrontFaceDirection
    FrontFaceDirection -> FrontFaceDirection -> Bool
    FrontFaceDirection -> FrontFaceDirection -> Ordering
    FrontFaceDirection -> FrontFaceDirection -> FrontFaceDirection
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: FrontFaceDirection -> FrontFaceDirection -> Ordering
    compare :: FrontFaceDirection -> FrontFaceDirection -> Ordering
    $c< :: FrontFaceDirection -> FrontFaceDirection -> Bool
    < :: FrontFaceDirection -> FrontFaceDirection -> Bool
    $c<= :: FrontFaceDirection -> FrontFaceDirection -> Bool
    <= :: FrontFaceDirection -> FrontFaceDirection -> Bool
    $c> :: FrontFaceDirection -> FrontFaceDirection -> Bool
    > :: FrontFaceDirection -> FrontFaceDirection -> Bool
    $c>= :: FrontFaceDirection -> FrontFaceDirection -> Bool
    >= :: FrontFaceDirection -> FrontFaceDirection -> Bool
    $cmax :: FrontFaceDirection -> FrontFaceDirection -> FrontFaceDirection
    max :: FrontFaceDirection -> FrontFaceDirection -> FrontFaceDirection
    $cmin :: FrontFaceDirection -> FrontFaceDirection -> FrontFaceDirection
    min :: FrontFaceDirection -> FrontFaceDirection -> FrontFaceDirection
    Ord, Int -> FrontFaceDirection -> ShowS
    [FrontFaceDirection] -> ShowS
    FrontFaceDirection -> String
    (Int -> FrontFaceDirection -> ShowS)
    -> (FrontFaceDirection -> String)
    -> ([FrontFaceDirection] -> ShowS)
    -> Show FrontFaceDirection
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> FrontFaceDirection -> ShowS
    showsPrec :: Int -> FrontFaceDirection -> ShowS
    $cshow :: FrontFaceDirection -> String
    show :: FrontFaceDirection -> String
    $cshowList :: [FrontFaceDirection] -> ShowS
    showList :: [FrontFaceDirection] -> ShowS
    Show )

    marshalFrontFaceDirection :: FrontFaceDirection -> GLenum
    marshalFrontFaceDirection :: FrontFaceDirection -> GLenum
    marshalFrontFaceDirection FrontFaceDirection
    x = case FrontFaceDirection
    x of
       FrontFaceDirection
    CW -> GLenum
    GL_CW
       FrontFaceDirection
    CCW -> GLenum
    GL_CCW

    unmarshalFrontFaceDirection :: GLenum -> FrontFaceDirection
    unmarshalFrontFaceDirection :: GLenum -> FrontFaceDirection
    unmarshalFrontFaceDirection GLenum
    x
       | GLenum
    x GLenum -> GLenum -> Bool
    forall a. Eq a => a -> a -> Bool
    == GLenum
    GL_CW = FrontFaceDirection
    CW
       | GLenum
    x GLenum -> GLenum -> Bool
    forall a. Eq a => a -> a -> Bool
    == GLenum
    GL_CCW = FrontFaceDirection
    CCW
       | Bool
    otherwise = String -> FrontFaceDirection
    forall a. HasCallStack => String -> a
    error (String
    "unmarshalFrontFaceDirection: illegal value " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ GLenum -> String
    forall a. Show a => a -> String
    show GLenum
    x)

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

    frontFace :: StateVar FrontFaceDirection
    frontFace :: StateVar FrontFaceDirection
    frontFace =
       IO FrontFaceDirection
    -> (FrontFaceDirection -> IO ()) -> StateVar FrontFaceDirection
    forall a. IO a -> (a -> IO ()) -> StateVar a
    makeStateVar
          ((GLenum -> FrontFaceDirection) -> PName1I -> IO FrontFaceDirection
    forall p a. GetPName1I p => (GLenum -> a) -> p -> IO a
    forall a. (GLenum -> a) -> PName1I -> IO a
    getEnum1 GLenum -> FrontFaceDirection
    unmarshalFrontFaceDirection PName1I
    GetFrontFace)
          (GLenum -> IO ()
    forall (m :: * -> *). MonadIO m => GLenum -> m ()
    glFrontFace (GLenum -> IO ())
    -> (FrontFaceDirection -> GLenum) -> FrontFaceDirection -> IO ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . FrontFaceDirection -> GLenum
    marshalFrontFaceDirection)

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

    data MaterialParameter =
         MaterialEmission
       | MaterialShininess
       | MaterialAmbientAndDiffuse
       | MaterialColorIndexes
       | MaterialAmbient
       | MaterialDiffuse
       | MaterialSpecular

    marshalMaterialParameter :: MaterialParameter -> GLenum
    marshalMaterialParameter :: MaterialParameter -> GLenum
    marshalMaterialParameter MaterialParameter
    x = case MaterialParameter
    x of
       MaterialParameter
    MaterialEmission -> GLenum
    GL_EMISSION
       MaterialParameter
    MaterialShininess -> GLenum
    GL_SHININESS
       MaterialParameter
    MaterialAmbientAndDiffuse -> GLenum
    GL_AMBIENT_AND_DIFFUSE
       MaterialParameter
    MaterialColorIndexes -> GLenum
    GL_COLOR_INDEXES
       MaterialParameter
    MaterialAmbient -> GLenum
    GL_AMBIENT
       MaterialParameter
    MaterialDiffuse -> GLenum
    GL_DIFFUSE
       MaterialParameter
    MaterialSpecular -> GLenum
    GL_SPECULAR

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

    materialAmbient :: Face -> StateVar (Color4 GLfloat)
    materialAmbient :: Face -> StateVar (Color4 GLfloat)
    materialAmbient =
       (GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ())
    -> (GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ())
    -> MaterialParameter
    -> Face
    -> StateVar (Color4 GLfloat)
    forall a.
    Storable a =>
    (GLenum -> GLenum -> Ptr a -> IO ())
    -> (GLenum -> GLenum -> Ptr a -> IO ())
    -> MaterialParameter
    -> Face
    -> StateVar a
    makeMaterialVar GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ()
    glGetMaterialfvc GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ()
    glMaterialfvc MaterialParameter
    MaterialAmbient

    materialDiffuse :: Face -> StateVar (Color4 GLfloat)
    materialDiffuse :: Face -> StateVar (Color4 GLfloat)
    materialDiffuse =
       (GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ())
    -> (GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ())
    -> MaterialParameter
    -> Face
    -> StateVar (Color4 GLfloat)
    forall a.
    Storable a =>
    (GLenum -> GLenum -> Ptr a -> IO ())
    -> (GLenum -> GLenum -> Ptr a -> IO ())
    -> MaterialParameter
    -> Face
    -> StateVar a
    makeMaterialVar GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ()
    glGetMaterialfvc GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ()
    glMaterialfvc MaterialParameter
    MaterialDiffuse

    materialAmbientAndDiffuse :: Face -> StateVar (Color4 GLfloat)
    materialAmbientAndDiffuse :: Face -> StateVar (Color4 GLfloat)
    materialAmbientAndDiffuse =
       (GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ())
    -> (GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ())
    -> MaterialParameter
    -> Face
    -> StateVar (Color4 GLfloat)
    forall a.
    Storable a =>
    (GLenum -> GLenum -> Ptr a -> IO ())
    -> (GLenum -> GLenum -> Ptr a -> IO ())
    -> MaterialParameter
    -> Face
    -> StateVar a
    makeMaterialVar GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ()
    glGetMaterialfvc GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ()
    glMaterialfvc MaterialParameter
    MaterialAmbientAndDiffuse

    materialSpecular :: Face -> StateVar (Color4 GLfloat)
    materialSpecular :: Face -> StateVar (Color4 GLfloat)
    materialSpecular =
       (GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ())
    -> (GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ())
    -> MaterialParameter
    -> Face
    -> StateVar (Color4 GLfloat)
    forall a.
    Storable a =>
    (GLenum -> GLenum -> Ptr a -> IO ())
    -> (GLenum -> GLenum -> Ptr a -> IO ())
    -> MaterialParameter
    -> Face
    -> StateVar a
    makeMaterialVar GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ()
    glGetMaterialfvc GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ()
    glMaterialfvc MaterialParameter
    MaterialSpecular

    materialEmission :: Face -> StateVar (Color4 GLfloat)
    materialEmission :: Face -> StateVar (Color4 GLfloat)
    materialEmission =
       (GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ())
    -> (GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ())
    -> MaterialParameter
    -> Face
    -> StateVar (Color4 GLfloat)
    forall a.
    Storable a =>
    (GLenum -> GLenum -> Ptr a -> IO ())
    -> (GLenum -> GLenum -> Ptr a -> IO ())
    -> MaterialParameter
    -> Face
    -> StateVar a
    makeMaterialVar GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ()
    glGetMaterialfvc GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ()
    glMaterialfvc MaterialParameter
    MaterialEmission

    makeMaterialVar :: Storable a
                    => (GLenum -> GLenum -> Ptr a -> IO ())
                    -> (GLenum -> GLenum -> Ptr a -> IO ())
                    -> MaterialParameter -> Face -> StateVar a
    makeMaterialVar :: forall a.
    Storable a =>
    (GLenum -> GLenum -> Ptr a -> IO ())
    -> (GLenum -> GLenum -> Ptr a -> IO ())
    -> MaterialParameter
    -> Face
    -> StateVar a
    makeMaterialVar GLenum -> GLenum -> Ptr a -> IO ()
    getter GLenum -> GLenum -> Ptr a -> IO ()
    setter MaterialParameter
    materialParameter Face
    face =
       IO a -> (a -> IO ()) -> StateVar a
    forall a. IO a -> (a -> IO ()) -> StateVar a
    makeStateVar ((Ptr a -> IO a) -> IO a
    forall a b. Storable a => (Ptr a -> IO b) -> IO b
    alloca ((Ptr a -> IO a) -> IO a) -> (Ptr a -> IO a) -> IO a
    forall a b. (a -> b) -> a -> b
    $ \Ptr a
    buf -> do GLenum -> GLenum -> Ptr a -> IO ()
    getter GLenum
    f GLenum
    mp Ptr a
    buf ; Ptr a -> IO a
    forall a. Storable a => Ptr a -> IO a
    peek Ptr a
    buf)
                    (\a
    val -> a -> (Ptr a -> IO ()) -> IO ()
    forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
    with a
    val ((Ptr a -> IO ()) -> IO ()) -> (Ptr a -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ GLenum -> GLenum -> Ptr a -> IO ()
    setter GLenum
    f GLenum
    mp)
       where mp :: GLenum
    mp = MaterialParameter -> GLenum
    marshalMaterialParameter MaterialParameter
    materialParameter
             f :: GLenum
    f  = Face -> GLenum
    marshalFace Face
    face

    glGetMaterialfvc :: GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ()
    glGetMaterialfvc :: GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ()
    glGetMaterialfvc GLenum
    face GLenum
    pname Ptr (Color4 GLfloat)
    ptr = GLenum -> GLenum -> Ptr GLfloat -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLenum -> GLenum -> Ptr GLfloat -> m ()
    glGetMaterialfv GLenum
    face GLenum
    pname (Ptr (Color4 GLfloat) -> Ptr GLfloat
    forall a b. Ptr a -> Ptr b
    castPtr Ptr (Color4 GLfloat)
    ptr)

    glMaterialfvc :: GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ()
    glMaterialfvc :: GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ()
    glMaterialfvc GLenum
    face GLenum
    pname Ptr (Color4 GLfloat)
    ptr = GLenum -> GLenum -> Ptr GLfloat -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLenum -> GLenum -> Ptr GLfloat -> m ()
    glMaterialfv GLenum
    face GLenum
    pname (Ptr (Color4 GLfloat) -> Ptr GLfloat
    forall a b. Ptr a -> Ptr b
    castPtr Ptr (Color4 GLfloat)
    ptr)

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

    materialShininess :: Face -> StateVar GLfloat
    materialShininess :: Face -> StateVar GLfloat
    materialShininess =
       (GLenum -> GLenum -> Ptr GLfloat -> IO ())
    -> (GLenum -> GLenum -> Ptr GLfloat -> IO ())
    -> MaterialParameter
    -> Face
    -> StateVar GLfloat
    forall a.
    Storable a =>
    (GLenum -> GLenum -> Ptr a -> IO ())
    -> (GLenum -> GLenum -> Ptr a -> IO ())
    -> MaterialParameter
    -> Face
    -> StateVar a
    makeMaterialVar GLenum -> GLenum -> Ptr GLfloat -> IO ()
    glGetMaterialfvf GLenum -> GLenum -> Ptr GLfloat -> IO ()
    glMaterialff MaterialParameter
    MaterialShininess

    glGetMaterialfvf :: GLenum -> GLenum -> Ptr GLfloat -> IO ()
    glGetMaterialfvf :: GLenum -> GLenum -> Ptr GLfloat -> IO ()
    glGetMaterialfvf GLenum
    face GLenum
    pname Ptr GLfloat
    ptr = GLenum -> GLenum -> Ptr GLfloat -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLenum -> GLenum -> Ptr GLfloat -> m ()
    glGetMaterialfv GLenum
    face GLenum
    pname (Ptr GLfloat -> Ptr GLfloat
    forall a b. Ptr a -> Ptr b
    castPtr Ptr GLfloat
    ptr)

    glMaterialff :: GLenum -> GLenum -> Ptr GLfloat -> IO ()
    glMaterialff :: GLenum -> GLenum -> Ptr GLfloat -> IO ()
    glMaterialff GLenum
    face GLenum
    pname Ptr GLfloat
    ptr = GLenum -> GLenum -> Ptr GLfloat -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLenum -> GLenum -> Ptr GLfloat -> m ()
    glMaterialfv GLenum
    face GLenum
    pname (Ptr GLfloat -> Ptr GLfloat
    forall a b. Ptr a -> Ptr b
    castPtr Ptr GLfloat
    ptr)

    maxShininess :: GettableStateVar GLfloat
    maxShininess :: GettableStateVar GLfloat
    maxShininess = GettableStateVar GLfloat -> GettableStateVar GLfloat
    forall a. IO a -> IO a
    makeGettableStateVar (GettableStateVar GLfloat -> GettableStateVar GLfloat)
    -> GettableStateVar GLfloat -> GettableStateVar GLfloat
    forall a b. (a -> b) -> a -> b
    $ (GLfloat -> GLfloat) -> PName1F -> GettableStateVar GLfloat
    forall p a. GetPName1F p => (GLfloat -> a) -> p -> IO a
    forall a. (GLfloat -> a) -> PName1F -> IO a
    getFloat1 GLfloat -> GLfloat
    forall a. a -> a
    id PName1F
    GetMaxShininess

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

    -- Alas, (Index1 GLint, Index1 GLint, Index1 GLint) is not an instance of
    -- Storable...

    materialColorIndexes ::
       Face -> StateVar (Index1 GLint, Index1 GLint, Index1 GLint)
    materialColorIndexes :: Face -> StateVar (Index1 GLint, Index1 GLint, Index1 GLint)
    materialColorIndexes Face
    face =
       IO (Index1 GLint, Index1 GLint, Index1 GLint)
    -> ((Index1 GLint, Index1 GLint, Index1 GLint) -> IO ())
    -> StateVar (Index1 GLint, Index1 GLint, Index1 GLint)
    forall a. IO a -> (a -> IO ()) -> StateVar a
    makeStateVar (Face -> IO (Index1 GLint, Index1 GLint, Index1 GLint)
    getMaterialColorIndexes Face
    face) (Face -> (Index1 GLint, Index1 GLint, Index1 GLint) -> IO ()
    setMaterialColorIndexes Face
    face)

    getMaterialColorIndexes :: Face -> IO (Index1 GLint, Index1 GLint, Index1 GLint)
    getMaterialColorIndexes :: Face -> IO (Index1 GLint, Index1 GLint, Index1 GLint)
    getMaterialColorIndexes Face
    face =
       Int
    -> (Ptr GLint -> IO (Index1 GLint, Index1 GLint, Index1 GLint))
    -> IO (Index1 GLint, Index1 GLint, Index1 GLint)
    forall a b. Storable a => Int -> (Ptr a -> IO b) -> IO b
    allocaArray Int
    3 ((Ptr GLint -> IO (Index1 GLint, Index1 GLint, Index1 GLint))
     -> IO (Index1 GLint, Index1 GLint, Index1 GLint))
    -> (Ptr GLint -> IO (Index1 GLint, Index1 GLint, Index1 GLint))
    -> IO (Index1 GLint, Index1 GLint, Index1 GLint)
    forall a b. (a -> b) -> a -> b
    $ \Ptr GLint
    buf -> do
          GLenum -> GLenum -> Ptr GLint -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLenum -> GLenum -> Ptr GLint -> m ()
    glGetMaterialiv (Face -> GLenum
    marshalFace Face
    face)
                          (MaterialParameter -> GLenum
    marshalMaterialParameter MaterialParameter
    MaterialColorIndexes)
                          Ptr GLint
    buf
          (GLint
     -> GLint -> GLint -> (Index1 GLint, Index1 GLint, Index1 GLint))
    -> Ptr GLint -> IO (Index1 GLint, Index1 GLint, Index1 GLint)
    forall a b. Storable a => (a -> a -> a -> b) -> Ptr a -> IO b
    peek3 (\GLint
    a GLint
    d GLint
    s -> (GLint -> Index1 GLint
    forall a. a -> Index1 a
    Index1 GLint
    a, GLint -> Index1 GLint
    forall a. a -> Index1 a
    Index1 GLint
    d, GLint -> Index1 GLint
    forall a. a -> Index1 a
    Index1 GLint
    s)) Ptr GLint
    buf

    setMaterialColorIndexes ::
       Face -> (Index1 GLint, Index1 GLint, Index1 GLint) -> IO ()
    setMaterialColorIndexes :: Face -> (Index1 GLint, Index1 GLint, Index1 GLint) -> IO ()
    setMaterialColorIndexes Face
    face (Index1 GLint
    a, Index1 GLint
    d, Index1 GLint
    s) =
       [GLint] -> (Ptr GLint -> IO ()) -> IO ()
    forall a b. Storable a => [a] -> (Ptr a -> IO b) -> IO b
    withArray [GLint
    a, GLint
    d, GLint
    s] ((Ptr GLint -> IO ()) -> IO ()) -> (Ptr GLint -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $
          GLenum -> GLenum -> Ptr GLint -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLenum -> GLenum -> Ptr GLint -> m ()
    glMaterialiv (Face -> GLenum
    marshalFace Face
    face)
                       (MaterialParameter -> GLenum
    marshalMaterialParameter MaterialParameter
    MaterialColorIndexes)

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

    data LightParameter =
         Ambient'
       | Diffuse'
       | Specular'
       | Position
       | SpotDirection
       | SpotExponent
       | SpotCutoff
       | ConstantAttenuation
       | LinearAttenuation
       | QuadraticAttenuation

    marshalLightParameter :: LightParameter -> GLenum
    marshalLightParameter :: LightParameter -> GLenum
    marshalLightParameter LightParameter
    x = case LightParameter
    x of
       LightParameter
    Ambient' -> GLenum
    GL_AMBIENT
       LightParameter
    Diffuse' -> GLenum
    GL_DIFFUSE
       LightParameter
    Specular' -> GLenum
    GL_SPECULAR
       LightParameter
    Position -> GLenum
    GL_POSITION
       LightParameter
    SpotDirection -> GLenum
    GL_SPOT_DIRECTION
       LightParameter
    SpotExponent -> GLenum
    GL_SPOT_EXPONENT
       LightParameter
    SpotCutoff -> GLenum
    GL_SPOT_CUTOFF
       LightParameter
    ConstantAttenuation -> GLenum
    GL_CONSTANT_ATTENUATION
       LightParameter
    LinearAttenuation -> GLenum
    GL_LINEAR_ATTENUATION
       LightParameter
    QuadraticAttenuation -> GLenum
    GL_QUADRATIC_ATTENUATION

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

    ambient :: Light -> StateVar (Color4 GLfloat)
    ambient :: Light -> StateVar (Color4 GLfloat)
    ambient = (GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ())
    -> (GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ())
    -> LightParameter
    -> Color4 GLfloat
    -> Light
    -> StateVar (Color4 GLfloat)
    forall a.
    Storable a =>
    (GLenum -> GLenum -> Ptr a -> IO ())
    -> (GLenum -> GLenum -> Ptr a -> IO ())
    -> LightParameter
    -> a
    -> Light
    -> StateVar a
    makeLightVar GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ()
    glGetLightfvc GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ()
    glLightfvc LightParameter
    Ambient' Color4 GLfloat
    black

    black :: Color4 GLfloat
    black :: Color4 GLfloat
    black = GLfloat -> GLfloat -> GLfloat -> GLfloat -> Color4 GLfloat
    forall a. a -> a -> a -> a -> Color4 a
    Color4 GLfloat
    0 GLfloat
    0 GLfloat
    0 GLfloat
    0

    diffuse :: Light -> StateVar (Color4 GLfloat)
    diffuse :: Light -> StateVar (Color4 GLfloat)
    diffuse = (GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ())
    -> (GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ())
    -> LightParameter
    -> Color4 GLfloat
    -> Light
    -> StateVar (Color4 GLfloat)
    forall a.
    Storable a =>
    (GLenum -> GLenum -> Ptr a -> IO ())
    -> (GLenum -> GLenum -> Ptr a -> IO ())
    -> LightParameter
    -> a
    -> Light
    -> StateVar a
    makeLightVar GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ()
    glGetLightfvc GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ()
    glLightfvc LightParameter
    Diffuse' Color4 GLfloat
    black

    specular :: Light -> StateVar (Color4 GLfloat)
    specular :: Light -> StateVar (Color4 GLfloat)
    specular = (GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ())
    -> (GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ())
    -> LightParameter
    -> Color4 GLfloat
    -> Light
    -> StateVar (Color4 GLfloat)
    forall a.
    Storable a =>
    (GLenum -> GLenum -> Ptr a -> IO ())
    -> (GLenum -> GLenum -> Ptr a -> IO ())
    -> LightParameter
    -> a
    -> Light
    -> StateVar a
    makeLightVar GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ()
    glGetLightfvc GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ()
    glLightfvc LightParameter
    Specular' Color4 GLfloat
    black

    makeLightVar :: Storable a
                 => (GLenum -> GLenum -> Ptr a -> IO ())
                 -> (GLenum -> GLenum -> Ptr a -> IO ())
                 -> LightParameter -> a -> Light -> StateVar a
    makeLightVar :: forall a.
    Storable a =>
    (GLenum -> GLenum -> Ptr a -> IO ())
    -> (GLenum -> GLenum -> Ptr a -> IO ())
    -> LightParameter
    -> a
    -> Light
    -> StateVar a
    makeLightVar GLenum -> GLenum -> Ptr a -> IO ()
    getter GLenum -> GLenum -> Ptr a -> IO ()
    setter LightParameter
    lightParameter a
    defaultValue Light
    theLight =
       IO a -> (a -> IO ()) -> StateVar a
    forall a. IO a -> (a -> IO ()) -> StateVar a
    makeStateVar (IO a -> (GLenum -> IO a) -> Maybe GLenum -> IO a
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe (a -> IO a
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return a
    defaultValue) GLenum -> IO a
    getLightVar Maybe GLenum
    ml)
                    (\a
    val -> IO () -> (GLenum -> IO ()) -> Maybe GLenum -> IO ()
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe IO ()
    recordInvalidEnum (a -> GLenum -> IO ()
    setLightVar a
    val) Maybe GLenum
    ml)
       where lp :: GLenum
    lp          = LightParameter -> GLenum
    marshalLightParameter LightParameter
    lightParameter
             ml :: Maybe GLenum
    ml          = Light -> Maybe GLenum
    marshalLight Light
    theLight
             getLightVar :: GLenum -> IO a
    getLightVar = \GLenum
    l -> (Ptr a -> IO a) -> IO a
    forall a b. Storable a => (Ptr a -> IO b) -> IO b
    alloca ((Ptr a -> IO a) -> IO a) -> (Ptr a -> IO a) -> IO a
    forall a b. (a -> b) -> a -> b
    $ \Ptr a
    buf -> do GLenum -> GLenum -> Ptr a -> IO ()
    getter GLenum
    l GLenum
    lp Ptr a
    buf ; Ptr a -> IO a
    forall a. Storable a => Ptr a -> IO a
    peek Ptr a
    buf
             setLightVar :: a -> GLenum -> IO ()
    setLightVar = \a
    val GLenum
    l -> a -> (Ptr a -> IO ()) -> IO ()
    forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
    with a
    val ((Ptr a -> IO ()) -> IO ()) -> (Ptr a -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ GLenum -> GLenum -> Ptr a -> IO ()
    setter GLenum
    l GLenum
    lp

    glGetLightfvc :: GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ()
    glGetLightfvc :: GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ()
    glGetLightfvc GLenum
    l GLenum
    pname Ptr (Color4 GLfloat)
    ptr = GLenum -> GLenum -> Ptr GLfloat -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLenum -> GLenum -> Ptr GLfloat -> m ()
    glGetLightfv GLenum
    l GLenum
    pname (Ptr (Color4 GLfloat) -> Ptr GLfloat
    forall a b. Ptr a -> Ptr b
    castPtr Ptr (Color4 GLfloat)
    ptr)

    glLightfvc :: GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ()
    glLightfvc :: GLenum -> GLenum -> Ptr (Color4 GLfloat) -> IO ()
    glLightfvc GLenum
    l GLenum
    pname Ptr (Color4 GLfloat)
    ptr = GLenum -> GLenum -> Ptr GLfloat -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLenum -> GLenum -> Ptr GLfloat -> m ()
    glLightfv GLenum
    l GLenum
    pname (Ptr (Color4 GLfloat) -> Ptr GLfloat
    forall a b. Ptr a -> Ptr b
    castPtr Ptr (Color4 GLfloat)
    ptr)

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

    position :: Light -> StateVar (Vertex4 GLfloat)
    position :: Light -> StateVar (Vertex4 GLfloat)
    position = (GLenum -> GLenum -> Ptr (Vertex4 GLfloat) -> IO ())
    -> (GLenum -> GLenum -> Ptr (Vertex4 GLfloat) -> IO ())
    -> LightParameter
    -> Vertex4 GLfloat
    -> Light
    -> StateVar (Vertex4 GLfloat)
    forall a.
    Storable a =>
    (GLenum -> GLenum -> Ptr a -> IO ())
    -> (GLenum -> GLenum -> Ptr a -> IO ())
    -> LightParameter
    -> a
    -> Light
    -> StateVar a
    makeLightVar GLenum -> GLenum -> Ptr (Vertex4 GLfloat) -> IO ()
    glGetLightfvv GLenum -> GLenum -> Ptr (Vertex4 GLfloat) -> IO ()
    glLightfvv LightParameter
    Position (GLfloat -> GLfloat -> GLfloat -> GLfloat -> Vertex4 GLfloat
    forall a. a -> a -> a -> a -> Vertex4 a
    Vertex4 GLfloat
    0 GLfloat
    0 GLfloat
    0 GLfloat
    0)

    glLightfvv :: GLenum -> GLenum -> Ptr (Vertex4 GLfloat) -> IO ()
    glLightfvv :: GLenum -> GLenum -> Ptr (Vertex4 GLfloat) -> IO ()
    glLightfvv GLenum
    l GLenum
    pname Ptr (Vertex4 GLfloat)
    ptr = GLenum -> GLenum -> Ptr GLfloat -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLenum -> GLenum -> Ptr GLfloat -> m ()
    glLightfv GLenum
    l GLenum
    pname (Ptr (Vertex4 GLfloat) -> Ptr GLfloat
    forall a b. Ptr a -> Ptr b
    castPtr Ptr (Vertex4 GLfloat)
    ptr)

    glGetLightfvv :: GLenum -> GLenum -> Ptr (Vertex4 GLfloat) -> IO ()
    glGetLightfvv :: GLenum -> GLenum -> Ptr (Vertex4 GLfloat) -> IO ()
    glGetLightfvv GLenum
    l GLenum
    pname Ptr (Vertex4 GLfloat)
    ptr = GLenum -> GLenum -> Ptr GLfloat -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLenum -> GLenum -> Ptr GLfloat -> m ()
    glGetLightfv GLenum
    l GLenum
    pname (Ptr (Vertex4 GLfloat) -> Ptr GLfloat
    forall a b. Ptr a -> Ptr b
    castPtr Ptr (Vertex4 GLfloat)
    ptr)

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

    spotDirection :: Light -> StateVar (Normal3 GLfloat)
    spotDirection :: Light -> StateVar (Normal3 GLfloat)
    spotDirection =
       (GLenum -> GLenum -> Ptr (Normal3 GLfloat) -> IO ())
    -> (GLenum -> GLenum -> Ptr (Normal3 GLfloat) -> IO ())
    -> LightParameter
    -> Normal3 GLfloat
    -> Light
    -> StateVar (Normal3 GLfloat)
    forall a.
    Storable a =>
    (GLenum -> GLenum -> Ptr a -> IO ())
    -> (GLenum -> GLenum -> Ptr a -> IO ())
    -> LightParameter
    -> a
    -> Light
    -> StateVar a
    makeLightVar GLenum -> GLenum -> Ptr (Normal3 GLfloat) -> IO ()
    glGetLightfvn GLenum -> GLenum -> Ptr (Normal3 GLfloat) -> IO ()
    glLightfvn LightParameter
    SpotDirection (GLfloat -> GLfloat -> GLfloat -> Normal3 GLfloat
    forall a. a -> a -> a -> Normal3 a
    Normal3 GLfloat
    0 GLfloat
    0 GLfloat
    0)

    glLightfvn :: GLenum -> GLenum -> Ptr (Normal3 GLfloat) -> IO ()
    glLightfvn :: GLenum -> GLenum -> Ptr (Normal3 GLfloat) -> IO ()
    glLightfvn GLenum
    l GLenum
    pname Ptr (Normal3 GLfloat)
    ptr = GLenum -> GLenum -> Ptr GLfloat -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLenum -> GLenum -> Ptr GLfloat -> m ()
    glLightfv GLenum
    l GLenum
    pname (Ptr (Normal3 GLfloat) -> Ptr GLfloat
    forall a b. Ptr a -> Ptr b
    castPtr Ptr (Normal3 GLfloat)
    ptr)

    glGetLightfvn :: GLenum -> GLenum -> Ptr (Normal3 GLfloat) -> IO ()
    glGetLightfvn :: GLenum -> GLenum -> Ptr (Normal3 GLfloat) -> IO ()
    glGetLightfvn GLenum
    l GLenum
    pname Ptr (Normal3 GLfloat)
    ptr = GLenum -> GLenum -> Ptr GLfloat -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLenum -> GLenum -> Ptr GLfloat -> m ()
    glGetLightfv GLenum
    l GLenum
    pname (Ptr (Normal3 GLfloat) -> Ptr GLfloat
    forall a b. Ptr a -> Ptr b
    castPtr Ptr (Normal3 GLfloat)
    ptr)

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

    spotExponent :: Light -> StateVar GLfloat
    spotExponent :: Light -> StateVar GLfloat
    spotExponent = (GLenum -> GLenum -> Ptr GLfloat -> IO ())
    -> (GLenum -> GLenum -> Ptr GLfloat -> IO ())
    -> LightParameter
    -> GLfloat
    -> Light
    -> StateVar GLfloat
    forall a.
    Storable a =>
    (GLenum -> GLenum -> Ptr a -> IO ())
    -> (GLenum -> GLenum -> Ptr a -> IO ())
    -> LightParameter
    -> a
    -> Light
    -> StateVar a
    makeLightVar GLenum -> GLenum -> Ptr GLfloat -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLenum -> GLenum -> Ptr GLfloat -> m ()
    glGetLightfv GLenum -> GLenum -> Ptr GLfloat -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLenum -> GLenum -> Ptr GLfloat -> m ()
    glLightfv LightParameter
    SpotExponent GLfloat
    0

    maxSpotExponent :: GettableStateVar GLfloat
    maxSpotExponent :: GettableStateVar GLfloat
    maxSpotExponent = GettableStateVar GLfloat -> GettableStateVar GLfloat
    forall a. IO a -> IO a
    makeGettableStateVar (GettableStateVar GLfloat -> GettableStateVar GLfloat)
    -> GettableStateVar GLfloat -> GettableStateVar GLfloat
    forall a b. (a -> b) -> a -> b
    $ (GLfloat -> GLfloat) -> PName1F -> GettableStateVar GLfloat
    forall p a. GetPName1F p => (GLfloat -> a) -> p -> IO a
    forall a. (GLfloat -> a) -> PName1F -> IO a
    getFloat1 GLfloat -> GLfloat
    forall a. a -> a
    id PName1F
    GetMaxSpotExponent

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

    spotCutoff :: Light -> StateVar GLfloat
    spotCutoff :: Light -> StateVar GLfloat
    spotCutoff = (GLenum -> GLenum -> Ptr GLfloat -> IO ())
    -> (GLenum -> GLenum -> Ptr GLfloat -> IO ())
    -> LightParameter
    -> GLfloat
    -> Light
    -> StateVar GLfloat
    forall a.
    Storable a =>
    (GLenum -> GLenum -> Ptr a -> IO ())
    -> (GLenum -> GLenum -> Ptr a -> IO ())
    -> LightParameter
    -> a
    -> Light
    -> StateVar a
    makeLightVar GLenum -> GLenum -> Ptr GLfloat -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLenum -> GLenum -> Ptr GLfloat -> m ()
    glGetLightfv GLenum -> GLenum -> Ptr GLfloat -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLenum -> GLenum -> Ptr GLfloat -> m ()
    glLightfv LightParameter
    SpotCutoff GLfloat
    0

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

    attenuation :: Light -> StateVar (GLfloat, GLfloat, GLfloat)
    attenuation :: Light -> StateVar (GLfloat, GLfloat, GLfloat)
    attenuation Light
    theLight =
       IO (GLfloat, GLfloat, GLfloat)
    -> ((GLfloat, GLfloat, GLfloat) -> IO ())
    -> StateVar (GLfloat, GLfloat, GLfloat)
    forall a. IO a -> (a -> IO ()) -> StateVar a
    makeStateVar
          ((GLfloat -> GLfloat -> GLfloat -> (GLfloat, GLfloat, GLfloat))
    -> GettableStateVar GLfloat
    -> GettableStateVar GLfloat
    -> GettableStateVar GLfloat
    -> IO (GLfloat, GLfloat, GLfloat)
    forall (m :: * -> *) a1 a2 a3 r.
    Monad m =>
    (a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
    liftM3 (,,) (StateVar GLfloat -> GettableStateVar GLfloat
    forall t a (m :: * -> *). (HasGetter t a, MonadIO m) => t -> m a
    forall (m :: * -> *). MonadIO m => StateVar GLfloat -> m GLfloat
    get (Light -> StateVar GLfloat
    constantAttenuation  Light
    theLight))
                       (StateVar GLfloat -> GettableStateVar GLfloat
    forall t a (m :: * -> *). (HasGetter t a, MonadIO m) => t -> m a
    forall (m :: * -> *). MonadIO m => StateVar GLfloat -> m GLfloat
    get (Light -> StateVar GLfloat
    linearAttenuation    Light
    theLight))
                       (StateVar GLfloat -> GettableStateVar GLfloat
    forall t a (m :: * -> *). (HasGetter t a, MonadIO m) => t -> m a
    forall (m :: * -> *). MonadIO m => StateVar GLfloat -> m GLfloat
    get (Light -> StateVar GLfloat
    quadraticAttenuation Light
    theLight)))
          (\(GLfloat
    constant, GLfloat
    linear, GLfloat
    quadratic) -> do
             Light -> StateVar GLfloat
    constantAttenuation  Light
    theLight StateVar GLfloat -> GLfloat -> IO ()
    forall t a (m :: * -> *).
    (HasSetter t a, MonadIO m) =>
    t -> a -> m ()
    forall (m :: * -> *).
    MonadIO m =>
    StateVar GLfloat -> GLfloat -> m ()
    $= GLfloat
    constant
             Light -> StateVar GLfloat
    linearAttenuation    Light
    theLight StateVar GLfloat -> GLfloat -> IO ()
    forall t a (m :: * -> *).
    (HasSetter t a, MonadIO m) =>
    t -> a -> m ()
    forall (m :: * -> *).
    MonadIO m =>
    StateVar GLfloat -> GLfloat -> m ()
    $= GLfloat
    linear
             Light -> StateVar GLfloat
    quadraticAttenuation Light
    theLight StateVar GLfloat -> GLfloat -> IO ()
    forall t a (m :: * -> *).
    (HasSetter t a, MonadIO m) =>
    t -> a -> m ()
    forall (m :: * -> *).
    MonadIO m =>
    StateVar GLfloat -> GLfloat -> m ()
    $= GLfloat
    quadratic)

    constantAttenuation :: Light -> StateVar GLfloat
    constantAttenuation :: Light -> StateVar GLfloat
    constantAttenuation = (GLenum -> GLenum -> Ptr GLfloat -> IO ())
    -> (GLenum -> GLenum -> Ptr GLfloat -> IO ())
    -> LightParameter
    -> GLfloat
    -> Light
    -> StateVar GLfloat
    forall a.
    Storable a =>
    (GLenum -> GLenum -> Ptr a -> IO ())
    -> (GLenum -> GLenum -> Ptr a -> IO ())
    -> LightParameter
    -> a
    -> Light
    -> StateVar a
    makeLightVar GLenum -> GLenum -> Ptr GLfloat -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLenum -> GLenum -> Ptr GLfloat -> m ()
    glGetLightfv GLenum -> GLenum -> Ptr GLfloat -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLenum -> GLenum -> Ptr GLfloat -> m ()
    glLightfv LightParameter
    ConstantAttenuation GLfloat
    0

    linearAttenuation :: Light -> StateVar GLfloat
    linearAttenuation :: Light -> StateVar GLfloat
    linearAttenuation = (GLenum -> GLenum -> Ptr GLfloat -> IO ())
    -> (GLenum -> GLenum -> Ptr GLfloat -> IO ())
    -> LightParameter
    -> GLfloat
    -> Light
    -> StateVar GLfloat
    forall a.
    Storable a =>
    (GLenum -> GLenum -> Ptr a -> IO ())
    -> (GLenum -> GLenum -> Ptr a -> IO ())
    -> LightParameter
    -> a
    -> Light
    -> StateVar a
    makeLightVar GLenum -> GLenum -> Ptr GLfloat -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLenum -> GLenum -> Ptr GLfloat -> m ()
    glGetLightfv GLenum -> GLenum -> Ptr GLfloat -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLenum -> GLenum -> Ptr GLfloat -> m ()
    glLightfv LightParameter
    LinearAttenuation GLfloat
    0

    quadraticAttenuation :: Light -> StateVar GLfloat
    quadraticAttenuation :: Light -> StateVar GLfloat
    quadraticAttenuation =
       (GLenum -> GLenum -> Ptr GLfloat -> IO ())
    -> (GLenum -> GLenum -> Ptr GLfloat -> IO ())
    -> LightParameter
    -> GLfloat
    -> Light
    -> StateVar GLfloat
    forall a.
    Storable a =>
    (GLenum -> GLenum -> Ptr a -> IO ())
    -> (GLenum -> GLenum -> Ptr a -> IO ())
    -> LightParameter
    -> a
    -> Light
    -> StateVar a
    makeLightVar GLenum -> GLenum -> Ptr GLfloat -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLenum -> GLenum -> Ptr GLfloat -> m ()
    glGetLightfv GLenum -> GLenum -> Ptr GLfloat -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLenum -> GLenum -> Ptr GLfloat -> m ()
    glLightfv LightParameter
    QuadraticAttenuation GLfloat
    0

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

    data LightModelParameter =
         LightModelAmbient
       | LightModelLocalViewer
       | LightModelTwoSide
       | LightModelColorControl

    marshalLightModelParameter :: LightModelParameter -> GLenum
    marshalLightModelParameter :: LightModelParameter -> GLenum
    marshalLightModelParameter LightModelParameter
    x = case LightModelParameter
    x of
       LightModelParameter
    LightModelAmbient -> GLenum
    GL_LIGHT_MODEL_AMBIENT
       LightModelParameter
    LightModelLocalViewer -> GLenum
    GL_LIGHT_MODEL_LOCAL_VIEWER
       LightModelParameter
    LightModelTwoSide -> GLenum
    GL_LIGHT_MODEL_TWO_SIDE
       LightModelParameter
    LightModelColorControl -> GLenum
    GL_LIGHT_MODEL_COLOR_CONTROL

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

    lightModelAmbient :: StateVar (Color4 GLfloat)
    lightModelAmbient :: StateVar (Color4 GLfloat)
    lightModelAmbient =
       IO (Color4 GLfloat)
    -> (Color4 GLfloat -> IO ()) -> StateVar (Color4 GLfloat)
    forall a. IO a -> (a -> IO ()) -> StateVar a
    makeStateVar
          ((GLfloat -> GLfloat -> GLfloat -> GLfloat -> Color4 GLfloat)
    -> PName4F -> IO (Color4 GLfloat)
    forall p a.
    GetPName4F p =>
    (GLfloat -> GLfloat -> GLfloat -> GLfloat -> a) -> p -> IO a
    forall a.
    (GLfloat -> GLfloat -> GLfloat -> GLfloat -> a) -> PName4F -> IO a
    getFloat4 GLfloat -> GLfloat -> GLfloat -> GLfloat -> Color4 GLfloat
    forall a. a -> a -> a -> a -> Color4 a
    Color4 PName4F
    GetLightModelAmbient)
          (\Color4 GLfloat
    c -> Color4 GLfloat -> (Ptr (Color4 GLfloat) -> IO ()) -> IO ()
    forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
    with Color4 GLfloat
    c ((Ptr (Color4 GLfloat) -> IO ()) -> IO ())
    -> (Ptr (Color4 GLfloat) -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $
                    GLenum -> Ptr GLfloat -> IO ()
    forall (m :: * -> *). MonadIO m => GLenum -> Ptr GLfloat -> m ()
    glLightModelfv (LightModelParameter -> GLenum
    marshalLightModelParameter LightModelParameter
    LightModelAmbient) (Ptr GLfloat -> IO ())
    -> (Ptr (Color4 GLfloat) -> Ptr GLfloat)
    -> Ptr (Color4 GLfloat)
    -> IO ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Ptr (Color4 GLfloat) -> Ptr GLfloat
    forall a b. Ptr a -> Ptr b
    castPtr)

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

    lightModelLocalViewer :: StateVar Capability
    lightModelLocalViewer :: StateVar Capability
    lightModelLocalViewer =
       PName1I -> LightModelParameter -> StateVar Capability
    makeLightModelCapVar PName1I
    GetLightModelLocalViewer LightModelParameter
    LightModelLocalViewer

    makeLightModelCapVar :: PName1I -> LightModelParameter -> StateVar Capability
    makeLightModelCapVar :: PName1I -> LightModelParameter -> StateVar Capability
    makeLightModelCapVar PName1I
    pname LightModelParameter
    lightModelParameter =
       IO Capability -> (Capability -> IO ()) -> StateVar Capability
    forall a. IO a -> (a -> IO ()) -> StateVar a
    makeStateVar
          ((GLboolean -> Capability) -> PName1I -> IO Capability
    forall p a. GetPName1I p => (GLboolean -> a) -> p -> IO a
    forall a. (GLboolean -> a) -> PName1I -> IO a
    getBoolean1 GLboolean -> Capability
    unmarshalCapability PName1I
    pname)
          (GLenum -> GLint -> IO ()
    forall (m :: * -> *). MonadIO m => GLenum -> GLint -> m ()
    glLightModeli (LightModelParameter -> GLenum
    marshalLightModelParameter LightModelParameter
    lightModelParameter) (GLint -> IO ()) -> (Capability -> GLint) -> Capability -> IO ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    .
                         GLboolean -> GLint
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral (GLboolean -> GLint)
    -> (Capability -> GLboolean) -> Capability -> GLint
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Capability -> GLboolean
    marshalCapability)

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

    lightModelTwoSide :: StateVar Capability
    lightModelTwoSide :: StateVar Capability
    lightModelTwoSide = PName1I -> LightModelParameter -> StateVar Capability
    makeLightModelCapVar PName1I
    GetLightModelTwoSide LightModelParameter
    LightModelTwoSide

    vertexProgramTwoSide :: StateVar Capability
    vertexProgramTwoSide :: StateVar Capability
    vertexProgramTwoSide = EnableCap -> StateVar Capability
    makeCapability EnableCap
    CapVertexProgramTwoSide

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

    data LightModelColorControl =
         SingleColor
       | SeparateSpecularColor
       deriving ( LightModelColorControl -> LightModelColorControl -> Bool
    (LightModelColorControl -> LightModelColorControl -> Bool)
    -> (LightModelColorControl -> LightModelColorControl -> Bool)
    -> Eq LightModelColorControl
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: LightModelColorControl -> LightModelColorControl -> Bool
    == :: LightModelColorControl -> LightModelColorControl -> Bool
    $c/= :: LightModelColorControl -> LightModelColorControl -> Bool
    /= :: LightModelColorControl -> LightModelColorControl -> Bool
    Eq, Eq LightModelColorControl
    Eq LightModelColorControl =>
    (LightModelColorControl -> LightModelColorControl -> Ordering)
    -> (LightModelColorControl -> LightModelColorControl -> Bool)
    -> (LightModelColorControl -> LightModelColorControl -> Bool)
    -> (LightModelColorControl -> LightModelColorControl -> Bool)
    -> (LightModelColorControl -> LightModelColorControl -> Bool)
    -> (LightModelColorControl
        -> LightModelColorControl -> LightModelColorControl)
    -> (LightModelColorControl
        -> LightModelColorControl -> LightModelColorControl)
    -> Ord LightModelColorControl
    LightModelColorControl -> LightModelColorControl -> Bool
    LightModelColorControl -> LightModelColorControl -> Ordering
    LightModelColorControl
    -> LightModelColorControl -> LightModelColorControl
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: LightModelColorControl -> LightModelColorControl -> Ordering
    compare :: LightModelColorControl -> LightModelColorControl -> Ordering
    $c< :: LightModelColorControl -> LightModelColorControl -> Bool
    < :: LightModelColorControl -> LightModelColorControl -> Bool
    $c<= :: LightModelColorControl -> LightModelColorControl -> Bool
    <= :: LightModelColorControl -> LightModelColorControl -> Bool
    $c> :: LightModelColorControl -> LightModelColorControl -> Bool
    > :: LightModelColorControl -> LightModelColorControl -> Bool
    $c>= :: LightModelColorControl -> LightModelColorControl -> Bool
    >= :: LightModelColorControl -> LightModelColorControl -> Bool
    $cmax :: LightModelColorControl
    -> LightModelColorControl -> LightModelColorControl
    max :: LightModelColorControl
    -> LightModelColorControl -> LightModelColorControl
    $cmin :: LightModelColorControl
    -> LightModelColorControl -> LightModelColorControl
    min :: LightModelColorControl
    -> LightModelColorControl -> LightModelColorControl
    Ord, Int -> LightModelColorControl -> ShowS
    [LightModelColorControl] -> ShowS
    LightModelColorControl -> String
    (Int -> LightModelColorControl -> ShowS)
    -> (LightModelColorControl -> String)
    -> ([LightModelColorControl] -> ShowS)
    -> Show LightModelColorControl
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> LightModelColorControl -> ShowS
    showsPrec :: Int -> LightModelColorControl -> ShowS
    $cshow :: LightModelColorControl -> String
    show :: LightModelColorControl -> String
    $cshowList :: [LightModelColorControl] -> ShowS
    showList :: [LightModelColorControl] -> ShowS
    Show )

    marshalLightModelColorControl :: LightModelColorControl -> GLenum
    marshalLightModelColorControl :: LightModelColorControl -> GLenum
    marshalLightModelColorControl LightModelColorControl
    x = case LightModelColorControl
    x of
       LightModelColorControl
    SingleColor -> GLenum
    GL_SINGLE_COLOR
       LightModelColorControl
    SeparateSpecularColor -> GLenum
    GL_SEPARATE_SPECULAR_COLOR

    unmarshalLightModelColorControl :: GLenum -> LightModelColorControl
    unmarshalLightModelColorControl :: GLenum -> LightModelColorControl
    unmarshalLightModelColorControl GLenum
    x
       | GLenum
    x GLenum -> GLenum -> Bool
    forall a. Eq a => a -> a -> Bool
    == GLenum
    GL_SINGLE_COLOR = LightModelColorControl
    SingleColor
       | GLenum
    x GLenum -> GLenum -> Bool
    forall a. Eq a => a -> a -> Bool
    == GLenum
    GL_SEPARATE_SPECULAR_COLOR = LightModelColorControl
    SeparateSpecularColor
       | Bool
    otherwise = String -> LightModelColorControl
    forall a. HasCallStack => String -> a
    error (String
    "unmarshalLightModelColorControl: illegal value " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ GLenum -> String
    forall a. Show a => a -> String
    show GLenum
    x)

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

    lightModelColorControl :: StateVar LightModelColorControl
    lightModelColorControl :: StateVar LightModelColorControl
    lightModelColorControl =
       IO LightModelColorControl
    -> (LightModelColorControl -> IO ())
    -> StateVar LightModelColorControl
    forall a. IO a -> (a -> IO ()) -> StateVar a
    makeStateVar
          ((GLenum -> LightModelColorControl)
    -> PName1I -> IO LightModelColorControl
    forall p a. GetPName1I p => (GLenum -> a) -> p -> IO a
    forall a. (GLenum -> a) -> PName1I -> IO a
    getEnum1 GLenum -> LightModelColorControl
    unmarshalLightModelColorControl PName1I
    GetLightModelColorControl)
          (GLenum -> GLint -> IO ()
    forall (m :: * -> *). MonadIO m => GLenum -> GLint -> m ()
    glLightModeli (LightModelParameter -> GLenum
    marshalLightModelParameter LightModelParameter
    LightModelColorControl) (GLint -> IO ())
    -> (LightModelColorControl -> GLint)
    -> LightModelColorControl
    -> IO ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    .
                         GLenum -> GLint
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral (GLenum -> GLint)
    -> (LightModelColorControl -> GLenum)
    -> LightModelColorControl
    -> GLint
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . LightModelColorControl -> GLenum
    marshalLightModelColorControl)

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

    data ColorMaterialParameter =
         Ambient
       | Diffuse
       | Specular
       | Emission
       | AmbientAndDiffuse
       deriving ( ColorMaterialParameter -> ColorMaterialParameter -> Bool
    (ColorMaterialParameter -> ColorMaterialParameter -> Bool)
    -> (ColorMaterialParameter -> ColorMaterialParameter -> Bool)
    -> Eq ColorMaterialParameter
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: ColorMaterialParameter -> ColorMaterialParameter -> Bool
    == :: ColorMaterialParameter -> ColorMaterialParameter -> Bool
    $c/= :: ColorMaterialParameter -> ColorMaterialParameter -> Bool
    /= :: ColorMaterialParameter -> ColorMaterialParameter -> Bool
    Eq, Eq ColorMaterialParameter
    Eq ColorMaterialParameter =>
    (ColorMaterialParameter -> ColorMaterialParameter -> Ordering)
    -> (ColorMaterialParameter -> ColorMaterialParameter -> Bool)
    -> (ColorMaterialParameter -> ColorMaterialParameter -> Bool)
    -> (ColorMaterialParameter -> ColorMaterialParameter -> Bool)
    -> (ColorMaterialParameter -> ColorMaterialParameter -> Bool)
    -> (ColorMaterialParameter
        -> ColorMaterialParameter -> ColorMaterialParameter)
    -> (ColorMaterialParameter
        -> ColorMaterialParameter -> ColorMaterialParameter)
    -> Ord ColorMaterialParameter
    ColorMaterialParameter -> ColorMaterialParameter -> Bool
    ColorMaterialParameter -> ColorMaterialParameter -> Ordering
    ColorMaterialParameter
    -> ColorMaterialParameter -> ColorMaterialParameter
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: ColorMaterialParameter -> ColorMaterialParameter -> Ordering
    compare :: ColorMaterialParameter -> ColorMaterialParameter -> Ordering
    $c< :: ColorMaterialParameter -> ColorMaterialParameter -> Bool
    < :: ColorMaterialParameter -> ColorMaterialParameter -> Bool
    $c<= :: ColorMaterialParameter -> ColorMaterialParameter -> Bool
    <= :: ColorMaterialParameter -> ColorMaterialParameter -> Bool
    $c> :: ColorMaterialParameter -> ColorMaterialParameter -> Bool
    > :: ColorMaterialParameter -> ColorMaterialParameter -> Bool
    $c>= :: ColorMaterialParameter -> ColorMaterialParameter -> Bool
    >= :: ColorMaterialParameter -> ColorMaterialParameter -> Bool
    $cmax :: ColorMaterialParameter
    -> ColorMaterialParameter -> ColorMaterialParameter
    max :: ColorMaterialParameter
    -> ColorMaterialParameter -> ColorMaterialParameter
    $cmin :: ColorMaterialParameter
    -> ColorMaterialParameter -> ColorMaterialParameter
    min :: ColorMaterialParameter
    -> ColorMaterialParameter -> ColorMaterialParameter
    Ord, Int -> ColorMaterialParameter -> ShowS
    [ColorMaterialParameter] -> ShowS
    ColorMaterialParameter -> String
    (Int -> ColorMaterialParameter -> ShowS)
    -> (ColorMaterialParameter -> String)
    -> ([ColorMaterialParameter] -> ShowS)
    -> Show ColorMaterialParameter
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> ColorMaterialParameter -> ShowS
    showsPrec :: Int -> ColorMaterialParameter -> ShowS
    $cshow :: ColorMaterialParameter -> String
    show :: ColorMaterialParameter -> String
    $cshowList :: [ColorMaterialParameter] -> ShowS
    showList :: [ColorMaterialParameter] -> ShowS
    Show )

    marshalColorMaterialParameter :: ColorMaterialParameter -> GLenum
    marshalColorMaterialParameter :: ColorMaterialParameter -> GLenum
    marshalColorMaterialParameter ColorMaterialParameter
    x = case ColorMaterialParameter
    x of
       ColorMaterialParameter
    Ambient -> GLenum
    GL_AMBIENT
       ColorMaterialParameter
    Diffuse -> GLenum
    GL_DIFFUSE
       ColorMaterialParameter
    Specular -> GLenum
    GL_SPECULAR
       ColorMaterialParameter
    Emission -> GLenum
    GL_EMISSION
       ColorMaterialParameter
    AmbientAndDiffuse -> GLenum
    GL_AMBIENT_AND_DIFFUSE

    unmarshalColorMaterialParameter :: GLenum -> ColorMaterialParameter
    unmarshalColorMaterialParameter :: GLenum -> ColorMaterialParameter
    unmarshalColorMaterialParameter GLenum
    x
       | GLenum
    x GLenum -> GLenum -> Bool
    forall a. Eq a => a -> a -> Bool
    == GLenum
    GL_AMBIENT = ColorMaterialParameter
    Ambient
       | GLenum
    x GLenum -> GLenum -> Bool
    forall a. Eq a => a -> a -> Bool
    == GLenum
    GL_DIFFUSE = ColorMaterialParameter
    Diffuse
       | GLenum
    x GLenum -> GLenum -> Bool
    forall a. Eq a => a -> a -> Bool
    == GLenum
    GL_SPECULAR = ColorMaterialParameter
    Specular
       | GLenum
    x GLenum -> GLenum -> Bool
    forall a. Eq a => a -> a -> Bool
    == GLenum
    GL_EMISSION = ColorMaterialParameter
    Emission
       | GLenum
    x GLenum -> GLenum -> Bool
    forall a. Eq a => a -> a -> Bool
    == GLenum
    GL_AMBIENT_AND_DIFFUSE = ColorMaterialParameter
    AmbientAndDiffuse
       | Bool
    otherwise = String -> ColorMaterialParameter
    forall a. HasCallStack => String -> a
    error (String
    "unmarshalColorMaterialParameter: illegal value " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ GLenum -> String
    forall a. Show a => a -> String
    show GLenum
    x)

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

    colorMaterial :: StateVar (Maybe (Face, ColorMaterialParameter))
    colorMaterial :: StateVar (Maybe (Face, ColorMaterialParameter))
    colorMaterial =
       IO EnableCap
    -> IO (Face, ColorMaterialParameter)
    -> ((Face, ColorMaterialParameter) -> IO ())
    -> StateVar (Maybe (Face, ColorMaterialParameter))
    forall a.
    IO EnableCap -> IO a -> (a -> IO ()) -> StateVar (Maybe a)
    makeStateVarMaybe
          (EnableCap -> IO EnableCap
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return EnableCap
    CapColorMaterial)
          ((Face -> ColorMaterialParameter -> (Face, ColorMaterialParameter))
    -> IO Face
    -> IO ColorMaterialParameter
    -> IO (Face, ColorMaterialParameter)
    forall (m :: * -> *) a1 a2 r.
    Monad m =>
    (a1 -> a2 -> r) -> m a1 -> m a2 -> m r
    liftM2
             (,)
             ((GLenum -> Face) -> PName1I -> IO Face
    forall p a. GetPName1I p => (GLenum -> a) -> p -> IO a
    forall a. (GLenum -> a) -> PName1I -> IO a
    getEnum1 GLenum -> Face
    unmarshalFace PName1I
    GetColorMaterialFace)
             ((GLenum -> ColorMaterialParameter)
    -> PName1I -> IO ColorMaterialParameter
    forall p a. GetPName1I p => (GLenum -> a) -> p -> IO a
    forall a. (GLenum -> a) -> PName1I -> IO a
    getEnum1 GLenum -> ColorMaterialParameter
    unmarshalColorMaterialParameter PName1I
    GetColorMaterialParameter))
          (\(Face
    face, ColorMaterialParameter
    param) -> GLenum -> GLenum -> IO ()
    forall (m :: * -> *). MonadIO m => GLenum -> GLenum -> m ()
    glColorMaterial (Face -> GLenum
    marshalFace Face
    face)
                                             (ColorMaterialParameter -> GLenum
    marshalColorMaterialParameter ColorMaterialParameter
    param))

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

    data ShadingModel =
         Flat
       | Smooth
       deriving ( ShadingModel -> ShadingModel -> Bool
    (ShadingModel -> ShadingModel -> Bool)
    -> (ShadingModel -> ShadingModel -> Bool) -> Eq ShadingModel
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: ShadingModel -> ShadingModel -> Bool
    == :: ShadingModel -> ShadingModel -> Bool
    $c/= :: ShadingModel -> ShadingModel -> Bool
    /= :: ShadingModel -> ShadingModel -> Bool
    Eq, Eq ShadingModel
    Eq ShadingModel =>
    (ShadingModel -> ShadingModel -> Ordering)
    -> (ShadingModel -> ShadingModel -> Bool)
    -> (ShadingModel -> ShadingModel -> Bool)
    -> (ShadingModel -> ShadingModel -> Bool)
    -> (ShadingModel -> ShadingModel -> Bool)
    -> (ShadingModel -> ShadingModel -> ShadingModel)
    -> (ShadingModel -> ShadingModel -> ShadingModel)
    -> Ord ShadingModel
    ShadingModel -> ShadingModel -> Bool
    ShadingModel -> ShadingModel -> Ordering
    ShadingModel -> ShadingModel -> ShadingModel
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: ShadingModel -> ShadingModel -> Ordering
    compare :: ShadingModel -> ShadingModel -> Ordering
    $c< :: ShadingModel -> ShadingModel -> Bool
    < :: ShadingModel -> ShadingModel -> Bool
    $c<= :: ShadingModel -> ShadingModel -> Bool
    <= :: ShadingModel -> ShadingModel -> Bool
    $c> :: ShadingModel -> ShadingModel -> Bool
    > :: ShadingModel -> ShadingModel -> Bool
    $c>= :: ShadingModel -> ShadingModel -> Bool
    >= :: ShadingModel -> ShadingModel -> Bool
    $cmax :: ShadingModel -> ShadingModel -> ShadingModel
    max :: ShadingModel -> ShadingModel -> ShadingModel
    $cmin :: ShadingModel -> ShadingModel -> ShadingModel
    min :: ShadingModel -> ShadingModel -> ShadingModel
    Ord, Int -> ShadingModel -> ShowS
    [ShadingModel] -> ShowS
    ShadingModel -> String
    (Int -> ShadingModel -> ShowS)
    -> (ShadingModel -> String)
    -> ([ShadingModel] -> ShowS)
    -> Show ShadingModel
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> ShadingModel -> ShowS
    showsPrec :: Int -> ShadingModel -> ShowS
    $cshow :: ShadingModel -> String
    show :: ShadingModel -> String
    $cshowList :: [ShadingModel] -> ShowS
    showList :: [ShadingModel] -> ShowS
    Show )

    marshalShadingModel :: ShadingModel -> GLenum
    marshalShadingModel :: ShadingModel -> GLenum
    marshalShadingModel ShadingModel
    x = case ShadingModel
    x of
       ShadingModel
    Flat -> GLenum
    GL_FLAT
       ShadingModel
    Smooth -> GLenum
    GL_SMOOTH

    unmarshalShadingModel :: GLenum -> ShadingModel
    unmarshalShadingModel :: GLenum -> ShadingModel
    unmarshalShadingModel GLenum
    x
       | GLenum
    x GLenum -> GLenum -> Bool
    forall a. Eq a => a -> a -> Bool
    == GLenum
    GL_FLAT = ShadingModel
    Flat
       | GLenum
    x GLenum -> GLenum -> Bool
    forall a. Eq a => a -> a -> Bool
    == GLenum
    GL_SMOOTH = ShadingModel
    Smooth
       | Bool
    otherwise = String -> ShadingModel
    forall a. HasCallStack => String -> a
    error (String
    "unmarshalShadingModel: illegal value " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ GLenum -> String
    forall a. Show a => a -> String
    show GLenum
    x)

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

    shadeModel :: StateVar ShadingModel
    shadeModel :: StateVar ShadingModel
    shadeModel =
       IO ShadingModel -> (ShadingModel -> IO ()) -> StateVar ShadingModel
    forall a. IO a -> (a -> IO ()) -> StateVar a
    makeStateVar
          ((GLenum -> ShadingModel) -> PName1I -> IO ShadingModel
    forall p a. GetPName1I p => (GLenum -> a) -> p -> IO a
    forall a. (GLenum -> a) -> PName1I -> IO a
    getEnum1 GLenum -> ShadingModel
    unmarshalShadingModel PName1I
    GetShadeModel)
          (GLenum -> IO ()
    forall (m :: * -> *). MonadIO m => GLenum -> m ()
    glShadeModel (GLenum -> IO ())
    -> (ShadingModel -> GLenum) -> ShadingModel -> IO ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ShadingModel -> GLenum
    marshalShadingModel)

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

    data ClampTarget =
         ClampVertexColor
       | ClampFragmentColor
       | ClampReadColor
       deriving ( ClampTarget -> ClampTarget -> Bool
    (ClampTarget -> ClampTarget -> Bool)
    -> (ClampTarget -> ClampTarget -> Bool) -> Eq ClampTarget
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: ClampTarget -> ClampTarget -> Bool
    == :: ClampTarget -> ClampTarget -> Bool
    $c/= :: ClampTarget -> ClampTarget -> Bool
    /= :: ClampTarget -> ClampTarget -> Bool
    Eq, Eq ClampTarget
    Eq ClampTarget =>
    (ClampTarget -> ClampTarget -> Ordering)
    -> (ClampTarget -> ClampTarget -> Bool)
    -> (ClampTarget -> ClampTarget -> Bool)
    -> (ClampTarget -> ClampTarget -> Bool)
    -> (ClampTarget -> ClampTarget -> Bool)
    -> (ClampTarget -> ClampTarget -> ClampTarget)
    -> (ClampTarget -> ClampTarget -> ClampTarget)
    -> Ord ClampTarget
    ClampTarget -> ClampTarget -> Bool
    ClampTarget -> ClampTarget -> Ordering
    ClampTarget -> ClampTarget -> ClampTarget
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: ClampTarget -> ClampTarget -> Ordering
    compare :: ClampTarget -> ClampTarget -> Ordering
    $c< :: ClampTarget -> ClampTarget -> Bool
    < :: ClampTarget -> ClampTarget -> Bool
    $c<= :: ClampTarget -> ClampTarget -> Bool
    <= :: ClampTarget -> ClampTarget -> Bool
    $c> :: ClampTarget -> ClampTarget -> Bool
    > :: ClampTarget -> ClampTarget -> Bool
    $c>= :: ClampTarget -> ClampTarget -> Bool
    >= :: ClampTarget -> ClampTarget -> Bool
    $cmax :: ClampTarget -> ClampTarget -> ClampTarget
    max :: ClampTarget -> ClampTarget -> ClampTarget
    $cmin :: ClampTarget -> ClampTarget -> ClampTarget
    min :: ClampTarget -> ClampTarget -> ClampTarget
    Ord, Int -> ClampTarget -> ShowS
    [ClampTarget] -> ShowS
    ClampTarget -> String
    (Int -> ClampTarget -> ShowS)
    -> (ClampTarget -> String)
    -> ([ClampTarget] -> ShowS)
    -> Show ClampTarget
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> ClampTarget -> ShowS
    showsPrec :: Int -> ClampTarget -> ShowS
    $cshow :: ClampTarget -> String
    show :: ClampTarget -> String
    $cshowList :: [ClampTarget] -> ShowS
    showList :: [ClampTarget] -> ShowS
    Show )

    marshalClampTarget :: ClampTarget -> GLenum
    marshalClampTarget :: ClampTarget -> GLenum
    marshalClampTarget ClampTarget
    x = case ClampTarget
    x of
       ClampTarget
    ClampVertexColor -> GLenum
    GL_CLAMP_VERTEX_COLOR
       ClampTarget
    ClampFragmentColor -> GLenum
    GL_CLAMP_FRAGMENT_COLOR
       ClampTarget
    ClampReadColor -> GLenum
    GL_CLAMP_READ_COLOR

    marshalClampTargetToPName :: ClampTarget -> PName1I
    marshalClampTargetToPName :: ClampTarget -> PName1I
    marshalClampTargetToPName ClampTarget
    x = case ClampTarget
    x of
       ClampTarget
    ClampFragmentColor -> PName1I
    GetFragmentColorClamp
       ClampTarget
    ClampVertexColor -> PName1I
    GetVertexColorClamp
       ClampTarget
    ClampReadColor -> PName1I
    GetReadColorClamp

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

    data ClampMode =
         ClampOn
       | FixedOnly
       | ClampOff
       deriving ( ClampMode -> ClampMode -> Bool
    (ClampMode -> ClampMode -> Bool)
    -> (ClampMode -> ClampMode -> Bool) -> Eq ClampMode
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: ClampMode -> ClampMode -> Bool
    == :: ClampMode -> ClampMode -> Bool
    $c/= :: ClampMode -> ClampMode -> Bool
    /= :: ClampMode -> ClampMode -> Bool
    Eq, Eq ClampMode
    Eq ClampMode =>
    (ClampMode -> ClampMode -> Ordering)
    -> (ClampMode -> ClampMode -> Bool)
    -> (ClampMode -> ClampMode -> Bool)
    -> (ClampMode -> ClampMode -> Bool)
    -> (ClampMode -> ClampMode -> Bool)
    -> (ClampMode -> ClampMode -> ClampMode)
    -> (ClampMode -> ClampMode -> ClampMode)
    -> Ord ClampMode
    ClampMode -> ClampMode -> Bool
    ClampMode -> ClampMode -> Ordering
    ClampMode -> ClampMode -> ClampMode
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: ClampMode -> ClampMode -> Ordering
    compare :: ClampMode -> ClampMode -> Ordering
    $c< :: ClampMode -> ClampMode -> Bool
    < :: ClampMode -> ClampMode -> Bool
    $c<= :: ClampMode -> ClampMode -> Bool
    <= :: ClampMode -> ClampMode -> Bool
    $c> :: ClampMode -> ClampMode -> Bool
    > :: ClampMode -> ClampMode -> Bool
    $c>= :: ClampMode -> ClampMode -> Bool
    >= :: ClampMode -> ClampMode -> Bool
    $cmax :: ClampMode -> ClampMode -> ClampMode
    max :: ClampMode -> ClampMode -> ClampMode
    $cmin :: ClampMode -> ClampMode -> ClampMode
    min :: ClampMode -> ClampMode -> ClampMode
    Ord, Int -> ClampMode -> ShowS
    [ClampMode] -> ShowS
    ClampMode -> String
    (Int -> ClampMode -> ShowS)
    -> (ClampMode -> String)
    -> ([ClampMode] -> ShowS)
    -> Show ClampMode
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> ClampMode -> ShowS
    showsPrec :: Int -> ClampMode -> ShowS
    $cshow :: ClampMode -> String
    show :: ClampMode -> String
    $cshowList :: [ClampMode] -> ShowS
    showList :: [ClampMode] -> ShowS
    Show )

    marshalClampMode :: ClampMode -> GLenum
    marshalClampMode :: ClampMode -> GLenum
    marshalClampMode ClampMode
    x = case ClampMode
    x of
       ClampMode
    ClampOn -> GLboolean -> GLenum
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral GLboolean
    GL_TRUE
       ClampMode
    FixedOnly -> GLenum
    GL_FIXED_ONLY
       ClampMode
    ClampOff -> GLboolean -> GLenum
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral GLboolean
    GL_FALSE

    unmarshalClampMode :: GLenum -> ClampMode
    unmarshalClampMode :: GLenum -> ClampMode
    unmarshalClampMode GLenum
    x
       | GLenum
    x GLenum -> GLenum -> Bool
    forall a. Eq a => a -> a -> Bool
    == GLboolean -> GLenum
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral GLboolean
    GL_TRUE = ClampMode
    ClampOn
       | GLenum
    x GLenum -> GLenum -> Bool
    forall a. Eq a => a -> a -> Bool
    == GLenum
    GL_FIXED_ONLY = ClampMode
    FixedOnly
       | GLenum
    x GLenum -> GLenum -> Bool
    forall a. Eq a => a -> a -> Bool
    == GLboolean -> GLenum
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral GLboolean
    GL_FALSE = ClampMode
    ClampOff
       | Bool
    otherwise = String -> ClampMode
    forall a. HasCallStack => String -> a
    error (String -> ClampMode) -> String -> ClampMode
    forall a b. (a -> b) -> a -> b
    $ String
    "unmarshalClampMode: unknown enum value " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ GLenum -> String
    forall a. Show a => a -> String
    show GLenum
    x

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

    clampColor :: ClampTarget -> StateVar ClampMode
    clampColor :: ClampTarget -> StateVar ClampMode
    clampColor ClampTarget
    ct = IO ClampMode -> (ClampMode -> IO ()) -> StateVar ClampMode
    forall a. IO a -> (a -> IO ()) -> StateVar a
    makeStateVar (ClampTarget -> IO ClampMode
    getClampColor ClampTarget
    ct) (ClampTarget -> ClampMode -> IO ()
    forall {m :: * -> *}. MonadIO m => ClampTarget -> ClampMode -> m ()
    setClampColor ClampTarget
    ct)
       where getClampColor :: ClampTarget -> IO ClampMode
    getClampColor = (GLenum -> ClampMode) -> PName1I -> IO ClampMode
    forall p a. GetPName1I p => (GLenum -> a) -> p -> IO a
    forall a. (GLenum -> a) -> PName1I -> IO a
    getEnum1 GLenum -> ClampMode
    unmarshalClampMode (PName1I -> IO ClampMode)
    -> (ClampTarget -> PName1I) -> ClampTarget -> IO ClampMode
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ClampTarget -> PName1I
    marshalClampTargetToPName
             setClampColor :: ClampTarget -> ClampMode -> m ()
    setClampColor ClampTarget
    t = GLenum -> GLenum -> m ()
    forall (m :: * -> *). MonadIO m => GLenum -> GLenum -> m ()
    glClampColor (ClampTarget -> GLenum
    marshalClampTarget ClampTarget
    t) (GLenum -> m ()) -> (ClampMode -> GLenum) -> ClampMode -> m ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ClampMode -> GLenum
    marshalClampMode