    -----------------------------------------------------------------------------
    -- |
    -- Module      :  Graphics.Rendering.OpenGL.GL.FramebufferObjects.Attachments
    -- Copyright   :  (c) Sven Panne 2011-2019, Lars Corbijn 2011-2016
    -- License     :  BSD3
    --
    -- Maintainer  :  Sven Panne <svenpanne@gmail.com>
    -- Stability   :  stable
    -- Portability :  portable
    --
    -----------------------------------------------------------------------------

    module Graphics.Rendering.OpenGL.GL.FramebufferObjects.Attachments (
       FramebufferObjectAttachment(..),

       fboaToBufferMode, fboaFromBufferMode,

       FramebufferAttachment(..),

       framebufferRenderbuffer, framebufferTexture1D, framebufferTexture2D,
       framebufferTexture3D, framebufferTextureLayer
    ) where

    import Graphics.Rendering.OpenGL.GL.FramebufferObjects.FramebufferObjectAttachment
    import Graphics.Rendering.OpenGL.GL.FramebufferObjects.FramebufferTarget
    import Graphics.Rendering.OpenGL.GL.FramebufferObjects.RenderbufferObject
    import Graphics.Rendering.OpenGL.GL.FramebufferObjects.RenderbufferTarget
    import Graphics.Rendering.OpenGL.GL.Texturing.Specification
    import Graphics.Rendering.OpenGL.GL.Texturing.TextureObject
    import Graphics.Rendering.OpenGL.GL.Texturing.TextureTarget
    import Graphics.Rendering.OpenGL.GLU.ErrorsInternal
    import Graphics.GL

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

    framebufferRenderbuffer :: FramebufferTarget -> FramebufferObjectAttachment
       -> RenderbufferTarget -> RenderbufferObject -> IO ()
    framebufferRenderbuffer :: FramebufferTarget
    -> FramebufferObjectAttachment
    -> RenderbufferTarget
    -> RenderbufferObject
    -> IO ()
    framebufferRenderbuffer FramebufferTarget
    fbt FramebufferObjectAttachment
    fba RenderbufferTarget
    rbt (RenderbufferObject GLuint
    rboi) =
       IO () -> (GLuint -> IO ()) -> Maybe GLuint -> IO ()
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe IO ()
    recordInvalidValue (\GLuint
    mfba ->  GLuint -> GLuint -> GLuint -> GLuint -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLuint -> GLuint -> GLuint -> GLuint -> m ()
    glFramebufferRenderbuffer (FramebufferTarget -> GLuint
    marshalFramebufferTarget FramebufferTarget
    fbt)
          GLuint
    mfba (RenderbufferTarget -> GLuint
    marshalRenderbufferTarget RenderbufferTarget
    rbt) GLuint
    rboi) (Maybe GLuint -> IO ()) -> Maybe GLuint -> IO ()
    forall a b. (a -> b) -> a -> b
    $ FramebufferObjectAttachment -> Maybe GLuint
    marshalFramebufferObjectAttachment FramebufferObjectAttachment
    fba

    framebufferTexture1D :: FramebufferTarget -> FramebufferObjectAttachment
       -> TextureTarget1D -> TextureObject -> Level -> IO ()
    framebufferTexture1D :: FramebufferTarget
    -> FramebufferObjectAttachment
    -> TextureTarget1D
    -> TextureObject
    -> Level
    -> IO ()
    framebufferTexture1D FramebufferTarget
    fbt FramebufferObjectAttachment
    fba TextureTarget1D
    tt (TextureObject GLuint
    t) Level
    l  =  IO () -> (GLuint -> IO ()) -> Maybe GLuint -> IO ()
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe IO ()
    recordInvalidValue
       (\GLuint
    mfba -> GLuint -> GLuint -> GLuint -> GLuint -> Level -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLuint -> GLuint -> GLuint -> GLuint -> Level -> m ()
    glFramebufferTexture1D (FramebufferTarget -> GLuint
    marshalFramebufferTarget FramebufferTarget
    fbt) GLuint
    mfba
          (TextureTarget1D -> GLuint
    forall t. QueryableTextureTarget t => t -> GLuint
    marshalQueryableTextureTarget TextureTarget1D
    tt) GLuint
    t Level
    l) (Maybe GLuint -> IO ()) -> Maybe GLuint -> IO ()
    forall a b. (a -> b) -> a -> b
    $ FramebufferObjectAttachment -> Maybe GLuint
    marshalFramebufferObjectAttachment FramebufferObjectAttachment
    fba

    -- Note: Typing is too permissive, no TEXTURE_1D_ARRAY allowed per 4.4. spec.
    framebufferTexture2D :: FramebufferTarget -> FramebufferObjectAttachment
       -> TextureTarget2D -> TextureObject -> Level -> IO ()
    framebufferTexture2D :: FramebufferTarget
    -> FramebufferObjectAttachment
    -> TextureTarget2D
    -> TextureObject
    -> Level
    -> IO ()
    framebufferTexture2D FramebufferTarget
    fbt FramebufferObjectAttachment
    fba TextureTarget2D
    tt (TextureObject GLuint
    t) Level
    l = IO () -> (GLuint -> IO ()) -> Maybe GLuint -> IO ()
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe IO ()
    recordInvalidValue
       (\GLuint
    mfba -> GLuint -> GLuint -> GLuint -> GLuint -> Level -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLuint -> GLuint -> GLuint -> GLuint -> Level -> m ()
    glFramebufferTexture2D (FramebufferTarget -> GLuint
    marshalFramebufferTarget FramebufferTarget
    fbt) GLuint
    mfba
          (TextureTarget2D -> GLuint
    forall t. QueryableTextureTarget t => t -> GLuint
    marshalQueryableTextureTarget TextureTarget2D
    tt) GLuint
    t Level
    l)
             (Maybe GLuint -> IO ()) -> Maybe GLuint -> IO ()
    forall a b. (a -> b) -> a -> b
    $ FramebufferObjectAttachment -> Maybe GLuint
    marshalFramebufferObjectAttachment FramebufferObjectAttachment
    fba

    -- Note: Typing is too permissive, no TEXTURE_2D_ARRAY or TEXTURE_2D_MULTISAMPLE_ARRAY allowed per 4.4. spec.
    framebufferTexture3D :: FramebufferTarget -> FramebufferObjectAttachment
       -> TextureTarget3D -> TextureObject -> Level -> GLint -> IO ()
    framebufferTexture3D :: FramebufferTarget
    -> FramebufferObjectAttachment
    -> TextureTarget3D
    -> TextureObject
    -> Level
    -> Level
    -> IO ()
    framebufferTexture3D FramebufferTarget
    fbt FramebufferObjectAttachment
    fba TextureTarget3D
    tt (TextureObject GLuint
    t) Level
    le Level
    la = IO () -> (GLuint -> IO ()) -> Maybe GLuint -> IO ()
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe IO ()
    recordInvalidValue
       (\GLuint
    mfba -> GLuint -> GLuint -> GLuint -> GLuint -> Level -> Level -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLuint -> GLuint -> GLuint -> GLuint -> Level -> Level -> m ()
    glFramebufferTexture3D (FramebufferTarget -> GLuint
    marshalFramebufferTarget FramebufferTarget
    fbt) GLuint
    mfba
          (TextureTarget3D -> GLuint
    forall t. QueryableTextureTarget t => t -> GLuint
    marshalQueryableTextureTarget TextureTarget3D
    tt) GLuint
    t Level
    le Level
    la) (Maybe GLuint -> IO ()) -> Maybe GLuint -> IO ()
    forall a b. (a -> b) -> a -> b
    $ FramebufferObjectAttachment -> Maybe GLuint
    marshalFramebufferObjectAttachment FramebufferObjectAttachment
    fba

    framebufferTextureLayer :: FramebufferTarget -> FramebufferObjectAttachment
       -> TextureObject -> Level -> GLint -> IO()
    framebufferTextureLayer :: FramebufferTarget
    -> FramebufferObjectAttachment
    -> TextureObject
    -> Level
    -> Level
    -> IO ()
    framebufferTextureLayer FramebufferTarget
    fbt FramebufferObjectAttachment
    fba (TextureObject GLuint
    t) Level
    le Level
    la = IO () -> (GLuint -> IO ()) -> Maybe GLuint -> IO ()
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe IO ()
    recordInvalidValue
       (\GLuint
    mfba -> GLuint -> GLuint -> GLuint -> Level -> Level -> IO ()
    forall (m :: * -> *).
    MonadIO m =>
    GLuint -> GLuint -> GLuint -> Level -> Level -> m ()
    glFramebufferTextureLayer (FramebufferTarget -> GLuint
    marshalFramebufferTarget FramebufferTarget
    fbt)
          GLuint
    mfba GLuint
    t Level
    le Level
    la) (Maybe GLuint -> IO ()) -> Maybe GLuint -> IO ()
    forall a b. (a -> b) -> a -> b
    $ FramebufferObjectAttachment -> Maybe GLuint
    marshalFramebufferObjectAttachment FramebufferObjectAttachment
    fba