{-# 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
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Face -> Face -> Bool
$c/= :: Face -> Face -> Bool
== :: Face -> Face -> Bool
$c== :: Face -> Face -> Bool
Eq, Eq 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
min :: Face -> Face -> Face
$cmin :: Face -> Face -> Face
max :: Face -> Face -> Face
$cmax :: Face -> Face -> Face
>= :: Face -> Face -> Bool
$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
compare :: Face -> Face -> Ordering
$ccompare :: Face -> Face -> Ordering
Ord, Int -> Face -> ShowS
[Face] -> ShowS
Face -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Face] -> ShowS
$cshowList :: [Face] -> ShowS
show :: Face -> String
$cshow :: Face -> String
showsPrec :: Int -> Face -> ShowS
$cshowsPrec :: Int -> 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 forall a. Eq a => a -> a -> Bool
== GLenum
GL_FRONT = Face
Front
   | GLenum
x forall a. Eq a => a -> a -> Bool
== GLenum
GL_BACK = Face
Back
   | GLenum
x forall a. Eq a => a -> a -> Bool
== GLenum
GL_FRONT_AND_BACK = Face
FrontAndBack
   | Bool
otherwise = forall a. HasCallStack => String -> a
error (String
"unmarshalFace: illegal value " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show GLenum
x)