{-# 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
/= :: PixelFormat -> PixelFormat -> Bool
$c/= :: PixelFormat -> PixelFormat -> Bool
== :: PixelFormat -> PixelFormat -> Bool
$c== :: 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
min :: PixelFormat -> PixelFormat -> PixelFormat
$cmin :: PixelFormat -> PixelFormat -> PixelFormat
max :: PixelFormat -> PixelFormat -> PixelFormat
$cmax :: PixelFormat -> PixelFormat -> PixelFormat
>= :: PixelFormat -> PixelFormat -> Bool
$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
compare :: PixelFormat -> PixelFormat -> Ordering
$ccompare :: PixelFormat -> PixelFormat -> Ordering
$cp1Ord :: Eq 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
showList :: [PixelFormat] -> ShowS
$cshowList :: [PixelFormat] -> ShowS
show :: PixelFormat -> String
$cshow :: PixelFormat -> String
showsPrec :: Int -> PixelFormat -> ShowS
$cshowsPrec :: Int -> PixelFormat -> ShowS
Show )

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

unmarshalPixelFormat :: GLenum -> PixelFormat
unmarshalPixelFormat :: GLenum -> PixelFormat
unmarshalPixelFormat x :: 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 ("unmarshalPixelFormat: illegal value " String -> ShowS
forall a. [a] -> [a] -> [a]
++ GLenum -> String
forall a. Show a => a -> String
show GLenum
x)