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

    module Graphics.Rendering.OpenGL.GL.PolygonMode (
       PolygonMode(..), marshalPolygonMode, unmarshalPolygonMode
    ) where

    import Graphics.GL

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

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

    marshalPolygonMode :: PolygonMode -> GLenum
    marshalPolygonMode :: PolygonMode -> GLenum
    marshalPolygonMode PolygonMode
    x = case PolygonMode
    x of
       PolygonMode
    Point -> GLenum
    GL_POINT
       PolygonMode
    Line -> GLenum
    GL_LINE
       PolygonMode
    Fill -> GLenum
    GL_FILL

    unmarshalPolygonMode :: GLenum -> PolygonMode
    unmarshalPolygonMode :: GLenum -> PolygonMode
    unmarshalPolygonMode GLenum
    x
       | GLenum
    x GLenum -> GLenum -> Bool
    forall a. Eq a => a -> a -> Bool
    == GLenum
    GL_POINT = PolygonMode
    Point
       | GLenum
    x GLenum -> GLenum -> Bool
    forall a. Eq a => a -> a -> Bool
    == GLenum
    GL_LINE = PolygonMode
    Line
       | GLenum
    x GLenum -> GLenum -> Bool
    forall a. Eq a => a -> a -> Bool
    == GLenum
    GL_FILL = PolygonMode
    Fill
       | Bool
    otherwise = String -> PolygonMode
    forall a. HasCallStack => String -> a
    error (String
    "unmarshalPolygonMode: illegal value " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ GLenum -> String
    forall a. Show a => a -> String
    show GLenum
    x)