{-# OPTIONS_HADDOCK hide #-}
--------------------------------------------------------------------------------
-- |
-- Module      :  Graphics.Rendering.OpenGL.GL.Face
-- 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 Face.
--
--------------------------------------------------------------------------------

module Graphics.Rendering.OpenGL.GL.Face (
   Face(..), marshalFace, unmarshalFace
) where

import Graphics.GL

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

data Face =
     Front
   | Back
   | FrontAndBack
   deriving ( Face -> Face -> Bool
(Face -> Face -> Bool) -> (Face -> Face -> Bool) -> Eq Face
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Face -> Face -> Bool
== :: Face -> Face -> Bool
$c/= :: Face -> Face -> Bool
/= :: Face -> Face -> Bool
Eq, Eq Face
Eq Face
-> (Face -> Face -> Ordering)
-> (Face -> Face -> Bool)
-> (Face -> Face -> Bool)
-> (Face -> Face -> Bool)
-> (Face -> Face -> Bool)
-> (Face -> Face -> Face)
-> (Face -> Face -> Face)
-> Ord Face
Face -> Face -> Bool
Face -> Face -> Ordering
Face -> Face -> Face
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 :: Face -> Face -> Ordering
compare :: Face -> Face -> Ordering
$c< :: Face -> Face -> Bool
< :: Face -> Face -> Bool
$c<= :: Face -> Face -> Bool
<= :: Face -> Face -> Bool
$c> :: Face -> Face -> Bool
> :: Face -> Face -> Bool
$c>= :: Face -> Face -> Bool
>= :: Face -> Face -> Bool
$cmax :: Face -> Face -> Face
max :: Face -> Face -> Face
$cmin :: Face -> Face -> Face
min :: Face -> Face -> Face
Ord, Int -> Face -> ShowS
[Face] -> ShowS
Face -> String
(Int -> Face -> ShowS)
-> (Face -> String) -> ([Face] -> ShowS) -> Show Face
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Face -> ShowS
showsPrec :: Int -> Face -> ShowS
$cshow :: Face -> String
show :: Face -> String
$cshowList :: [Face] -> ShowS
showList :: [Face] -> ShowS
Show )

marshalFace :: Face -> GLenum
marshalFace :: Face -> GLenum
marshalFace Face
x = case Face
x of
   Face
Front -> GLenum
GL_FRONT
   Face
Back -> GLenum
GL_BACK
   Face
FrontAndBack -> GLenum
GL_FRONT_AND_BACK

unmarshalFace :: GLenum -> Face
unmarshalFace :: GLenum -> Face
unmarshalFace GLenum
x
   | GLenum
x GLenum -> GLenum -> Bool
forall a. Eq a => a -> a -> Bool
== GLenum
GL_FRONT = Face
Front
   | GLenum
x GLenum -> GLenum -> Bool
forall a. Eq a => a -> a -> Bool
== GLenum
GL_BACK = Face
Back
   | GLenum
x GLenum -> GLenum -> Bool
forall a. Eq a => a -> a -> Bool
== GLenum
GL_FRONT_AND_BACK = Face
FrontAndBack
   | Bool
otherwise = String -> Face
forall a. HasCallStack => String -> a
error (String
"unmarshalFace: illegal value " String -> ShowS
forall a. [a] -> [a] -> [a]
++ GLenum -> String
forall a. Show a => a -> String
show GLenum
x)