    -- #hide
    --------------------------------------------------------------------------------
    -- |
    -- Module      :  Graphics.Rendering.OpenGL.GL.Texturing.TextureTarget
    -- Copyright   :  (c) Sven Panne 2002-2009
    -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
    --
    -- Maintainer  :  sven.panne@aedion.de
    -- Stability   :  stable
    -- Portability :  portable
    --
    -- This is a purely internal module for marshaling texture targets.
    --
    --------------------------------------------------------------------------------

    module Graphics.Rendering.OpenGL.GL.Texturing.TextureTarget (
       TextureTarget(..), marshalTextureTarget, marshalProxyTextureTarget,
       CubeMapTarget(..), marshalCubeMapTarget, unmarshalCubeMapTarget,
    ) where

    import Graphics.Rendering.OpenGL.GL.PixelRectangles
    import Graphics.Rendering.OpenGL.Raw.Core31

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

    data TextureTarget =
         Texture1D
       | Texture2D
       | Texture3D
       | TextureCubeMap
       | TextureRectangle
       deriving ( Eq, Ord, Show )

    marshalTextureTarget :: TextureTarget -> GLenum
    marshalTextureTarget x = case x of
       Texture1D -> gl_TEXTURE_1D
       Texture2D -> gl_TEXTURE_2D
       Texture3D -> gl_TEXTURE_3D
       TextureCubeMap -> gl_TEXTURE_CUBE_MAP
       TextureRectangle -> gl_TEXTURE_RECTANGLE

    marshalProxyTextureTarget :: Proxy -> TextureTarget -> GLenum
    marshalProxyTextureTarget NoProxy x = marshalTextureTarget x
    marshalProxyTextureTarget Proxy   x = case x of
       Texture1D -> gl_PROXY_TEXTURE_1D
       Texture2D -> gl_PROXY_TEXTURE_2D
       Texture3D -> gl_PROXY_TEXTURE_3D
       TextureCubeMap -> gl_PROXY_TEXTURE_CUBE_MAP
       TextureRectangle -> gl_PROXY_TEXTURE_RECTANGLE

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

    data CubeMapTarget =
         TextureCubeMapPositiveX
       | TextureCubeMapNegativeX
       | TextureCubeMapPositiveY
       | TextureCubeMapNegativeY
       | TextureCubeMapPositiveZ
       | TextureCubeMapNegativeZ
       deriving ( Eq, Ord, Show )

    marshalCubeMapTarget :: CubeMapTarget -> GLenum
    marshalCubeMapTarget x = case x of
       TextureCubeMapPositiveX -> gl_TEXTURE_CUBE_MAP_POSITIVE_X
       TextureCubeMapNegativeX -> gl_TEXTURE_CUBE_MAP_NEGATIVE_X
       TextureCubeMapPositiveY -> gl_TEXTURE_CUBE_MAP_POSITIVE_Y
       TextureCubeMapNegativeY -> gl_TEXTURE_CUBE_MAP_NEGATIVE_Y
       TextureCubeMapPositiveZ -> gl_TEXTURE_CUBE_MAP_POSITIVE_Z
       TextureCubeMapNegativeZ -> gl_TEXTURE_CUBE_MAP_NEGATIVE_Z

    unmarshalCubeMapTarget :: GLenum -> CubeMapTarget
    unmarshalCubeMapTarget x
       | x == gl_TEXTURE_CUBE_MAP_POSITIVE_X = TextureCubeMapPositiveX
       | x == gl_TEXTURE_CUBE_MAP_NEGATIVE_X = TextureCubeMapNegativeX
       | x == gl_TEXTURE_CUBE_MAP_POSITIVE_Y = TextureCubeMapPositiveY
       | x == gl_TEXTURE_CUBE_MAP_NEGATIVE_Y = TextureCubeMapNegativeY
       | x == gl_TEXTURE_CUBE_MAP_POSITIVE_Z = TextureCubeMapPositiveZ
       | x == gl_TEXTURE_CUBE_MAP_NEGATIVE_Z = TextureCubeMapNegativeZ
       | otherwise = error $ "unmarshalCubeMapTarget: unknown enum " ++ show x