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

    module Graphics.Rendering.OpenGL.GL.Fog (
       fog,
       FogMode(..), fogMode,
       fogColor, fogIndex,
       FogCoordSrc(..), fogCoordSrc,
       FogDistanceMode(..), fogDistanceMode
    ) where

    import Data.StateVar
    import Foreign.Marshal.Utils
    import Foreign.Ptr
    import Graphics.Rendering.OpenGL.GL.Capability
    import Graphics.Rendering.OpenGL.GL.QueryUtils
    import Graphics.Rendering.OpenGL.GL.VertexSpec
    import Graphics.GL

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

    fog :: StateVar Capability
    fog :: StateVar Capability
    fog = EnableCap -> StateVar Capability
    makeCapability EnableCap
    CapFog

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

    data FogParameter =
         FogIndex
       | FogDensity
       | FogStart
       | FogEnd
       | FogMode
       | FogColor
       | FogCoordSrc
       | FogDistanceMode

    marshalFogParameter :: FogParameter -> GLenum
    marshalFogParameter :: FogParameter -> GLenum
    marshalFogParameter FogParameter
    x = case FogParameter
    x of
       FogParameter
    FogIndex -> GLenum
    GL_FOG_INDEX
       FogParameter
    FogDensity -> GLenum
    GL_FOG_DENSITY
       FogParameter
    FogStart -> GLenum
    GL_FOG_START
       FogParameter
    FogEnd -> GLenum
    GL_FOG_END
       FogParameter
    FogMode -> GLenum
    GL_FOG_MODE
       FogParameter
    FogColor -> GLenum
    GL_FOG_COLOR
       FogParameter
    FogCoordSrc -> GLenum
    GL_FOG_COORD_SRC
       FogParameter
    FogDistanceMode -> GLenum
    GL_FOG_DISTANCE_MODE_NV

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

    data FogMode' =
         Linear'
       | Exp'
       | Exp2'

    marshalFogMode' :: FogMode' -> GLint
    marshalFogMode' :: FogMode' -> GLint
    marshalFogMode' FogMode'
    x = GLenum -> GLint
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral (GLenum -> GLint) -> GLenum -> GLint
    forall a b. (a -> b) -> a -> b
    $ case FogMode'
    x of
       FogMode'
    Linear' -> GLenum
    GL_LINEAR
       FogMode'
    Exp' -> GLenum
    GL_EXP
       FogMode'
    Exp2' -> GLenum
    GL_EXP2

    unmarshalFogMode' :: GLint -> FogMode'
    unmarshalFogMode' :: GLint -> FogMode'
    unmarshalFogMode' GLint
    x
       | GLenum
    y GLenum -> GLenum -> Bool
    forall a. Eq a => a -> a -> Bool
    == GLenum
    GL_LINEAR = FogMode'
    Linear'
       | GLenum
    y GLenum -> GLenum -> Bool
    forall a. Eq a => a -> a -> Bool
    == GLenum
    GL_EXP = FogMode'
    Exp'
       | GLenum
    y GLenum -> GLenum -> Bool
    forall a. Eq a => a -> a -> Bool
    == GLenum
    GL_EXP2 = FogMode'
    Exp2'
       | Bool
    otherwise = [Char] -> FogMode'
    forall a. HasCallStack => [Char] -> a
    error ([Char]
    "unmarshalFogMode': illegal value " [Char] -> [Char] -> [Char]
    forall a. [a] -> [a] -> [a]
    ++ GLint -> [Char]
    forall a. Show a => a -> [Char]
    show GLint
    x)
       where y :: GLenum
    y = GLint -> GLenum
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral GLint
    x

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

    data FogMode =
         Linear GLfloat GLfloat
       | Exp GLfloat
       | Exp2 GLfloat
       deriving ( FogMode -> FogMode -> Bool
    (FogMode -> FogMode -> Bool)
    -> (FogMode -> FogMode -> Bool) -> Eq FogMode
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: FogMode -> FogMode -> Bool
    == :: FogMode -> FogMode -> Bool
    $c/= :: FogMode -> FogMode -> Bool
    /= :: FogMode -> FogMode -> Bool
    Eq, Eq FogMode
    Eq FogMode =>
    (FogMode -> FogMode -> Ordering)
    -> (FogMode -> FogMode -> Bool)
    -> (FogMode -> FogMode -> Bool)
    -> (FogMode -> FogMode -> Bool)
    -> (FogMode -> FogMode -> Bool)
    -> (FogMode -> FogMode -> FogMode)
    -> (FogMode -> FogMode -> FogMode)
    -> Ord FogMode
    FogMode -> FogMode -> Bool
    FogMode -> FogMode -> Ordering
    FogMode -> FogMode -> FogMode
    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 :: FogMode -> FogMode -> Ordering
    compare :: FogMode -> FogMode -> Ordering
    $c< :: FogMode -> FogMode -> Bool
    < :: FogMode -> FogMode -> Bool
    $c<= :: FogMode -> FogMode -> Bool
    <= :: FogMode -> FogMode -> Bool
    $c> :: FogMode -> FogMode -> Bool
    > :: FogMode -> FogMode -> Bool
    $c>= :: FogMode -> FogMode -> Bool
    >= :: FogMode -> FogMode -> Bool
    $cmax :: FogMode -> FogMode -> FogMode
    max :: FogMode -> FogMode -> FogMode
    $cmin :: FogMode -> FogMode -> FogMode
    min :: FogMode -> FogMode -> FogMode
    Ord, Int -> FogMode -> [Char] -> [Char]
    [FogMode] -> [Char] -> [Char]
    FogMode -> [Char]
    (Int -> FogMode -> [Char] -> [Char])
    -> (FogMode -> [Char])
    -> ([FogMode] -> [Char] -> [Char])
    -> Show FogMode
    forall a.
    (Int -> a -> [Char] -> [Char])
    -> (a -> [Char]) -> ([a] -> [Char] -> [Char]) -> Show a
    $cshowsPrec :: Int -> FogMode -> [Char] -> [Char]
    showsPrec :: Int -> FogMode -> [Char] -> [Char]
    $cshow :: FogMode -> [Char]
    show :: FogMode -> [Char]
    $cshowList :: [FogMode] -> [Char] -> [Char]
    showList :: [FogMode] -> [Char] -> [Char]
    Show )

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

    fogMode :: StateVar FogMode
    fogMode :: StateVar FogMode
    fogMode = IO FogMode -> (FogMode -> IO ()) -> StateVar FogMode
    forall a. IO a -> (a -> IO ()) -> StateVar a
    makeStateVar IO FogMode
    getFogMode FogMode -> IO ()
    setFogMode

    getFogMode :: IO FogMode
    getFogMode :: IO FogMode
    getFogMode = do
       mode <- (GLint -> FogMode') -> PName1I -> IO FogMode'
    forall p a. GetPName1I p => (GLint -> a) -> p -> IO a
    forall a. (GLint -> a) -> PName1I -> IO a
    getInteger1 GLint -> FogMode'
    unmarshalFogMode' PName1I
    GetFogMode
       case mode of
          FogMode'
    Linear' -> do
             start <- (GLclampf -> GLclampf) -> PName1F -> IO GLclampf
    forall p a. GetPName1F p => (GLclampf -> a) -> p -> IO a
    forall a. (GLclampf -> a) -> PName1F -> IO a
    getFloat1 GLclampf -> GLclampf
    forall a. a -> a
    id PName1F
    GetFogStart
             end <- getFloat1 id GetFogEnd
             return $ Linear start end
          FogMode'
    Exp' -> (GLclampf -> FogMode) -> PName1F -> IO FogMode
    forall p a. GetPName1F p => (GLclampf -> a) -> p -> IO a
    forall a. (GLclampf -> a) -> PName1F -> IO a
    getFloat1 GLclampf -> FogMode
    Exp PName1F
    GetFogDensity
          FogMode'
    Exp2' -> (GLclampf -> FogMode) -> PName1F -> IO FogMode
    forall p a. GetPName1F p => (GLclampf -> a) -> p -> IO a
    forall a. (GLclampf -> a) -> PName1F -> IO a
    getFloat1 GLclampf -> FogMode
    Exp2 PName1F
    GetFogDensity

    setFogMode :: FogMode -> IO ()
    setFogMode :: FogMode -> IO ()
    setFogMode (Linear GLclampf
    start GLclampf
    end) = do
       FogParameter -> GLint -> IO ()
    fogi FogParameter
    FogMode (FogMode' -> GLint
    marshalFogMode' FogMode'
    Linear')
       FogParameter -> GLclampf -> IO ()
    fogf FogParameter
    FogStart GLclampf
    start
       FogParameter -> GLclampf -> IO ()
    fogf FogParameter
    FogEnd GLclampf
    end
    setFogMode (Exp GLclampf
    density) = do
       FogParameter -> GLint -> IO ()
    fogi FogParameter
    FogMode (FogMode' -> GLint
    marshalFogMode' FogMode'
    Exp')
       FogParameter -> GLclampf -> IO ()
    fogf FogParameter
    FogDensity GLclampf
    density
    setFogMode (Exp2 GLclampf
    density) = do
       FogParameter -> GLint -> IO ()
    fogi FogParameter
    FogMode (FogMode' -> GLint
    marshalFogMode' FogMode'
    Exp2')
       FogParameter -> GLclampf -> IO ()
    fogf FogParameter
    FogDensity GLclampf
    density

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

    fogi :: FogParameter -> GLint -> IO ()
    fogi :: FogParameter -> GLint -> IO ()
    fogi = GLenum -> GLint -> IO ()
    forall (m :: * -> *). MonadIO m => GLenum -> GLint -> m ()
    glFogi (GLenum -> GLint -> IO ())
    -> (FogParameter -> GLenum) -> FogParameter -> GLint -> IO ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . FogParameter -> GLenum
    marshalFogParameter

    fogf :: FogParameter -> GLfloat -> IO ()
    fogf :: FogParameter -> GLclampf -> IO ()
    fogf = GLenum -> GLclampf -> IO ()
    forall (m :: * -> *). MonadIO m => GLenum -> GLclampf -> m ()
    glFogf (GLenum -> GLclampf -> IO ())
    -> (FogParameter -> GLenum) -> FogParameter -> GLclampf -> IO ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . FogParameter -> GLenum
    marshalFogParameter

    fogfv :: FogParameter -> Ptr (Color4 GLfloat) -> IO ()
    fogfv :: FogParameter -> Ptr (Color4 GLclampf) -> IO ()
    fogfv FogParameter
    param Ptr (Color4 GLclampf)
    ptr = GLenum -> Ptr GLclampf -> IO ()
    forall (m :: * -> *). MonadIO m => GLenum -> Ptr GLclampf -> m ()
    glFogfv (FogParameter -> GLenum
    marshalFogParameter FogParameter
    param) (Ptr (Color4 GLclampf) -> Ptr GLclampf
    forall a b. Ptr a -> Ptr b
    castPtr Ptr (Color4 GLclampf)
    ptr)

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

    fogColor :: StateVar (Color4 GLclampf)
    fogColor :: StateVar (Color4 GLclampf)
    fogColor =
       IO (Color4 GLclampf)
    -> (Color4 GLclampf -> IO ()) -> StateVar (Color4 GLclampf)
    forall a. IO a -> (a -> IO ()) -> StateVar a
    makeStateVar
          ((GLclampf -> GLclampf -> GLclampf -> GLclampf -> Color4 GLclampf)
    -> PName4F -> IO (Color4 GLclampf)
    forall p a.
    GetPName4F p =>
    (GLclampf -> GLclampf -> GLclampf -> GLclampf -> a) -> p -> IO a
    forall a.
    (GLclampf -> GLclampf -> GLclampf -> GLclampf -> a)
    -> PName4F -> IO a
    getClampf4 GLclampf -> GLclampf -> GLclampf -> GLclampf -> Color4 GLclampf
    forall a. a -> a -> a -> a -> Color4 a
    Color4 PName4F
    GetFogColor)
          (\Color4 GLclampf
    c -> Color4 GLclampf -> (Ptr (Color4 GLclampf) -> IO ()) -> IO ()
    forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
    with Color4 GLclampf
    c ((Ptr (Color4 GLclampf) -> IO ()) -> IO ())
    -> (Ptr (Color4 GLclampf) -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ (FogParameter -> Ptr (Color4 GLclampf) -> IO ()
    fogfv FogParameter
    FogColor (Ptr (Color4 GLclampf) -> IO ())
    -> (Ptr (Color4 GLclampf) -> Ptr (Color4 GLclampf))
    -> Ptr (Color4 GLclampf)
    -> IO ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Ptr (Color4 GLclampf) -> Ptr (Color4 GLclampf)
    forall a b. Ptr a -> Ptr b
    castPtr))

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

    fogIndex :: StateVar (Index1 GLint)
    fogIndex :: StateVar (Index1 GLint)
    fogIndex =
       IO (Index1 GLint)
    -> (Index1 GLint -> IO ()) -> StateVar (Index1 GLint)
    forall a. IO a -> (a -> IO ()) -> StateVar a
    makeStateVar
          ((GLint -> Index1 GLint) -> PName1I -> IO (Index1 GLint)
    forall p a. GetPName1I p => (GLint -> a) -> p -> IO a
    forall a. (GLint -> a) -> PName1I -> IO a
    getInteger1 GLint -> Index1 GLint
    forall a. a -> Index1 a
    Index1 PName1I
    GetFogIndex)
          (\(Index1 GLint
    i) -> FogParameter -> GLint -> IO ()
    fogi FogParameter
    FogIndex GLint
    i)

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

    data FogCoordSrc =
         FogCoord
       | FragmentDepth
       deriving ( FogCoordSrc -> FogCoordSrc -> Bool
    (FogCoordSrc -> FogCoordSrc -> Bool)
    -> (FogCoordSrc -> FogCoordSrc -> Bool) -> Eq FogCoordSrc
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: FogCoordSrc -> FogCoordSrc -> Bool
    == :: FogCoordSrc -> FogCoordSrc -> Bool
    $c/= :: FogCoordSrc -> FogCoordSrc -> Bool
    /= :: FogCoordSrc -> FogCoordSrc -> Bool
    Eq, Eq FogCoordSrc
    Eq FogCoordSrc =>
    (FogCoordSrc -> FogCoordSrc -> Ordering)
    -> (FogCoordSrc -> FogCoordSrc -> Bool)
    -> (FogCoordSrc -> FogCoordSrc -> Bool)
    -> (FogCoordSrc -> FogCoordSrc -> Bool)
    -> (FogCoordSrc -> FogCoordSrc -> Bool)
    -> (FogCoordSrc -> FogCoordSrc -> FogCoordSrc)
    -> (FogCoordSrc -> FogCoordSrc -> FogCoordSrc)
    -> Ord FogCoordSrc
    FogCoordSrc -> FogCoordSrc -> Bool
    FogCoordSrc -> FogCoordSrc -> Ordering
    FogCoordSrc -> FogCoordSrc -> FogCoordSrc
    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 :: FogCoordSrc -> FogCoordSrc -> Ordering
    compare :: FogCoordSrc -> FogCoordSrc -> Ordering
    $c< :: FogCoordSrc -> FogCoordSrc -> Bool
    < :: FogCoordSrc -> FogCoordSrc -> Bool
    $c<= :: FogCoordSrc -> FogCoordSrc -> Bool
    <= :: FogCoordSrc -> FogCoordSrc -> Bool
    $c> :: FogCoordSrc -> FogCoordSrc -> Bool
    > :: FogCoordSrc -> FogCoordSrc -> Bool
    $c>= :: FogCoordSrc -> FogCoordSrc -> Bool
    >= :: FogCoordSrc -> FogCoordSrc -> Bool
    $cmax :: FogCoordSrc -> FogCoordSrc -> FogCoordSrc
    max :: FogCoordSrc -> FogCoordSrc -> FogCoordSrc
    $cmin :: FogCoordSrc -> FogCoordSrc -> FogCoordSrc
    min :: FogCoordSrc -> FogCoordSrc -> FogCoordSrc
    Ord, Int -> FogCoordSrc -> [Char] -> [Char]
    [FogCoordSrc] -> [Char] -> [Char]
    FogCoordSrc -> [Char]
    (Int -> FogCoordSrc -> [Char] -> [Char])
    -> (FogCoordSrc -> [Char])
    -> ([FogCoordSrc] -> [Char] -> [Char])
    -> Show FogCoordSrc
    forall a.
    (Int -> a -> [Char] -> [Char])
    -> (a -> [Char]) -> ([a] -> [Char] -> [Char]) -> Show a
    $cshowsPrec :: Int -> FogCoordSrc -> [Char] -> [Char]
    showsPrec :: Int -> FogCoordSrc -> [Char] -> [Char]
    $cshow :: FogCoordSrc -> [Char]
    show :: FogCoordSrc -> [Char]
    $cshowList :: [FogCoordSrc] -> [Char] -> [Char]
    showList :: [FogCoordSrc] -> [Char] -> [Char]
    Show )

    marshalFogCoordSrc :: FogCoordSrc -> GLint
    marshalFogCoordSrc :: FogCoordSrc -> GLint
    marshalFogCoordSrc FogCoordSrc
    x = GLenum -> GLint
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral (GLenum -> GLint) -> GLenum -> GLint
    forall a b. (a -> b) -> a -> b
    $ case FogCoordSrc
    x of
       FogCoordSrc
    FogCoord -> GLenum
    GL_FOG_COORD
       FogCoordSrc
    FragmentDepth -> GLenum
    GL_FRAGMENT_DEPTH

    unmarshalFogCoordSrc :: GLint -> FogCoordSrc
    unmarshalFogCoordSrc :: GLint -> FogCoordSrc
    unmarshalFogCoordSrc GLint
    x
       | GLenum
    y GLenum -> GLenum -> Bool
    forall a. Eq a => a -> a -> Bool
    == GLenum
    GL_FOG_COORD = FogCoordSrc
    FogCoord
       | GLenum
    y GLenum -> GLenum -> Bool
    forall a. Eq a => a -> a -> Bool
    == GLenum
    GL_FRAGMENT_DEPTH = FogCoordSrc
    FragmentDepth
       | Bool
    otherwise = [Char] -> FogCoordSrc
    forall a. HasCallStack => [Char] -> a
    error ([Char]
    "unmarshalFogCoordSrc: illegal value " [Char] -> [Char] -> [Char]
    forall a. [a] -> [a] -> [a]
    ++ GLint -> [Char]
    forall a. Show a => a -> [Char]
    show GLint
    x)
       where y :: GLenum
    y = GLint -> GLenum
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral GLint
    x

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

    fogCoordSrc :: StateVar FogCoordSrc
    fogCoordSrc :: StateVar FogCoordSrc
    fogCoordSrc =
       IO FogCoordSrc -> (FogCoordSrc -> IO ()) -> StateVar FogCoordSrc
    forall a. IO a -> (a -> IO ()) -> StateVar a
    makeStateVar
          ((GLint -> FogCoordSrc) -> PName1I -> IO FogCoordSrc
    forall p a. GetPName1I p => (GLint -> a) -> p -> IO a
    forall a. (GLint -> a) -> PName1I -> IO a
    getInteger1 GLint -> FogCoordSrc
    unmarshalFogCoordSrc PName1I
    GetFogCoordSrc)
          (FogParameter -> GLint -> IO ()
    fogi FogParameter
    FogCoordSrc (GLint -> IO ()) -> (FogCoordSrc -> GLint) -> FogCoordSrc -> IO ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . FogCoordSrc -> GLint
    marshalFogCoordSrc)

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

    data FogDistanceMode =
         EyeRadial
       | EyePlaneSigned
       | EyePlaneAbsolute
       deriving ( FogDistanceMode -> FogDistanceMode -> Bool
    (FogDistanceMode -> FogDistanceMode -> Bool)
    -> (FogDistanceMode -> FogDistanceMode -> Bool)
    -> Eq FogDistanceMode
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: FogDistanceMode -> FogDistanceMode -> Bool
    == :: FogDistanceMode -> FogDistanceMode -> Bool
    $c/= :: FogDistanceMode -> FogDistanceMode -> Bool
    /= :: FogDistanceMode -> FogDistanceMode -> Bool
    Eq, Eq FogDistanceMode
    Eq FogDistanceMode =>
    (FogDistanceMode -> FogDistanceMode -> Ordering)
    -> (FogDistanceMode -> FogDistanceMode -> Bool)
    -> (FogDistanceMode -> FogDistanceMode -> Bool)
    -> (FogDistanceMode -> FogDistanceMode -> Bool)
    -> (FogDistanceMode -> FogDistanceMode -> Bool)
    -> (FogDistanceMode -> FogDistanceMode -> FogDistanceMode)
    -> (FogDistanceMode -> FogDistanceMode -> FogDistanceMode)
    -> Ord FogDistanceMode
    FogDistanceMode -> FogDistanceMode -> Bool
    FogDistanceMode -> FogDistanceMode -> Ordering
    FogDistanceMode -> FogDistanceMode -> FogDistanceMode
    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 :: FogDistanceMode -> FogDistanceMode -> Ordering
    compare :: FogDistanceMode -> FogDistanceMode -> Ordering
    $c< :: FogDistanceMode -> FogDistanceMode -> Bool
    < :: FogDistanceMode -> FogDistanceMode -> Bool
    $c<= :: FogDistanceMode -> FogDistanceMode -> Bool
    <= :: FogDistanceMode -> FogDistanceMode -> Bool
    $c> :: FogDistanceMode -> FogDistanceMode -> Bool
    > :: FogDistanceMode -> FogDistanceMode -> Bool
    $c>= :: FogDistanceMode -> FogDistanceMode -> Bool
    >= :: FogDistanceMode -> FogDistanceMode -> Bool
    $cmax :: FogDistanceMode -> FogDistanceMode -> FogDistanceMode
    max :: FogDistanceMode -> FogDistanceMode -> FogDistanceMode
    $cmin :: FogDistanceMode -> FogDistanceMode -> FogDistanceMode
    min :: FogDistanceMode -> FogDistanceMode -> FogDistanceMode
    Ord, Int -> FogDistanceMode -> [Char] -> [Char]
    [FogDistanceMode] -> [Char] -> [Char]
    FogDistanceMode -> [Char]
    (Int -> FogDistanceMode -> [Char] -> [Char])
    -> (FogDistanceMode -> [Char])
    -> ([FogDistanceMode] -> [Char] -> [Char])
    -> Show FogDistanceMode
    forall a.
    (Int -> a -> [Char] -> [Char])
    -> (a -> [Char]) -> ([a] -> [Char] -> [Char]) -> Show a
    $cshowsPrec :: Int -> FogDistanceMode -> [Char] -> [Char]
    showsPrec :: Int -> FogDistanceMode -> [Char] -> [Char]
    $cshow :: FogDistanceMode -> [Char]
    show :: FogDistanceMode -> [Char]
    $cshowList :: [FogDistanceMode] -> [Char] -> [Char]
    showList :: [FogDistanceMode] -> [Char] -> [Char]
    Show )

    marshalFogDistanceMode :: FogDistanceMode -> GLint
    marshalFogDistanceMode :: FogDistanceMode -> GLint
    marshalFogDistanceMode FogDistanceMode
    x = GLenum -> GLint
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral (GLenum -> GLint) -> GLenum -> GLint
    forall a b. (a -> b) -> a -> b
    $ case FogDistanceMode
    x of
       FogDistanceMode
    EyeRadial -> GLenum
    GL_EYE_RADIAL_NV
       FogDistanceMode
    EyePlaneSigned -> GLenum
    GL_EYE_PLANE
       FogDistanceMode
    EyePlaneAbsolute -> GLenum
    GL_EYE_PLANE_ABSOLUTE_NV

    unmarshalFogDistanceMode :: GLint -> FogDistanceMode
    unmarshalFogDistanceMode :: GLint -> FogDistanceMode
    unmarshalFogDistanceMode GLint
    x
       | GLenum
    y GLenum -> GLenum -> Bool
    forall a. Eq a => a -> a -> Bool
    == GLenum
    GL_EYE_RADIAL_NV = FogDistanceMode
    EyeRadial
       | GLenum
    y GLenum -> GLenum -> Bool
    forall a. Eq a => a -> a -> Bool
    == GLenum
    GL_EYE_PLANE = FogDistanceMode
    EyePlaneSigned
       | GLenum
    y GLenum -> GLenum -> Bool
    forall a. Eq a => a -> a -> Bool
    == GLenum
    GL_EYE_PLANE_ABSOLUTE_NV = FogDistanceMode
    EyePlaneAbsolute
       | Bool
    otherwise = [Char] -> FogDistanceMode
    forall a. HasCallStack => [Char] -> a
    error ([Char]
    "unmarshalFogDistanceMode: illegal value " [Char] -> [Char] -> [Char]
    forall a. [a] -> [a] -> [a]
    ++ GLint -> [Char]
    forall a. Show a => a -> [Char]
    show GLint
    x)
       where y :: GLenum
    y = GLint -> GLenum
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral GLint
    x

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

    fogDistanceMode :: StateVar FogDistanceMode
    fogDistanceMode :: StateVar FogDistanceMode
    fogDistanceMode =
       IO FogDistanceMode
    -> (FogDistanceMode -> IO ()) -> StateVar FogDistanceMode
    forall a. IO a -> (a -> IO ()) -> StateVar a
    makeStateVar
          ((GLint -> FogDistanceMode) -> PName1I -> IO FogDistanceMode
    forall p a. GetPName1I p => (GLint -> a) -> p -> IO a
    forall a. (GLint -> a) -> PName1I -> IO a
    getInteger1 GLint -> FogDistanceMode
    unmarshalFogDistanceMode PName1I
    GetFogDistanceMode)
          (FogParameter -> GLint -> IO ()
    fogi FogParameter
    FogDistanceMode (GLint -> IO ())
    -> (FogDistanceMode -> GLint) -> FogDistanceMode -> IO ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . FogDistanceMode -> GLint
    marshalFogDistanceMode)