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

    module Graphics.Rendering.OpenGL.GL.Framebuffer (
       -- * Selecting a Buffer for Writing
       BufferMode(..),
       drawBuffer, namedFramebufferDrawBuffer,
       drawBuffers, namedFramebufferDrawBuffers,
       DrawBufferIndex, drawBufferi,
       maxDrawBuffers,

       -- * Fine Control of Buffer Updates
       indexMask, colorMask, colorMaski, depthMask,
       stencilMask, stencilMaskSeparate,

       -- * Clearing the Buffers
       ClearBuffer(..), clear,
       clearColor, clearIndex, clearDepth, clearDepthf, clearStencil, clearAccum,

       ClearBufferCommand(..), clearBuffer, clearNamedFramebuffer,

       -- * Invalidating Framebuffer Contents
       invalidateSubFramebuffer, invalidateNamedFramebufferSubData,
       invalidateFramebuffer, invalidateNamedFramebufferData,

       -- * The Accumulation Buffer
       AccumOp(..), accum,

       -- * Querying the Buffer Configuration
       auxBuffers, doubleBuffer, stereoBuffer,
       rgbaBits, stencilBits, depthBits, accumBits, rgbaSignedComponents,
    ) where

    import Control.Monad
    import Data.Maybe
    import Data.StateVar
    import Foreign.Marshal.Array
    import Foreign.Marshal.Utils
    import Foreign.Ptr
    import Graphics.Rendering.OpenGL.GL.BufferMode
    import Graphics.Rendering.OpenGL.GL.Capability
    import Graphics.Rendering.OpenGL.GL.CoordTrans
    import Graphics.Rendering.OpenGL.GL.Face
    import Graphics.Rendering.OpenGL.GL.FramebufferObjects.FramebufferObject
    import Graphics.Rendering.OpenGL.GL.FramebufferObjects.FramebufferObjectAttachment
    import Graphics.Rendering.OpenGL.GL.FramebufferObjects.FramebufferTarget
    import Graphics.Rendering.OpenGL.GL.GLboolean
    import Graphics.Rendering.OpenGL.GL.QueryUtils
    import Graphics.Rendering.OpenGL.GL.VertexSpec
    import Graphics.Rendering.OpenGL.GLU.ErrorsInternal
    import Graphics.GL

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

    -- | When colors are written to the framebuffer, they are written into the color
    -- buffers specified by 'drawBuffer'.
    --
    -- If more than one color buffer is selected for drawing, then blending or
    -- logical operations are computed and applied independently for each color
    -- buffer and can produce different results in each buffer.
    --
    -- Monoscopic contexts include only left buffers, and stereoscopic contexts
    -- include both left and right buffers. Likewise, single-buffered contexts
    -- include only front buffers, and double-buffered contexts include both front
    -- and back buffers. The context is selected at GL initialization.
    --
    -- The initial value is 'FrontBuffers' for single-buffered contexts, and
    -- 'BackBuffers' for double-buffered contexts.

    drawBuffer :: StateVar BufferMode
    drawBuffer :: StateVar BufferMode
    drawBuffer = IO BufferMode -> (BufferMode -> IO ()) -> StateVar BufferMode
    forall a. IO a -> (a -> IO ()) -> StateVar a
    makeStateVar IO BufferMode
    getDrawBuffer BufferMode -> IO ()
    setDrawBuffer

    getDrawBuffer :: IO BufferMode
    getDrawBuffer :: IO BufferMode
    getDrawBuffer = GLint -> IO BufferMode
    getDrawBufferi GLint
    0

    setDrawBuffer :: BufferMode -> IO ()
    setDrawBuffer :: BufferMode -> IO ()
    setDrawBuffer BufferMode
    mode =
       [BufferMode] -> ([GLenum] -> IO ()) -> IO ()
    withBufferModes [BufferMode
    mode] (([GLenum] -> IO ()) -> IO ()) -> ([GLenum] -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \[GLenum
    m] ->
          GLenum -> IO ()
    forall (m :: * -> *). MonadIO m => GLenum -> m ()
    glDrawBuffer GLenum
    m

    -- | The direct-state-access version of 'drawBuffer'.

    namedFramebufferDrawBuffer :: FramebufferObject -> SettableStateVar BufferMode
    namedFramebufferDrawBuffer :: FramebufferObject -> SettableStateVar BufferMode
    namedFramebufferDrawBuffer FramebufferObject
    fbo =
       (BufferMode -> IO ()) -> SettableStateVar BufferMode
    forall a. (a -> IO ()) -> SettableStateVar a
    makeSettableStateVar ((BufferMode -> IO ()) -> SettableStateVar BufferMode)
    -> (BufferMode -> IO ()) -> SettableStateVar BufferMode
    forall a b. (a -> b) -> a -> b
    $ \BufferMode
    mode ->
          [BufferMode] -> ([GLenum] -> IO ()) -> IO ()
    withBufferModes [BufferMode
    mode] (([GLenum] -> IO ()) -> IO ()) -> ([GLenum] -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \[GLenum
    m] ->
             GLenum -> GLenum -> IO ()
    forall (m :: * -> *). MonadIO m => GLenum -> GLenum -> m ()
    glNamedFramebufferDrawBuffer (FramebufferObject -> GLenum
    framebufferID FramebufferObject
    fbo) GLenum
    m

    -- | 'drawBuffers' defines the draw buffers to which all fragment colors are
    -- written. The draw buffers being defined correspond in order to the respective
    -- fragment colors. The draw buffer for fragment colors beyond those specified
    -- is set to 'NoBuffers'.
    --
    -- Except for 'NoBuffers', a buffer may not appear more then once in the given
    -- list. Specifying a buffer more then once will result in an
    -- 'Graphics.Rendering.OpenGL.GLU.Errors.InvalidOperation'.
    --
    -- If fixed-function fragment shading is being performed, 'drawBuffers'
    -- specifies a set of draw buffers into which the fragment color is written.
    --
    -- If a fragment shader writes to @gl_FragColor@, 'drawBuffers' specifies a set
    -- of draw buffers into which the single fragment color defined by
    -- @gl_FragColor@ is written. If a fragment shader writes to @gl_FragData@,
    -- 'drawBuffers' specifies a set of draw buffers into which each of the multiple
    -- fragment colors defined by @gl_FragData@ are separately written. If a
    -- fragment shader writes to neither @gl_FragColor@ nor @gl_FragData@, the
    -- values of the fragment colors following shader execution are undefined, and
    -- may differ for each fragment color.

    drawBuffers :: StateVar [BufferMode]
    drawBuffers :: StateVar [BufferMode]
    drawBuffers = IO [BufferMode] -> ([BufferMode] -> IO ()) -> StateVar [BufferMode]
    forall a. IO a -> (a -> IO ()) -> StateVar a
    makeStateVar IO [BufferMode]
    getDrawBuffers [BufferMode] -> IO ()
    setDrawBuffers

    getDrawBuffers :: IO [BufferMode]
    getDrawBuffers :: IO [BufferMode]
    getDrawBuffers = do
       n <- GettableStateVar GLint -> GettableStateVar GLint
    forall t a (m :: * -> *). (HasGetter t a, MonadIO m) => t -> m a
    forall (m :: * -> *).
    MonadIO m =>
    GettableStateVar GLint -> m GLint
    get GettableStateVar GLint
    maxDrawBuffers
       mapM getDrawBufferi [ 0 .. n-1 ]

    setDrawBuffers :: [BufferMode] -> IO ()
    setDrawBuffers :: [BufferMode] -> IO ()
    setDrawBuffers [BufferMode]
    modes =
       [BufferMode] -> ([GLenum] -> IO ()) -> IO ()
    withBufferModes [BufferMode]
    modes (([GLenum] -> IO ()) -> IO ()) -> ([GLenum] -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \[GLenum]
    ms ->
          [GLenum] -> (Int -> Ptr GLenum -> IO ()) -> IO ()
    forall a b. Storable a => [a] -> (Int -> Ptr a -> IO b) -> IO b
    withArrayLen [GLenum]
    ms ((Int -> Ptr GLenum -> IO ()) -> IO ())
    -> (Int -> Ptr GLenum -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \Int
    len ->
             GLint -> Ptr GLenum -> IO ()
    forall (m :: * -> *). MonadIO m => GLint -> Ptr GLenum -> m ()
    glDrawBuffers (Int -> GLint
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Int
    len)

    -- | The direct-state-access version of 'drawBuffers'.

    namedFramebufferDrawBuffers :: FramebufferObject -> SettableStateVar [BufferMode]
    namedFramebufferDrawBuffers :: FramebufferObject -> SettableStateVar [BufferMode]
    namedFramebufferDrawBuffers FramebufferObject
    fbo =
       ([BufferMode] -> IO ()) -> SettableStateVar [BufferMode]
    forall a. (a -> IO ()) -> SettableStateVar a
    makeSettableStateVar (([BufferMode] -> IO ()) -> SettableStateVar [BufferMode])
    -> ([BufferMode] -> IO ()) -> SettableStateVar [BufferMode]
    forall a b. (a -> b) -> a -> b
    $ \[BufferMode]
    modes ->
          [BufferMode] -> ([GLenum] -> IO ()) -> IO ()
    withBufferModes [BufferMode]
    modes (([GLenum] -> IO ()) -> IO ()) -> ([GLenum] -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \[GLenum]
    ms ->
             [GLenum] -> (Int -> Ptr GLenum -> IO ()) -> IO ()
    forall a b. Storable a => [a] -> (Int -> Ptr a -> IO b) -> IO b
    withArrayLen [GLenum]
    ms ((Int -> Ptr GLenum -> IO ()) -> IO ())
    -> (Int -> Ptr GLenum -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \Int
    len ->
                GLenum -> GLint -> Ptr GLenum -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLenum -> GLint -> Ptr GLenum -> m ()
    glNamedFramebufferDrawBuffers (FramebufferObject -> GLenum
    framebufferID FramebufferObject
    fbo) (Int -> GLint
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Int
    len)

    withBufferModes :: [BufferMode] -> ([GLenum] -> IO ()) -> IO ()
    withBufferModes :: [BufferMode] -> ([GLenum] -> IO ()) -> IO ()
    withBufferModes [BufferMode]
    modes [GLenum] -> IO ()
    success
       | (Maybe GLenum -> Bool) -> [Maybe GLenum] -> Bool
    forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
    all Maybe GLenum -> Bool
    forall a. Maybe a -> Bool
    isJust [Maybe GLenum]
    ms = [GLenum] -> IO ()
    success ([Maybe GLenum] -> [GLenum]
    forall a. [Maybe a] -> [a]
    catMaybes [Maybe GLenum]
    ms)
       | Bool
    otherwise = IO ()
    recordInvalidValue
       where ms :: [Maybe GLenum]
    ms = (BufferMode -> Maybe GLenum) -> [BufferMode] -> [Maybe GLenum]
    forall a b. (a -> b) -> [a] -> [b]
    map BufferMode -> Maybe GLenum
    marshalBufferMode [BufferMode]
    modes

    -- | The index of the draw buffer.

    type DrawBufferIndex = GLuint

    -- | 'drawBufferi' is a fast query function. For indices in the range
    -- 0..'maxDrawBuffers'-1 its results is the same as selecting the corresponding
    -- element from the list returned by 'drawBuffers', but this function uses only
    -- one GL function call instead of 'maxDrawBuffers' ones.

    drawBufferi :: DrawBufferIndex -> GettableStateVar BufferMode
    drawBufferi :: GLenum -> IO BufferMode
    drawBufferi = IO BufferMode -> IO BufferMode
    forall a. IO a -> IO a
    makeGettableStateVar (IO BufferMode -> IO BufferMode)
    -> (GLenum -> IO BufferMode) -> GLenum -> IO BufferMode
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . GLint -> IO BufferMode
    getDrawBufferi (GLint -> IO BufferMode)
    -> (GLenum -> GLint) -> GLenum -> IO BufferMode
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . GLenum -> GLint
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral

    getDrawBufferi :: GLsizei -> IO BufferMode
    getDrawBufferi :: GLint -> IO BufferMode
    getDrawBufferi = (GLenum -> BufferMode) -> PName1I -> IO BufferMode
    forall p a. GetPName1I p => (GLenum -> a) -> p -> IO a
    forall a. (GLenum -> a) -> PName1I -> IO a
    getEnum1 GLenum -> BufferMode
    unmarshalBufferMode (PName1I -> IO BufferMode)
    -> (GLint -> PName1I) -> GLint -> IO BufferMode
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . GLint -> PName1I
    GetDrawBufferN

    -- | Contains the maximum number of buffers that can activated via 'drawBuffers'
    -- or which can be simultaneously written into from within a fragment shader
    -- using the special output variable array @gl_FragData@. This constant
    -- effectively defines the size of the @gl_FragData@ array. The minimum legal
    -- value is 1.

    maxDrawBuffers :: GettableStateVar GLsizei
    maxDrawBuffers :: GettableStateVar GLint
    maxDrawBuffers = GettableStateVar GLint -> GettableStateVar GLint
    forall a. IO a -> IO a
    makeGettableStateVar (GettableStateVar GLint -> GettableStateVar GLint)
    -> GettableStateVar GLint -> GettableStateVar GLint
    forall a b. (a -> b) -> a -> b
    $ (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
    GetMaxDrawBuffers

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

    -- | Controls the writing of individual bits in the color index buffers. The
    -- least significant /n/ bits of its value, where /n/ is the number of bits in a
    -- color index buffer, specify a mask. Where a 1 appears in the mask, it is
    -- possible to write to the corresponding bit in the color index buffer (or
    -- buffers). Where a 0 appears, the corresponding bit is write-protected.
    --
    -- This mask is used only in color index mode, and it affects only the buffers
    -- currently selected for writing (see 'drawBuffer'). Initially, all bits are
    -- enabled for writing.

    indexMask :: StateVar GLuint
    indexMask :: StateVar GLenum
    indexMask =
       IO GLenum -> (GLenum -> IO ()) -> StateVar GLenum
    forall a. IO a -> (a -> IO ()) -> StateVar a
    makeStateVar ((GLint -> GLenum) -> PName1I -> IO GLenum
    forall p a. GetPName1I p => (GLint -> a) -> p -> IO a
    forall a. (GLint -> a) -> PName1I -> IO a
    getInteger1 GLint -> GLenum
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral PName1I
    GetIndexWritemask) GLenum -> IO ()
    forall (m :: * -> *). MonadIO m => GLenum -> m ()
    glIndexMask

    -- | Controls whether the individual color components in the framebuffer can or
    -- cannot be written. If the red flag is 'Disabled', for example, no change is
    -- made to the red component of any pixel in any of the color buffers,
    -- regardless of the drawing operation attempted. Initially, all color
    -- components can be written.
    --
    -- Changes to individual bits of components cannot be controlled. Rather,
    -- changes are either enabled or disabled for entire color components.
    -- Furthermore, this mask is used only in RGBA mode.

    colorMask :: StateVar (Color4 Capability)
    colorMask :: StateVar (Color4 Capability)
    colorMask =
       IO (Color4 Capability)
    -> (Color4 Capability -> IO ()) -> StateVar (Color4 Capability)
    forall a. IO a -> (a -> IO ()) -> StateVar a
    makeStateVar
          ((GLboolean
     -> GLboolean -> GLboolean -> GLboolean -> Color4 Capability)
    -> PName4ISemiIndexed -> IO (Color4 Capability)
    forall p a.
    GetPName4I p =>
    (GLboolean -> GLboolean -> GLboolean -> GLboolean -> a)
    -> p -> IO a
    forall a.
    (GLboolean -> GLboolean -> GLboolean -> GLboolean -> a)
    -> PName4ISemiIndexed -> IO a
    getBoolean4 (\GLboolean
    r GLboolean
    g GLboolean
    b GLboolean
    a -> Capability
    -> Capability -> Capability -> Capability -> Color4 Capability
    forall a. a -> a -> a -> a -> Color4 a
    Color4 (GLboolean -> Capability
    unmarshalCapability GLboolean
    r)
                                           (GLboolean -> Capability
    unmarshalCapability GLboolean
    g)
                                           (GLboolean -> Capability
    unmarshalCapability GLboolean
    b)
                                           (GLboolean -> Capability
    unmarshalCapability GLboolean
    a))
                                           PName4ISemiIndexed
    GetColorWritemask)
          (\(Color4 Capability
    r Capability
    g Capability
    b Capability
    a) -> GLboolean -> GLboolean -> GLboolean -> GLboolean -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLboolean -> GLboolean -> GLboolean -> GLboolean -> m ()
    glColorMask (Capability -> GLboolean
    marshalCapability Capability
    r)
                                            (Capability -> GLboolean
    marshalCapability Capability
    g)
                                            (Capability -> GLboolean
    marshalCapability Capability
    b)
                                            (Capability -> GLboolean
    marshalCapability Capability
    a))

    -- | 'colorMaski' is a version of 'colorMask' that only applies to the specified
    -- draw buffer.

    colorMaski :: DrawBufferIndex -> StateVar (Color4 Capability)
    colorMaski :: GLenum -> StateVar (Color4 Capability)
    colorMaski GLenum
    idx =
       IO (Color4 Capability)
    -> (Color4 Capability -> IO ()) -> StateVar (Color4 Capability)
    forall a. IO a -> (a -> IO ()) -> StateVar a
    makeStateVar
          ((GLboolean
     -> GLboolean -> GLboolean -> GLboolean -> Color4 Capability)
    -> PName4ISemiIndexed -> GLenum -> IO (Color4 Capability)
    forall p a.
    GetIPName4I p =>
    (GLboolean -> GLboolean -> GLboolean -> GLboolean -> a)
    -> p -> GLenum -> IO a
    forall a.
    (GLboolean -> GLboolean -> GLboolean -> GLboolean -> a)
    -> PName4ISemiIndexed -> GLenum -> IO a
    getBoolean4i (\GLboolean
    r GLboolean
    g GLboolean
    b GLboolean
    a -> Capability
    -> Capability -> Capability -> Capability -> Color4 Capability
    forall a. a -> a -> a -> a -> Color4 a
    Color4 (GLboolean -> Capability
    unmarshalCapability GLboolean
    r)
                                            (GLboolean -> Capability
    unmarshalCapability GLboolean
    g)
                                            (GLboolean -> Capability
    unmarshalCapability GLboolean
    b)
                                            (GLboolean -> Capability
    unmarshalCapability GLboolean
    a))
                        PName4ISemiIndexed
    GetColorWritemask GLenum
    idx)
          (\(Color4 Capability
    r Capability
    g Capability
    b Capability
    a) -> GLenum -> GLboolean -> GLboolean -> GLboolean -> GLboolean -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLenum -> GLboolean -> GLboolean -> GLboolean -> GLboolean -> m ()
    glColorMaski GLenum
    idx
                                             (Capability -> GLboolean
    marshalCapability Capability
    r)
                                             (Capability -> GLboolean
    marshalCapability Capability
    g)
                                             (Capability -> GLboolean
    marshalCapability Capability
    b)
                                             (Capability -> GLboolean
    marshalCapability Capability
    a))

    -- | Controls whether the depth buffer is enabled for writing. The initial state
    -- is 'Enabled'.

    depthMask :: StateVar Capability
    depthMask :: StateVar Capability
    depthMask = 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
    GetDepthWritemask)
                             (GLboolean -> IO ()
    forall (m :: * -> *). MonadIO m => GLboolean -> m ()
    glDepthMask (GLboolean -> IO ())
    -> (Capability -> GLboolean) -> Capability -> IO ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Capability -> GLboolean
    marshalCapability)

    -- | Controls the writing of individual bits in the stencil planes. The least
    -- significant /n/ bits of its value, where /n/ is the number of bits in the
    -- stencil buffer, specify a mask. Where a 1 appears in the mask, it is possible
    -- to write to the corresponding bit in the stencil buffer. Where a 0 appears,
    -- the corresponding bit is write-protected. Initially, all bits are enabled for
    -- writing.

    stencilMask :: StateVar GLuint
    stencilMask :: StateVar GLenum
    stencilMask =
       IO GLenum -> (GLenum -> IO ()) -> StateVar GLenum
    forall a. IO a -> (a -> IO ()) -> StateVar a
    makeStateVar (StateVar GLenum -> IO GLenum
    forall t a (m :: * -> *). (HasGetter t a, MonadIO m) => t -> m a
    forall (m :: * -> *). MonadIO m => StateVar GLenum -> m GLenum
    get (Face -> StateVar GLenum
    stencilMaskSeparate Face
    Front)) GLenum -> IO ()
    forall (m :: * -> *). MonadIO m => GLenum -> m ()
    glStencilMask

    -- | A per-face version of 'stencilMask'.

    stencilMaskSeparate :: Face -> StateVar GLuint
    stencilMaskSeparate :: Face -> StateVar GLenum
    stencilMaskSeparate Face
    face =
       IO GLenum -> (GLenum -> IO ()) -> StateVar GLenum
    forall a. IO a -> (a -> IO ()) -> StateVar a
    makeStateVar
          (case Face
    face of
              Face
    Front -> (GLint -> GLenum) -> PName1I -> IO GLenum
    forall p a. GetPName1I p => (GLint -> a) -> p -> IO a
    forall a. (GLint -> a) -> PName1I -> IO a
    getInteger1 GLint -> GLenum
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral PName1I
    GetStencilWritemask
              Face
    Back -> (GLint -> GLenum) -> PName1I -> IO GLenum
    forall p a. GetPName1I p => (GLint -> a) -> p -> IO a
    forall a. (GLint -> a) -> PName1I -> IO a
    getInteger1 GLint -> GLenum
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral PName1I
    GetStencilBackWritemask
              Face
    FrontAndBack -> do IO ()
    recordInvalidEnum; GLenum -> IO GLenum
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return GLenum
    0)
          (GLenum -> GLenum -> IO ()
    forall (m :: * -> *). MonadIO m => GLenum -> GLenum -> m ()
    glStencilMaskSeparate (Face -> GLenum
    marshalFace Face
    face))

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

    -- | The buffers which can be cleared with 'clear'.

    data ClearBuffer =
         ColorBuffer   -- ^ The buffers currently enabled for color writing.
       | AccumBuffer   -- ^ The accumulation buffer.
       | StencilBuffer -- ^ The stencil buffer.
       | DepthBuffer   -- ^ The depth buffer.
       deriving ( ClearBuffer -> ClearBuffer -> Bool
    (ClearBuffer -> ClearBuffer -> Bool)
    -> (ClearBuffer -> ClearBuffer -> Bool) -> Eq ClearBuffer
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: ClearBuffer -> ClearBuffer -> Bool
    == :: ClearBuffer -> ClearBuffer -> Bool
    $c/= :: ClearBuffer -> ClearBuffer -> Bool
    /= :: ClearBuffer -> ClearBuffer -> Bool
    Eq, Eq ClearBuffer
    Eq ClearBuffer =>
    (ClearBuffer -> ClearBuffer -> Ordering)
    -> (ClearBuffer -> ClearBuffer -> Bool)
    -> (ClearBuffer -> ClearBuffer -> Bool)
    -> (ClearBuffer -> ClearBuffer -> Bool)
    -> (ClearBuffer -> ClearBuffer -> Bool)
    -> (ClearBuffer -> ClearBuffer -> ClearBuffer)
    -> (ClearBuffer -> ClearBuffer -> ClearBuffer)
    -> Ord ClearBuffer
    ClearBuffer -> ClearBuffer -> Bool
    ClearBuffer -> ClearBuffer -> Ordering
    ClearBuffer -> ClearBuffer -> ClearBuffer
    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 :: ClearBuffer -> ClearBuffer -> Ordering
    compare :: ClearBuffer -> ClearBuffer -> Ordering
    $c< :: ClearBuffer -> ClearBuffer -> Bool
    < :: ClearBuffer -> ClearBuffer -> Bool
    $c<= :: ClearBuffer -> ClearBuffer -> Bool
    <= :: ClearBuffer -> ClearBuffer -> Bool
    $c> :: ClearBuffer -> ClearBuffer -> Bool
    > :: ClearBuffer -> ClearBuffer -> Bool
    $c>= :: ClearBuffer -> ClearBuffer -> Bool
    >= :: ClearBuffer -> ClearBuffer -> Bool
    $cmax :: ClearBuffer -> ClearBuffer -> ClearBuffer
    max :: ClearBuffer -> ClearBuffer -> ClearBuffer
    $cmin :: ClearBuffer -> ClearBuffer -> ClearBuffer
    min :: ClearBuffer -> ClearBuffer -> ClearBuffer
    Ord, Int -> ClearBuffer -> ShowS
    [ClearBuffer] -> ShowS
    ClearBuffer -> String
    (Int -> ClearBuffer -> ShowS)
    -> (ClearBuffer -> String)
    -> ([ClearBuffer] -> ShowS)
    -> Show ClearBuffer
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> ClearBuffer -> ShowS
    showsPrec :: Int -> ClearBuffer -> ShowS
    $cshow :: ClearBuffer -> String
    show :: ClearBuffer -> String
    $cshowList :: [ClearBuffer] -> ShowS
    showList :: [ClearBuffer] -> ShowS
    Show )

    marshalClearBuffer :: ClearBuffer -> GLbitfield
    marshalClearBuffer :: ClearBuffer -> GLenum
    marshalClearBuffer ClearBuffer
    x = case ClearBuffer
    x of
       ClearBuffer
    ColorBuffer -> GLenum
    GL_COLOR_BUFFER_BIT
       ClearBuffer
    AccumBuffer -> GLenum
    GL_ACCUM_BUFFER_BIT
       ClearBuffer
    StencilBuffer -> GLenum
    GL_STENCIL_BUFFER_BIT
       ClearBuffer
    DepthBuffer -> GLenum
    GL_DEPTH_BUFFER_BIT

    -- | Set the bitplane area of the window to values previously selected by
    -- 'clearColor', 'clearIndex', 'clearDepth', 'clearStencil', and 'clearAccum'.
    -- Multiple color buffers can be cleared simultaneously by selecting more than
    -- one buffer at a time using 'drawBuffer'.
    --
    -- The pixel ownership test, the scissor test, dithering, and the buffer
    -- writemasks affect the operation of 'clear'. The scissor box bounds the
    -- cleared region. Alpha function, blend function, logical operation,
    -- stenciling, texure mapping, and depth-buffering are ignored by 'clear'.
    --
    -- 'clear' takes a list of buffers, indicating which buffers are to be cleared.
    -- If a buffer is not present, then a 'clear' directed at that buffer has no
    -- effect.
    --
    -- The value to which each buffer is cleared depends on the setting of the clear
    -- value for that buffer.

    clear :: [ClearBuffer] -> IO ()
    clear :: [ClearBuffer] -> IO ()
    clear = GLenum -> IO ()
    forall (m :: * -> *). MonadIO m => GLenum -> m ()
    glClear (GLenum -> IO ())
    -> ([ClearBuffer] -> GLenum) -> [ClearBuffer] -> IO ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [GLenum] -> GLenum
    forall a. Num a => [a] -> a
    forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
    sum ([GLenum] -> GLenum)
    -> ([ClearBuffer] -> [GLenum]) -> [ClearBuffer] -> GLenum
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (ClearBuffer -> GLenum) -> [ClearBuffer] -> [GLenum]
    forall a b. (a -> b) -> [a] -> [b]
    map ClearBuffer -> GLenum
    marshalClearBuffer

    -- | Controls the red, green, blue, and alpha values used by 'clear' to clear
    -- the color buffers. Initially, all values are 0.

    clearColor :: StateVar (Color4 GLfloat)
    clearColor :: StateVar (Color4 GLfloat)
    clearColor = 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
    GetColorClearValue)
                              (\(Color4 GLfloat
    r GLfloat
    g GLfloat
    b GLfloat
    a) -> GLfloat -> GLfloat -> GLfloat -> GLfloat -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLfloat -> GLfloat -> GLfloat -> GLfloat -> m ()
    glClearColor GLfloat
    r GLfloat
    g GLfloat
    b GLfloat
    a)

    -- | Controls the index /c/ used by 'clear' to clear the color index buffers.
    -- /c/ is not clamped. Rather, /c/ is converted to a fixed-point value with
    -- unspecified precision to the right of the binary point. The integer part of
    -- this value is then masked with 2^/m/-1, where /m/ is the number of bits in a
    -- color index stored in the framebuffer. Initially, the value is 0.

    clearIndex :: StateVar (Index1 GLfloat)
    clearIndex :: StateVar (Index1 GLfloat)
    clearIndex = IO (Index1 GLfloat)
    -> (Index1 GLfloat -> IO ()) -> StateVar (Index1 GLfloat)
    forall a. IO a -> (a -> IO ()) -> StateVar a
    makeStateVar ((GLfloat -> Index1 GLfloat) -> PName1F -> IO (Index1 GLfloat)
    forall p a. GetPName1F p => (GLfloat -> a) -> p -> IO a
    forall a. (GLfloat -> a) -> PName1F -> IO a
    getFloat1 GLfloat -> Index1 GLfloat
    forall a. a -> Index1 a
    Index1 PName1F
    GetIndexClearValue)
                              (\(Index1 GLfloat
    i) -> GLfloat -> IO ()
    forall (m :: * -> *). MonadIO m => GLfloat -> m ()
    glClearIndex GLfloat
    i)

    -- | Controls the depth value used by 'clear' to clear the depth buffer. The
    -- initial value is 1.

    clearDepth :: StateVar GLdouble
    clearDepth :: StateVar GLdouble
    clearDepth = IO GLdouble -> (GLdouble -> IO ()) -> StateVar GLdouble
    forall a. IO a -> (a -> IO ()) -> StateVar a
    makeStateVar ((GLdouble -> GLdouble) -> PName1F -> IO GLdouble
    forall p a. GetPName1F p => (GLdouble -> a) -> p -> IO a
    forall a. (GLdouble -> a) -> PName1F -> IO a
    getDouble1 GLdouble -> GLdouble
    forall a. a -> a
    id PName1F
    GetDepthClearValue) GLdouble -> IO ()
    forall (m :: * -> *). MonadIO m => GLdouble -> m ()
    glClearDepth

    -- | A variant of 'clearDepth' with a 'GLfloat' argument.

    clearDepthf :: StateVar GLfloat
    clearDepthf :: StateVar GLfloat
    clearDepthf = IO GLfloat -> (GLfloat -> IO ()) -> StateVar GLfloat
    forall a. IO a -> (a -> IO ()) -> StateVar a
    makeStateVar ((GLfloat -> GLfloat) -> PName1F -> IO 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
    GetDepthClearValue) GLfloat -> IO ()
    forall (m :: * -> *). MonadIO m => GLfloat -> m ()
    glClearDepthf

    -- | Controls the value /s/ used by 'clear' to clear the stencil buffer. /s/ is
    -- masked with 2^/m/-1, where /m/ is the number of bits in the stencil buffer.
    -- Initially, the value is 0.

    clearStencil :: StateVar GLint
    clearStencil :: StateVar GLint
    clearStencil = GettableStateVar GLint -> (GLint -> IO ()) -> StateVar GLint
    forall a. IO a -> (a -> IO ()) -> StateVar a
    makeStateVar ((GLint -> GLint) -> PName1I -> GettableStateVar GLint
    forall p a. GetPName1I p => (GLint -> a) -> p -> IO a
    forall a. (GLint -> a) -> PName1I -> IO a
    getInteger1 GLint -> GLint
    forall a. a -> a
    id PName1I
    GetStencilClearValue) GLint -> IO ()
    forall (m :: * -> *). MonadIO m => GLint -> m ()
    glClearStencil

    -- | Controls the red, green, blue, and alpha values used by 'clear' to clear
    -- the accumulation buffer. Values written into 'clearAccum' are clamped to the
    -- range [-1, 1]. The initial values are all 0.

    clearAccum :: StateVar (Color4 GLfloat)
    clearAccum :: StateVar (Color4 GLfloat)
    clearAccum =
       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
    GetAccumClearValue)
                    (\(Color4 GLfloat
    r GLfloat
    g GLfloat
    b GLfloat
    a) -> GLfloat -> GLfloat -> GLfloat -> GLfloat -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLfloat -> GLfloat -> GLfloat -> GLfloat -> m ()
    glClearAccum GLfloat
    r GLfloat
    g GLfloat
    b GLfloat
    a)

    -- | Describes which buffer(s) to clear and the value to use.

    data ClearBufferCommand
       = ClearColorBufferInt DrawBufferIndex (Color4 GLint)
       -- ^ Clear the signed integer color buffer(s) at the given index.
       | ClearColorBufferFloat DrawBufferIndex (Color4 GLfloat)
       -- ^ Clear the fixed- or floating-point color buffer(s) at the given index.
       | ClearColorBufferUint DrawBufferIndex (Color4 GLuint)
       -- ^ Clear the unsigned color buffer(s) at the given index.
       | ClearDepthBuffer GLfloat
       -- ^ Clear the depth buffer.
       | ClearStencilBuffer GLint
       -- ^ Clear the stencil buffer.
       | ClearDepthAndStencilBuffers GLfloat GLint
       -- ^ Clear the depth buffer and the stencil buffer.
       deriving ( ClearBufferCommand -> ClearBufferCommand -> Bool
    (ClearBufferCommand -> ClearBufferCommand -> Bool)
    -> (ClearBufferCommand -> ClearBufferCommand -> Bool)
    -> Eq ClearBufferCommand
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: ClearBufferCommand -> ClearBufferCommand -> Bool
    == :: ClearBufferCommand -> ClearBufferCommand -> Bool
    $c/= :: ClearBufferCommand -> ClearBufferCommand -> Bool
    /= :: ClearBufferCommand -> ClearBufferCommand -> Bool
    Eq, Eq ClearBufferCommand
    Eq ClearBufferCommand =>
    (ClearBufferCommand -> ClearBufferCommand -> Ordering)
    -> (ClearBufferCommand -> ClearBufferCommand -> Bool)
    -> (ClearBufferCommand -> ClearBufferCommand -> Bool)
    -> (ClearBufferCommand -> ClearBufferCommand -> Bool)
    -> (ClearBufferCommand -> ClearBufferCommand -> Bool)
    -> (ClearBufferCommand -> ClearBufferCommand -> ClearBufferCommand)
    -> (ClearBufferCommand -> ClearBufferCommand -> ClearBufferCommand)
    -> Ord ClearBufferCommand
    ClearBufferCommand -> ClearBufferCommand -> Bool
    ClearBufferCommand -> ClearBufferCommand -> Ordering
    ClearBufferCommand -> ClearBufferCommand -> ClearBufferCommand
    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 :: ClearBufferCommand -> ClearBufferCommand -> Ordering
    compare :: ClearBufferCommand -> ClearBufferCommand -> Ordering
    $c< :: ClearBufferCommand -> ClearBufferCommand -> Bool
    < :: ClearBufferCommand -> ClearBufferCommand -> Bool
    $c<= :: ClearBufferCommand -> ClearBufferCommand -> Bool
    <= :: ClearBufferCommand -> ClearBufferCommand -> Bool
    $c> :: ClearBufferCommand -> ClearBufferCommand -> Bool
    > :: ClearBufferCommand -> ClearBufferCommand -> Bool
    $c>= :: ClearBufferCommand -> ClearBufferCommand -> Bool
    >= :: ClearBufferCommand -> ClearBufferCommand -> Bool
    $cmax :: ClearBufferCommand -> ClearBufferCommand -> ClearBufferCommand
    max :: ClearBufferCommand -> ClearBufferCommand -> ClearBufferCommand
    $cmin :: ClearBufferCommand -> ClearBufferCommand -> ClearBufferCommand
    min :: ClearBufferCommand -> ClearBufferCommand -> ClearBufferCommand
    Ord, Int -> ClearBufferCommand -> ShowS
    [ClearBufferCommand] -> ShowS
    ClearBufferCommand -> String
    (Int -> ClearBufferCommand -> ShowS)
    -> (ClearBufferCommand -> String)
    -> ([ClearBufferCommand] -> ShowS)
    -> Show ClearBufferCommand
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> ClearBufferCommand -> ShowS
    showsPrec :: Int -> ClearBufferCommand -> ShowS
    $cshow :: ClearBufferCommand -> String
    show :: ClearBufferCommand -> String
    $cshowList :: [ClearBufferCommand] -> ShowS
    showList :: [ClearBufferCommand] -> ShowS
    Show )

    -- | Clear the given buffer(s).

    clearBuffer :: ClearBufferCommand -> IO ()
    clearBuffer :: ClearBufferCommand -> IO ()
    clearBuffer ClearBufferCommand
    cmd = case ClearBufferCommand
    cmd of
       ClearColorBufferInt GLenum
    i Color4 GLint
    c ->
          Color4 GLint -> (Ptr (Color4 GLint) -> IO ()) -> IO ()
    forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
    with Color4 GLint
    c ((Ptr (Color4 GLint) -> IO ()) -> IO ())
    -> (Ptr (Color4 GLint) -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ GLenum -> GLint -> Ptr GLint -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLenum -> GLint -> Ptr GLint -> m ()
    glClearBufferiv GLenum
    GL_COLOR (GLenum -> GLint
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral GLenum
    i) (Ptr GLint -> IO ())
    -> (Ptr (Color4 GLint) -> Ptr GLint) -> Ptr (Color4 GLint) -> IO ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Ptr (Color4 GLint) -> Ptr GLint
    forall a b. Ptr a -> Ptr b
    castPtr
       ClearColorBufferFloat GLenum
    i 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 -> GLint -> Ptr GLfloat -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLenum -> GLint -> Ptr GLfloat -> m ()
    glClearBufferfv GLenum
    GL_COLOR (GLenum -> GLint
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral GLenum
    i) (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
       ClearColorBufferUint GLenum
    i Color4 GLenum
    c ->
          Color4 GLenum -> (Ptr (Color4 GLenum) -> IO ()) -> IO ()
    forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
    with Color4 GLenum
    c ((Ptr (Color4 GLenum) -> IO ()) -> IO ())
    -> (Ptr (Color4 GLenum) -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ GLenum -> GLint -> Ptr GLenum -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLenum -> GLint -> Ptr GLenum -> m ()
    glClearBufferuiv GLenum
    GL_COLOR (GLenum -> GLint
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral GLenum
    i) (Ptr GLenum -> IO ())
    -> (Ptr (Color4 GLenum) -> Ptr GLenum)
    -> Ptr (Color4 GLenum)
    -> IO ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Ptr (Color4 GLenum) -> Ptr GLenum
    forall a b. Ptr a -> Ptr b
    castPtr
       ClearDepthBuffer GLfloat
    d ->
          GLfloat -> (Ptr GLfloat -> IO ()) -> IO ()
    forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
    with GLfloat
    d ((Ptr GLfloat -> IO ()) -> IO ())
    -> (Ptr GLfloat -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ GLenum -> GLint -> Ptr GLfloat -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLenum -> GLint -> Ptr GLfloat -> m ()
    glClearBufferfv GLenum
    GL_DEPTH GLint
    0
       ClearStencilBuffer GLint
    s ->
          GLint -> (Ptr GLint -> IO ()) -> IO ()
    forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
    with GLint
    s ((Ptr GLint -> IO ()) -> IO ()) -> (Ptr GLint -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ GLenum -> GLint -> Ptr GLint -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLenum -> GLint -> Ptr GLint -> m ()
    glClearBufferiv GLenum
    GL_STENCIL GLint
    0
       ClearDepthAndStencilBuffers GLfloat
    d GLint
    s ->
          GLenum -> GLint -> GLfloat -> GLint -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLenum -> GLint -> GLfloat -> GLint -> m ()
    glClearBufferfi GLenum
    GL_DEPTH_STENCIL GLint
    0 GLfloat
    d GLint
    s

    -- | The direct-state-access version of 'clearBuffer'.

    clearNamedFramebuffer :: FramebufferObject -> ClearBufferCommand -> IO ()
    clearNamedFramebuffer :: FramebufferObject -> ClearBufferCommand -> IO ()
    clearNamedFramebuffer FramebufferObject
    fbo ClearBufferCommand
    cmd = case ClearBufferCommand
    cmd of
       ClearColorBufferInt GLenum
    i Color4 GLint
    c ->
          Color4 GLint -> (Ptr (Color4 GLint) -> IO ()) -> IO ()
    forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
    with Color4 GLint
    c ((Ptr (Color4 GLint) -> IO ()) -> IO ())
    -> (Ptr (Color4 GLint) -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ GLenum -> GLenum -> GLint -> Ptr GLint -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLenum -> GLenum -> GLint -> Ptr GLint -> m ()
    glClearNamedFramebufferiv GLenum
    f GLenum
    GL_COLOR (GLenum -> GLint
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral GLenum
    i) (Ptr GLint -> IO ())
    -> (Ptr (Color4 GLint) -> Ptr GLint) -> Ptr (Color4 GLint) -> IO ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Ptr (Color4 GLint) -> Ptr GLint
    forall a b. Ptr a -> Ptr b
    castPtr
       ClearColorBufferFloat GLenum
    i 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 -> GLenum -> GLint -> Ptr GLfloat -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLenum -> GLenum -> GLint -> Ptr GLfloat -> m ()
    glClearNamedFramebufferfv GLenum
    f GLenum
    GL_COLOR (GLenum -> GLint
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral GLenum
    i) (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
       ClearColorBufferUint GLenum
    i Color4 GLenum
    c ->
          Color4 GLenum -> (Ptr (Color4 GLenum) -> IO ()) -> IO ()
    forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
    with Color4 GLenum
    c ((Ptr (Color4 GLenum) -> IO ()) -> IO ())
    -> (Ptr (Color4 GLenum) -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ GLenum -> GLenum -> GLint -> Ptr GLenum -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLenum -> GLenum -> GLint -> Ptr GLenum -> m ()
    glClearNamedFramebufferuiv GLenum
    f GLenum
    GL_COLOR (GLenum -> GLint
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral GLenum
    i) (Ptr GLenum -> IO ())
    -> (Ptr (Color4 GLenum) -> Ptr GLenum)
    -> Ptr (Color4 GLenum)
    -> IO ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Ptr (Color4 GLenum) -> Ptr GLenum
    forall a b. Ptr a -> Ptr b
    castPtr
       ClearDepthBuffer GLfloat
    d ->
          GLfloat -> (Ptr GLfloat -> IO ()) -> IO ()
    forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
    with GLfloat
    d ((Ptr GLfloat -> IO ()) -> IO ())
    -> (Ptr GLfloat -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ GLenum -> GLenum -> GLint -> Ptr GLfloat -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLenum -> GLenum -> GLint -> Ptr GLfloat -> m ()
    glClearNamedFramebufferfv GLenum
    f GLenum
    GL_DEPTH GLint
    0
       ClearStencilBuffer GLint
    s ->
          GLint -> (Ptr GLint -> IO ()) -> IO ()
    forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
    with GLint
    s ((Ptr GLint -> IO ()) -> IO ()) -> (Ptr GLint -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ GLenum -> GLenum -> GLint -> Ptr GLint -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLenum -> GLenum -> GLint -> Ptr GLint -> m ()
    glClearNamedFramebufferiv GLenum
    f GLenum
    GL_STENCIL GLint
    0
       ClearDepthAndStencilBuffers GLfloat
    d GLint
    s ->
          GLenum -> GLenum -> GLint -> GLfloat -> GLint -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLenum -> GLenum -> GLint -> GLfloat -> GLint -> m ()
    glClearNamedFramebufferfi GLenum
    f GLenum
    GL_DEPTH_STENCIL GLint
    0 GLfloat
    d GLint
    s
       where f :: GLenum
    f = FramebufferObject -> GLenum
    framebufferID FramebufferObject
    fbo

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

    -- | Invalidate a region of the attachments bound to the given target.

    invalidateSubFramebuffer :: FramebufferTarget -> [FramebufferObjectAttachment] -> (Position, Size) -> IO ()
    invalidateSubFramebuffer :: FramebufferTarget
    -> [FramebufferObjectAttachment] -> (Position, Size) -> IO ()
    invalidateSubFramebuffer FramebufferTarget
    target [FramebufferObjectAttachment]
    attachments (Position GLint
    x GLint
    y, Size GLint
    w GLint
    h) =
       [FramebufferObjectAttachment]
    -> (GLint -> Ptr GLenum -> IO ()) -> IO ()
    withAttachments [FramebufferObjectAttachment]
    attachments ((GLint -> Ptr GLenum -> IO ()) -> IO ())
    -> (GLint -> Ptr GLenum -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \GLint
    numAttachments Ptr GLenum
    atts ->
          GLenum
    -> GLint -> Ptr GLenum -> GLint -> GLint -> GLint -> GLint -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLenum
    -> GLint -> Ptr GLenum -> GLint -> GLint -> GLint -> GLint -> m ()
    glInvalidateSubFramebuffer (FramebufferTarget -> GLenum
    marshalFramebufferTarget FramebufferTarget
    target) GLint
    numAttachments Ptr GLenum
    atts GLint
    x GLint
    y GLint
    w GLint
    h

    -- | The direct-state-access version of 'invalidateSubFramebuffer'.

    invalidateNamedFramebufferSubData :: FramebufferObject -> [FramebufferObjectAttachment] -> (Position, Size) -> IO ()
    invalidateNamedFramebufferSubData :: FramebufferObject
    -> [FramebufferObjectAttachment] -> (Position, Size) -> IO ()
    invalidateNamedFramebufferSubData FramebufferObject
    fbo [FramebufferObjectAttachment]
    attachments (Position GLint
    x GLint
    y, Size GLint
    w GLint
    h) =
       [FramebufferObjectAttachment]
    -> (GLint -> Ptr GLenum -> IO ()) -> IO ()
    withAttachments [FramebufferObjectAttachment]
    attachments ((GLint -> Ptr GLenum -> IO ()) -> IO ())
    -> (GLint -> Ptr GLenum -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \GLint
    numAttachments Ptr GLenum
    atts ->
          GLenum
    -> GLint -> Ptr GLenum -> GLint -> GLint -> GLint -> GLint -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLenum
    -> GLint -> Ptr GLenum -> GLint -> GLint -> GLint -> GLint -> m ()
    glInvalidateNamedFramebufferSubData (FramebufferObject -> GLenum
    framebufferID FramebufferObject
    fbo) GLint
    numAttachments Ptr GLenum
    atts GLint
    x GLint
    y GLint
    w GLint
    h

    -- | A version of 'invalidateSubFramebuffer' affecting the whole viewport.

    invalidateFramebuffer :: FramebufferTarget -> [FramebufferObjectAttachment] -> IO ()
    invalidateFramebuffer :: FramebufferTarget -> [FramebufferObjectAttachment] -> IO ()
    invalidateFramebuffer FramebufferTarget
    target [FramebufferObjectAttachment]
    attachments =
       [FramebufferObjectAttachment]
    -> (GLint -> Ptr GLenum -> IO ()) -> IO ()
    withAttachments [FramebufferObjectAttachment]
    attachments ((GLint -> Ptr GLenum -> IO ()) -> IO ())
    -> (GLint -> Ptr GLenum -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $
          GLenum -> GLint -> Ptr GLenum -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLenum -> GLint -> Ptr GLenum -> m ()
    glInvalidateFramebuffer (FramebufferTarget -> GLenum
    marshalFramebufferTarget FramebufferTarget
    target)

    -- | The direct-state-access version of 'invalidateFramebuffer'.

    invalidateNamedFramebufferData :: FramebufferObject -> [FramebufferObjectAttachment] -> IO ()
    invalidateNamedFramebufferData :: FramebufferObject -> [FramebufferObjectAttachment] -> IO ()
    invalidateNamedFramebufferData FramebufferObject
    fbo [FramebufferObjectAttachment]
    attachments =
       [FramebufferObjectAttachment]
    -> (GLint -> Ptr GLenum -> IO ()) -> IO ()
    withAttachments [FramebufferObjectAttachment]
    attachments ((GLint -> Ptr GLenum -> IO ()) -> IO ())
    -> (GLint -> Ptr GLenum -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $
          GLenum -> GLint -> Ptr GLenum -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLenum -> GLint -> Ptr GLenum -> m ()
    glInvalidateNamedFramebufferData (FramebufferObject -> GLenum
    framebufferID FramebufferObject
    fbo)

    withAttachments :: [FramebufferObjectAttachment] -> (GLsizei -> Ptr GLenum -> IO ()) -> IO ()
    withAttachments :: [FramebufferObjectAttachment]
    -> (GLint -> Ptr GLenum -> IO ()) -> IO ()
    withAttachments [FramebufferObjectAttachment]
    attachments GLint -> Ptr GLenum -> IO ()
    success
       | (Maybe GLenum -> Bool) -> [Maybe GLenum] -> Bool
    forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
    all Maybe GLenum -> Bool
    forall a. Maybe a -> Bool
    isJust [Maybe GLenum]
    atts = [GLenum] -> (Int -> Ptr GLenum -> IO ()) -> IO ()
    forall a b. Storable a => [a] -> (Int -> Ptr a -> IO b) -> IO b
    withArrayLen ([Maybe GLenum] -> [GLenum]
    forall a. [Maybe a] -> [a]
    catMaybes [Maybe GLenum]
    atts) ((Int -> Ptr GLenum -> IO ()) -> IO ())
    -> (Int -> Ptr GLenum -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \Int
    len Ptr GLenum
    buf ->
                              GLint -> Ptr GLenum -> IO ()
    success (Int -> GLint
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Int
    len) Ptr GLenum
    buf
       | Bool
    otherwise = IO ()
    recordInvalidEnum
       where atts :: [Maybe GLenum]
    atts = (FramebufferObjectAttachment -> Maybe GLenum)
    -> [FramebufferObjectAttachment] -> [Maybe GLenum]
    forall a b. (a -> b) -> [a] -> [b]
    map FramebufferObjectAttachment -> Maybe GLenum
    marshalFramebufferObjectAttachment [FramebufferObjectAttachment]
    attachments

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

    -- | The implementation and context dependent number of auxiliary buffers.

    auxBuffers :: GettableStateVar GLsizei
    auxBuffers :: GettableStateVar GLint
    auxBuffers = GettableStateVar GLint -> GettableStateVar GLint
    forall a. IO a -> IO a
    makeGettableStateVar (GettableStateVar GLint -> GettableStateVar GLint)
    -> GettableStateVar GLint -> GettableStateVar GLint
    forall a b. (a -> b) -> a -> b
    $ (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
    GetAuxBuffers

    -- | 'True' if front and back buffers exist.

    doubleBuffer :: GettableStateVar Bool
    doubleBuffer :: GettableStateVar Bool
    doubleBuffer =
       GettableStateVar Bool -> GettableStateVar Bool
    forall a. IO a -> IO a
    makeGettableStateVar (GettableStateVar Bool -> GettableStateVar Bool)
    -> GettableStateVar Bool -> GettableStateVar Bool
    forall a b. (a -> b) -> a -> b
    $ (GLboolean -> Bool) -> PName1I -> GettableStateVar Bool
    forall p a. GetPName1I p => (GLboolean -> a) -> p -> IO a
    forall a. (GLboolean -> a) -> PName1I -> IO a
    getBoolean1 GLboolean -> Bool
    forall a. (Eq a, Num a) => a -> Bool
    unmarshalGLboolean PName1I
    GetDoublebuffer

    -- | 'True' if left and right buffers exist.

    stereoBuffer :: GettableStateVar Bool
    stereoBuffer :: GettableStateVar Bool
    stereoBuffer =
        GettableStateVar Bool -> GettableStateVar Bool
    forall a. IO a -> IO a
    makeGettableStateVar (GettableStateVar Bool -> GettableStateVar Bool)
    -> GettableStateVar Bool -> GettableStateVar Bool
    forall a b. (a -> b) -> a -> b
    $ (GLboolean -> Bool) -> PName1I -> GettableStateVar Bool
    forall p a. GetPName1I p => (GLboolean -> a) -> p -> IO a
    forall a. (GLboolean -> a) -> PName1I -> IO a
    getBoolean1 GLboolean -> Bool
    forall a. (Eq a, Num a) => a -> Bool
    unmarshalGLboolean PName1I
    GetStereo

    rgbaBits :: GettableStateVar (Color4 GLsizei)
    rgbaBits :: GettableStateVar (Color4 GLint)
    rgbaBits =
       GettableStateVar (Color4 GLint) -> GettableStateVar (Color4 GLint)
    forall a. IO a -> IO a
    makeGettableStateVar (GettableStateVar (Color4 GLint)
     -> GettableStateVar (Color4 GLint))
    -> GettableStateVar (Color4 GLint)
    -> GettableStateVar (Color4 GLint)
    forall a b. (a -> b) -> a -> b
    $
          (GLint -> GLint -> GLint -> GLint -> Color4 GLint)
    -> GettableStateVar GLint
    -> GettableStateVar GLint
    -> GettableStateVar GLint
    -> GettableStateVar GLint
    -> GettableStateVar (Color4 GLint)
    forall (m :: * -> *) a1 a2 a3 a4 r.
    Monad m =>
    (a1 -> a2 -> a3 -> a4 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m r
    liftM4 GLint -> GLint -> GLint -> GLint -> Color4 GLint
    forall a. a -> a -> a -> a -> Color4 a
    Color4 ((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
    GetRedBits)
                        ((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
    GetGreenBits)
                        ((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
    GetBlueBits)
                        ((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
    GetAlphaBits)

    stencilBits :: GettableStateVar GLsizei
    stencilBits :: GettableStateVar GLint
    stencilBits = GettableStateVar GLint -> GettableStateVar GLint
    forall a. IO a -> IO a
    makeGettableStateVar (GettableStateVar GLint -> GettableStateVar GLint)
    -> GettableStateVar GLint -> GettableStateVar GLint
    forall a b. (a -> b) -> a -> b
    $ (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
    GetStencilBits

    depthBits :: GettableStateVar GLsizei
    depthBits :: GettableStateVar GLint
    depthBits = GettableStateVar GLint -> GettableStateVar GLint
    forall a. IO a -> IO a
    makeGettableStateVar (GettableStateVar GLint -> GettableStateVar GLint)
    -> GettableStateVar GLint -> GettableStateVar GLint
    forall a b. (a -> b) -> a -> b
    $ (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
    GetDepthBits

    accumBits :: GettableStateVar (Color4 GLsizei)
    accumBits :: GettableStateVar (Color4 GLint)
    accumBits =
       GettableStateVar (Color4 GLint) -> GettableStateVar (Color4 GLint)
    forall a. IO a -> IO a
    makeGettableStateVar (GettableStateVar (Color4 GLint)
     -> GettableStateVar (Color4 GLint))
    -> GettableStateVar (Color4 GLint)
    -> GettableStateVar (Color4 GLint)
    forall a b. (a -> b) -> a -> b
    $
          (GLint -> GLint -> GLint -> GLint -> Color4 GLint)
    -> GettableStateVar GLint
    -> GettableStateVar GLint
    -> GettableStateVar GLint
    -> GettableStateVar GLint
    -> GettableStateVar (Color4 GLint)
    forall (m :: * -> *) a1 a2 a3 a4 r.
    Monad m =>
    (a1 -> a2 -> a3 -> a4 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m r
    liftM4 GLint -> GLint -> GLint -> GLint -> Color4 GLint
    forall a. a -> a -> a -> a -> Color4 a
    Color4 ((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
    GetAccumRedBits)
                        ((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
    GetAccumGreenBits)
                        ((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
    GetAccumBlueBits)
                        ((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
    GetAccumAlphaBits)

    rgbaSignedComponents :: GettableStateVar (Color4 Bool)
    rgbaSignedComponents :: GettableStateVar (Color4 Bool)
    rgbaSignedComponents =
       GettableStateVar (Color4 Bool) -> GettableStateVar (Color4 Bool)
    forall a. IO a -> IO a
    makeGettableStateVar (GettableStateVar (Color4 Bool) -> GettableStateVar (Color4 Bool))
    -> GettableStateVar (Color4 Bool) -> GettableStateVar (Color4 Bool)
    forall a b. (a -> b) -> a -> b
    $
          (GLint -> GLint -> GLint -> GLint -> Color4 Bool)
    -> PName4I -> GettableStateVar (Color4 Bool)
    forall p a.
    GetPName4I p =>
    (GLint -> GLint -> GLint -> GLint -> a) -> p -> IO a
    forall a.
    (GLint -> GLint -> GLint -> GLint -> a) -> PName4I -> IO a
    getInteger4 (\GLint
    r GLint
    g GLint
    b GLint
    a -> Bool -> Bool -> Bool -> Bool -> Color4 Bool
    forall a. a -> a -> a -> a -> Color4 a
    Color4 (GLint -> Bool
    forall a. (Eq a, Num a) => a -> Bool
    unmarshalGLboolean GLint
    r)
                                          (GLint -> Bool
    forall a. (Eq a, Num a) => a -> Bool
    unmarshalGLboolean GLint
    g)
                                          (GLint -> Bool
    forall a. (Eq a, Num a) => a -> Bool
    unmarshalGLboolean GLint
    b)
                                          (GLint -> Bool
    forall a. (Eq a, Num a) => a -> Bool
    unmarshalGLboolean GLint
    a))
                      PName4I
    GetRGBASignedComponents

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

    -- | An operation on the accumulation buffer.

    data AccumOp =
         Accum
         -- ^ Obtains /R/, /G/, /B/, and /A/ values from the buffer currently
         -- selected for reading (see
         -- 'Graphics.Rendering.OpenGL.GL.ReadCopyPixels.readBuffer'). Each
         -- component value is divided by 2^/n/-1, where /n/ is the number of bits
         -- allocated to each color component in the currently selected buffer. The
         -- result is a floating-point value in the range [0, 1], which is
         -- multiplied by the value given to 'accum' and added to the corresponding
         -- pixel component in the accumulation buffer, thereby updating the
         -- accumulation buffer.
       | Load
         -- ^ Similar to 'Accum', except that the current value in the accumulation
         -- buffer is not used in the calculation of the new value. That is, the
         -- /R/, /G/, /B/, and /A/ values from the currently selected buffer are
         -- divided by 2^/n/-1, multiplied by the value given to 'accum', and then
         -- stored in the corresponding accumulation buffer cell, overwriting the
         -- current value.
       | Return
         -- ^ Transfers accumulation buffer values to the color buffer or buffers
         -- currently selected for writing. Each /R/, /G/, /B/, and /A/ component
         -- is multiplied by the value given to 'accum', then multiplied by 2^/n/-1,
         -- clamped to the range [0, 2^/n/-1], and stored in the corresponding
         -- display buffer cell. The only fragment operations that are applied to
         -- this transfer are pixel ownership, scissor, dithering, and color
         -- writemasks.
       | Mult
         -- ^ Multiplies each /R/, /G/, /B/, and /A/ in the accumulation buffer by
         -- the value given to 'accum' and returns the scaled component to its
         -- corresponding accumulation buffer location.
       | Add
         -- ^ Adds the value given to 'accum' to each /R/, /G/, /B/, and /A/ in the
         -- accumulation buffer.
       deriving ( AccumOp -> AccumOp -> Bool
    (AccumOp -> AccumOp -> Bool)
    -> (AccumOp -> AccumOp -> Bool) -> Eq AccumOp
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: AccumOp -> AccumOp -> Bool
    == :: AccumOp -> AccumOp -> Bool
    $c/= :: AccumOp -> AccumOp -> Bool
    /= :: AccumOp -> AccumOp -> Bool
    Eq, Eq AccumOp
    Eq AccumOp =>
    (AccumOp -> AccumOp -> Ordering)
    -> (AccumOp -> AccumOp -> Bool)
    -> (AccumOp -> AccumOp -> Bool)
    -> (AccumOp -> AccumOp -> Bool)
    -> (AccumOp -> AccumOp -> Bool)
    -> (AccumOp -> AccumOp -> AccumOp)
    -> (AccumOp -> AccumOp -> AccumOp)
    -> Ord AccumOp
    AccumOp -> AccumOp -> Bool
    AccumOp -> AccumOp -> Ordering
    AccumOp -> AccumOp -> AccumOp
    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 :: AccumOp -> AccumOp -> Ordering
    compare :: AccumOp -> AccumOp -> Ordering
    $c< :: AccumOp -> AccumOp -> Bool
    < :: AccumOp -> AccumOp -> Bool
    $c<= :: AccumOp -> AccumOp -> Bool
    <= :: AccumOp -> AccumOp -> Bool
    $c> :: AccumOp -> AccumOp -> Bool
    > :: AccumOp -> AccumOp -> Bool
    $c>= :: AccumOp -> AccumOp -> Bool
    >= :: AccumOp -> AccumOp -> Bool
    $cmax :: AccumOp -> AccumOp -> AccumOp
    max :: AccumOp -> AccumOp -> AccumOp
    $cmin :: AccumOp -> AccumOp -> AccumOp
    min :: AccumOp -> AccumOp -> AccumOp
    Ord, Int -> AccumOp -> ShowS
    [AccumOp] -> ShowS
    AccumOp -> String
    (Int -> AccumOp -> ShowS)
    -> (AccumOp -> String) -> ([AccumOp] -> ShowS) -> Show AccumOp
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> AccumOp -> ShowS
    showsPrec :: Int -> AccumOp -> ShowS
    $cshow :: AccumOp -> String
    show :: AccumOp -> String
    $cshowList :: [AccumOp] -> ShowS
    showList :: [AccumOp] -> ShowS
    Show )

    marshalAccumOp :: AccumOp -> GLenum
    marshalAccumOp :: AccumOp -> GLenum
    marshalAccumOp AccumOp
    x = case AccumOp
    x of
       AccumOp
    Accum -> GLenum
    GL_ACCUM
       AccumOp
    Load -> GLenum
    GL_LOAD
       AccumOp
    Return -> GLenum
    GL_RETURN
       AccumOp
    Mult -> GLenum
    GL_MULT
       AccumOp
    Add -> GLenum
    GL_ADD

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

    -- | The accumulation buffer is an extended-range color buffer. Images are not
    -- rendered into it. Rather, images rendered into one of the color buffers are
    -- added to the contents of the accumulation buffer after rendering. Effects
    -- such as antialiasing (of points, lines, and polygons), motion blur, and
    -- depth of field can be created by accumulating images generated with different
    -- transformation matrices.
    --
    -- Each pixel in the accumulation buffer consists of red, green, blue, and alpha
    -- values. The number of bits per component in the accumulation buffer depends
    -- on the implementation (see 'accumBits'). Regardless of the number of bits per
    -- component, the range of values stored by each component is [-1, 1]. The
    -- accumulation buffer pixels are mapped one-to-one with frame buffer pixels.
    --
    -- 'accum' operates on the accumulation buffer. The first argument selects an
    -- accumulation buffer operation. The second argument, is a floating-point value
    -- to be used in that operation, see 'AccumOp'.
    --
    -- All accumulation buffer operations are limited to the area of the current
    -- scissor box and applied identically to the red, green, blue, and alpha
    -- components of each pixel. If an 'accum' operation results in a value outside
    -- the range [-1, 1], the contents of an accumulation buffer pixel component
    -- are undefined.
    --
    -- To clear the accumulation buffer, use 'clearAccum' to specify the clear
    -- value, then call 'clear' with the accumulation buffer enabled.

    accum :: AccumOp -> GLfloat -> IO ()
    accum :: AccumOp -> GLfloat -> IO ()
    accum = GLenum -> GLfloat -> IO ()
    forall (m :: * -> *). MonadIO m => GLenum -> GLfloat -> m ()
    glAccum (GLenum -> GLfloat -> IO ())
    -> (AccumOp -> GLenum) -> AccumOp -> GLfloat -> IO ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . AccumOp -> GLenum
    marshalAccumOp