{-# OPTIONS_HADDOCK hide #-}
--------------------------------------------------------------------------------
-- |
-- Module      :  Graphics.Rendering.OpenGL.GL.PixelFormat
-- Copyright   :  (c) Sven Panne 2002-2019
-- License     :  BSD3
--
-- Maintainer  :  Sven Panne <svenpanne@gmail.com>
-- Stability   :  stable
-- Portability :  portable
--
-- This is a purely internal module for (un-)marshaling PixelFormat.
--
--------------------------------------------------------------------------------

module Graphics.Rendering.OpenGL.GL.PixelFormat (
   PixelFormat(..), marshalPixelFormat, unmarshalPixelFormat
) where

import Graphics.GL

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

data PixelFormat =
     ColorIndex
   | StencilIndex
   | DepthComponent
   | DepthStencil
   | Red
   | Green
   | Blue
   | Alpha
   | RG
   | RGB
   | RGBA
   | Luminance
   | LuminanceAlpha
   | RedInteger
   | GreenInteger
   | BlueInteger
   | AlphaInteger
   | RGInteger
   | RGBInteger
   | RGBAInteger
   | BGRInteger
   | BGRAInteger
   | ABGR
   | BGR
   | BGRA
   | CMYK
   | CMYKA
   | FourTwoTwo
   | FourTwoTwoRev
   | FourTwoTwoAverage
   | FourTwoTwoRevAverage
   | YCBCR422
   deriving ( PixelFormat -> PixelFormat -> Bool
(PixelFormat -> PixelFormat -> Bool)
-> (PixelFormat -> PixelFormat -> Bool) -> Eq PixelFormat
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PixelFormat -> PixelFormat -> Bool
== :: PixelFormat -> PixelFormat -> Bool
$c/= :: PixelFormat -> PixelFormat -> Bool
/= :: PixelFormat -> PixelFormat -> Bool
Eq, Eq PixelFormat
Eq PixelFormat
-> (PixelFormat -> PixelFormat -> Ordering)
-> (PixelFormat -> PixelFormat -> Bool)
-> (PixelFormat -> PixelFormat -> Bool)
-> (PixelFormat -> PixelFormat -> Bool)
-> (PixelFormat -> PixelFormat -> Bool)
-> (PixelFormat -> PixelFormat -> PixelFormat)
-> (PixelFormat -> PixelFormat -> PixelFormat)
-> Ord PixelFormat
PixelFormat -> PixelFormat -> Bool
PixelFormat -> PixelFormat -> Ordering
PixelFormat -> PixelFormat -> PixelFormat
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 :: PixelFormat -> PixelFormat -> Ordering
compare :: PixelFormat -> PixelFormat -> Ordering
$c< :: PixelFormat -> PixelFormat -> Bool
< :: PixelFormat -> PixelFormat -> Bool
$c<= :: PixelFormat -> PixelFormat -> Bool
<= :: PixelFormat -> PixelFormat -> Bool
$c> :: PixelFormat -> PixelFormat -> Bool
> :: PixelFormat -> PixelFormat -> Bool
$c>= :: PixelFormat -> PixelFormat -> Bool
>= :: PixelFormat -> PixelFormat -> Bool
$cmax :: PixelFormat -> PixelFormat -> PixelFormat
max :: PixelFormat -> PixelFormat -> PixelFormat
$cmin :: PixelFormat -> PixelFormat -> PixelFormat
min :: PixelFormat -> PixelFormat -> PixelFormat
Ord, Int -> PixelFormat -> ShowS
[PixelFormat] -> ShowS
PixelFormat -> String
(Int -> PixelFormat -> ShowS)
-> (PixelFormat -> String)
-> ([PixelFormat] -> ShowS)
-> Show PixelFormat
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PixelFormat -> ShowS
showsPrec :: Int -> PixelFormat -> ShowS
$cshow :: PixelFormat -> String
show :: PixelFormat -> String
$cshowList :: [PixelFormat] -> ShowS
showList :: [PixelFormat] -> ShowS
Show )

marshalPixelFormat :: PixelFormat -> GLenum
marshalPixelFormat :: PixelFormat -> GLenum
marshalPixelFormat PixelFormat
x = case PixelFormat
x of
   PixelFormat
ColorIndex -> GLenum
GL_COLOR_INDEX
   PixelFormat
StencilIndex -> GLenum
GL_STENCIL_INDEX
   PixelFormat
DepthComponent -> GLenum
GL_DEPTH_COMPONENT
   PixelFormat
Red -> GLenum
GL_RED
   PixelFormat
Green -> GLenum
GL_GREEN
   PixelFormat
Blue -> GLenum
GL_BLUE
   PixelFormat
Alpha -> GLenum
GL_ALPHA
   PixelFormat
RG -> GLenum
GL_RG
   PixelFormat
RGB -> GLenum
GL_RGB
   PixelFormat
RGBA -> GLenum
GL_RGBA
   PixelFormat
Luminance -> GLenum
GL_LUMINANCE
   PixelFormat
LuminanceAlpha -> GLenum
GL_LUMINANCE_ALPHA
   PixelFormat
RedInteger -> GLenum
GL_RED_INTEGER
   PixelFormat
GreenInteger -> GLenum
GL_GREEN_INTEGER
   PixelFormat
BlueInteger -> GLenum
GL_BLUE_INTEGER
   PixelFormat
AlphaInteger -> GLenum
GL_ALPHA_INTEGER
   PixelFormat
RGInteger -> GLenum
GL_RG_INTEGER
   PixelFormat
RGBInteger -> GLenum
GL_RGB_INTEGER
   PixelFormat
RGBAInteger -> GLenum
GL_RGBA_INTEGER
   PixelFormat
BGRInteger -> GLenum
GL_BGR_INTEGER
   PixelFormat
BGRAInteger -> GLenum
GL_BGRA_INTEGER
   PixelFormat
ABGR -> GLenum
GL_ABGR_EXT
   PixelFormat
BGR -> GLenum
GL_BGR
   PixelFormat
BGRA -> GLenum
GL_BGRA
   PixelFormat
CMYK -> GLenum
GL_CMYK_EXT
   PixelFormat
CMYKA -> GLenum
GL_CMYKA_EXT
   PixelFormat
FourTwoTwo -> GLenum
GL_422_EXT
   PixelFormat
FourTwoTwoRev -> GLenum
GL_422_REV_EXT
   PixelFormat
FourTwoTwoAverage -> GLenum
GL_422_AVERAGE_EXT
   PixelFormat
FourTwoTwoRevAverage -> GLenum
GL_422_REV_AVERAGE_EXT
   PixelFormat
YCBCR422 -> GLenum
GL_YCBCR_422_APPLE
   PixelFormat
DepthStencil -> GLenum
GL_DEPTH_STENCIL

unmarshalPixelFormat :: GLenum -> PixelFormat
unmarshalPixelFormat :: GLenum -> PixelFormat
unmarshalPixelFormat GLenum
x
   | GLenum
x GLenum -> GLenum -> Bool
forall a. Eq a => a -> a -> Bool
== GLenum
GL_COLOR_INDEX = PixelFormat
ColorIndex
   | GLenum
x GLenum -> GLenum -> Bool
forall a. Eq a => a -> a -> Bool
== GLenum
GL_STENCIL_INDEX = PixelFormat
StencilIndex
   | GLenum
x GLenum -> GLenum -> Bool
forall a. Eq a => a -> a -> Bool
== GLenum
GL_DEPTH_COMPONENT = PixelFormat
DepthComponent
   | GLenum
x GLenum -> GLenum -> Bool
forall a. Eq a => a -> a -> Bool
== GLenum
GL_RED = PixelFormat
Red
   | GLenum
x GLenum -> GLenum -> Bool
forall a. Eq a => a -> a -> Bool
== GLenum
GL_GREEN = PixelFormat
Green
   | GLenum
x GLenum -> GLenum -> Bool
forall a. Eq a => a -> a -> Bool
== GLenum
GL_BLUE = PixelFormat
Blue
   | GLenum
x GLenum -> GLenum -> Bool
forall a. Eq a => a -> a -> Bool
== GLenum
GL_ALPHA = PixelFormat
Alpha
   | GLenum
x GLenum -> GLenum -> Bool
forall a. Eq a => a -> a -> Bool
== GLenum
GL_RG = PixelFormat
RG
   | GLenum
x GLenum -> GLenum -> Bool
forall a. Eq a => a -> a -> Bool
== GLenum
GL_RGB = PixelFormat
RGB
   | GLenum
x GLenum -> GLenum -> Bool
forall a. Eq a => a -> a -> Bool
== GLenum
GL_RGBA = PixelFormat
RGBA
   | GLenum
x GLenum -> GLenum -> Bool
forall a. Eq a => a -> a -> Bool
== GLenum
GL_LUMINANCE = PixelFormat
Luminance
   | GLenum
x GLenum -> GLenum -> Bool
forall a. Eq a => a -> a -> Bool
== GLenum
GL_LUMINANCE_ALPHA = PixelFormat
LuminanceAlpha
   | GLenum
x GLenum -> GLenum -> Bool
forall a. Eq a => a -> a -> Bool
== GLenum
GL_RED_INTEGER = PixelFormat
RedInteger
   | GLenum
x GLenum -> GLenum -> Bool
forall a. Eq a => a -> a -> Bool
== GLenum
GL_GREEN_INTEGER = PixelFormat
GreenInteger
   | GLenum
x GLenum -> GLenum -> Bool
forall a. Eq a => a -> a -> Bool
== GLenum
GL_BLUE_INTEGER = PixelFormat
BlueInteger
   | GLenum
x GLenum -> GLenum -> Bool
forall a. Eq a => a -> a -> Bool
== GLenum
GL_ALPHA_INTEGER = PixelFormat
AlphaInteger
   | GLenum
x GLenum -> GLenum -> Bool
forall a. Eq a => a -> a -> Bool
== GLenum
GL_RG_INTEGER = PixelFormat
RGInteger
   | GLenum
x GLenum -> GLenum -> Bool
forall a. Eq a => a -> a -> Bool
== GLenum
GL_RGB_INTEGER = PixelFormat
RGBInteger
   | GLenum
x GLenum -> GLenum -> Bool
forall a. Eq a => a -> a -> Bool
== GLenum
GL_RGBA_INTEGER = PixelFormat
RGBAInteger
   | GLenum
x GLenum -> GLenum -> Bool
forall a. Eq a => a -> a -> Bool
== GLenum
GL_BGR_INTEGER = PixelFormat
BGRInteger
   | GLenum
x GLenum -> GLenum -> Bool
forall a. Eq a => a -> a -> Bool
== GLenum
GL_BGRA_INTEGER = PixelFormat
BGRAInteger
   | GLenum
x GLenum -> GLenum -> Bool
forall a. Eq a => a -> a -> Bool
== GLenum
GL_ABGR_EXT = PixelFormat
ABGR
   | GLenum
x GLenum -> GLenum -> Bool
forall a. Eq a => a -> a -> Bool
== GLenum
GL_BGR = PixelFormat
BGR
   | GLenum
x GLenum -> GLenum -> Bool
forall a. Eq a => a -> a -> Bool
== GLenum
GL_BGRA = PixelFormat
BGRA
   | GLenum
x GLenum -> GLenum -> Bool
forall a. Eq a => a -> a -> Bool
== GLenum
GL_CMYK_EXT = PixelFormat
CMYK
   | GLenum
x GLenum -> GLenum -> Bool
forall a. Eq a => a -> a -> Bool
== GLenum
GL_CMYKA_EXT = PixelFormat
CMYKA
   | GLenum
x GLenum -> GLenum -> Bool
forall a. Eq a => a -> a -> Bool
== GLenum
GL_422_EXT = PixelFormat
FourTwoTwo
   | GLenum
x GLenum -> GLenum -> Bool
forall a. Eq a => a -> a -> Bool
== GLenum
GL_422_REV_EXT = PixelFormat
FourTwoTwoRev
   | GLenum
x GLenum -> GLenum -> Bool
forall a. Eq a => a -> a -> Bool
== GLenum
GL_422_AVERAGE_EXT = PixelFormat
FourTwoTwoAverage
   | GLenum
x GLenum -> GLenum -> Bool
forall a. Eq a => a -> a -> Bool
== GLenum
GL_422_REV_AVERAGE_EXT = PixelFormat
FourTwoTwoRevAverage
   | GLenum
x GLenum -> GLenum -> Bool
forall a. Eq a => a -> a -> Bool
== GLenum
GL_YCBCR_422_APPLE = PixelFormat
YCBCR422
   | GLenum
x GLenum -> GLenum -> Bool
forall a. Eq a => a -> a -> Bool
== GLenum
GL_DEPTH_STENCIL = PixelFormat
DepthStencil
   | Bool
otherwise = String -> PixelFormat
forall a. HasCallStack => String -> a
error (String
"unmarshalPixelFormat: illegal value " String -> ShowS
forall a. [a] -> [a] -> [a]
++ GLenum -> String
forall a. Show a => a -> String
show GLenum
x)