--------------------------------------------------------------------------------
-- |
-- Module      :  Graphics.Rendering.OpenGL.GLU.NURBS
-- Copyright   :  (c) Sven Panne 2002-2019
-- License     :  BSD3
--
-- Maintainer  :  Sven Panne <svenpanne@gmail.com>
-- Stability   :  stable
-- Portability :  portable
--
-- This module corresponds to chapter 7 (NURBS) of the GLU specs.
--
--------------------------------------------------------------------------------

module Graphics.Rendering.OpenGL.GLU.NURBS (
   NURBSObj, withNURBSObj,
   NURBSBeginCallback, withNURBSBeginCallback,
   NURBSVertexCallback, withNURBSVertexCallback,
   NURBSNormalCallback, withNURBSNormalCallback,
   NURBSColorCallback, withNURBSColorCallback,
   NURBSEndCallback, withNURBSEndCallback,
   checkForNURBSError,
   nurbsBeginEndCurve, nurbsCurve,
   nurbsBeginEndSurface, nurbsSurface,
   TrimmingPoint, nurbsBeginEndTrim, pwlCurve, trimmingCurve,
   NURBSMode(..), setNURBSMode,
   setNURBSCulling,
   SamplingMethod(..), setSamplingMethod,
   loadSamplingMatrices,
   DisplayMode'(..), setDisplayMode'
) where

import Control.Monad
import Foreign.Marshal.Array
import Foreign.Ptr
import Foreign.Storable
import Graphics.GLU hiding (
   NURBSBeginCallback, NURBSVertexCallback, NURBSNormalCallback,
   NURBSColorCallback, NURBSEndCallback )
import Graphics.Rendering.OpenGL.GL.Tensor
import Graphics.Rendering.OpenGL.GL.Capability
import Graphics.Rendering.OpenGL.GL.ControlPoint
import Graphics.Rendering.OpenGL.GL.CoordTrans
import Graphics.Rendering.OpenGL.GL.Exception
import Graphics.Rendering.OpenGL.GL.GLboolean
import Graphics.Rendering.OpenGL.GL.PrimitiveMode
import Graphics.Rendering.OpenGL.GL.PrimitiveModeInternal
import Graphics.Rendering.OpenGL.GL.VertexSpec
import Graphics.Rendering.OpenGL.GLU.ErrorsInternal
import Graphics.GL

--------------------------------------------------------------------------------
-- chapter 7.1: The NURBS Object

-- an opaque pointer to a NURBS object
type NURBSObj = Ptr GLUnurbs

isNullNURBSObj :: NURBSObj -> Bool
isNullNURBSObj :: Ptr GLUnurbs -> Bool
isNullNURBSObj = (Ptr GLUnurbs
forall a. Ptr a
nullPtr Ptr GLUnurbs -> Ptr GLUnurbs -> Bool
forall a. Eq a => a -> a -> Bool
==)

withNURBSObj :: a -> (NURBSObj -> IO a) -> IO a
withNURBSObj :: forall a. a -> (Ptr GLUnurbs -> IO a) -> IO a
withNURBSObj a
failureValue Ptr GLUnurbs -> IO a
action =
   IO (Ptr GLUnurbs)
-> (Ptr GLUnurbs -> IO ()) -> (Ptr GLUnurbs -> IO a) -> IO a
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket IO (Ptr GLUnurbs)
forall (m :: * -> *). MonadIO m => m (Ptr GLUnurbs)
gluNewNurbsRenderer Ptr GLUnurbs -> IO ()
safeDeleteNurbsRenderer
           (\Ptr GLUnurbs
nurbsObj -> if Ptr GLUnurbs -> Bool
isNullNURBSObj Ptr GLUnurbs
nurbsObj
                            then do IO ()
recordOutOfMemory
                                    a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return a
failureValue
                            else Ptr GLUnurbs -> IO a
action Ptr GLUnurbs
nurbsObj)

safeDeleteNurbsRenderer :: NURBSObj -> IO ()
safeDeleteNurbsRenderer :: Ptr GLUnurbs -> IO ()
safeDeleteNurbsRenderer Ptr GLUnurbs
nurbsObj =
   Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (Ptr GLUnurbs -> Bool
isNullNURBSObj Ptr GLUnurbs
nurbsObj) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ Ptr GLUnurbs -> IO ()
forall (m :: * -> *). MonadIO m => Ptr GLUnurbs -> m ()
gluDeleteNurbsRenderer Ptr GLUnurbs
nurbsObj

--------------------------------------------------------------------------------
-- chapter 7.2: Callbacks (begin)

type NURBSBeginCallback = PrimitiveMode -> IO ()

withNURBSBeginCallback :: NURBSObj -> NURBSBeginCallback -> IO a -> IO a
withNURBSBeginCallback :: forall a. Ptr GLUnurbs -> NURBSBeginCallback -> IO a -> IO a
withNURBSBeginCallback Ptr GLUnurbs
nurbsObj NURBSBeginCallback
beginCallback IO a
action =
   IO (FunPtr NURBSBeginCallback)
-> (FunPtr NURBSBeginCallback -> IO ())
-> (FunPtr NURBSBeginCallback -> IO a)
-> IO a
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (NURBSBeginCallback -> IO (FunPtr NURBSBeginCallback)
makeNURBSBeginCallback (NURBSBeginCallback
beginCallback NURBSBeginCallback
-> (GLenum -> PrimitiveMode) -> NURBSBeginCallback
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GLenum -> PrimitiveMode
unmarshalPrimitiveMode))
           FunPtr NURBSBeginCallback -> IO ()
forall a. FunPtr a -> IO ()
freeHaskellFunPtr ((FunPtr NURBSBeginCallback -> IO a) -> IO a)
-> (FunPtr NURBSBeginCallback -> IO a) -> IO a
forall a b. (a -> b) -> a -> b
$ \FunPtr NURBSBeginCallback
callbackPtr -> do
      Ptr GLUnurbs -> GLenum -> FunPtr NURBSBeginCallback -> IO ()
forall (m :: * -> *) a.
MonadIO m =>
Ptr GLUnurbs -> GLenum -> FunPtr a -> m ()
gluNurbsCallback Ptr GLUnurbs
nurbsObj GLenum
GLU_NURBS_BEGIN FunPtr NURBSBeginCallback
callbackPtr
      IO a
action

--------------------------------------------------------------------------------
-- chapter 7.2: Callbacks (vertex)

type NURBSVertexCallback = Vertex3 GLfloat -> IO ()

withNURBSVertexCallback :: NURBSObj -> NURBSVertexCallback -> IO a -> IO a
withNURBSVertexCallback :: forall a. Ptr GLUnurbs -> NURBSVertexCallback -> IO a -> IO a
withNURBSVertexCallback Ptr GLUnurbs
nurbsObj NURBSVertexCallback
vertexCallback IO a
action =
   IO (FunPtr NURBSVertexCallback)
-> (FunPtr NURBSVertexCallback -> IO ())
-> (FunPtr NURBSVertexCallback -> IO a)
-> IO a
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (NURBSVertexCallback -> IO (FunPtr NURBSVertexCallback)
makeNURBSVertexCallback (\Ptr GLfloat
p -> Ptr (Vertex3 GLfloat) -> IO (Vertex3 GLfloat)
forall a. Storable a => Ptr a -> IO a
peek (Ptr GLfloat -> Ptr (Vertex3 GLfloat)
forall a b. Ptr a -> Ptr b
castPtr Ptr GLfloat
p) IO (Vertex3 GLfloat) -> NURBSVertexCallback -> IO ()
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= NURBSVertexCallback
vertexCallback))
           FunPtr NURBSVertexCallback -> IO ()
forall a. FunPtr a -> IO ()
freeHaskellFunPtr ((FunPtr NURBSVertexCallback -> IO a) -> IO a)
-> (FunPtr NURBSVertexCallback -> IO a) -> IO a
forall a b. (a -> b) -> a -> b
$ \FunPtr NURBSVertexCallback
callbackPtr -> do
      Ptr GLUnurbs -> GLenum -> FunPtr NURBSVertexCallback -> IO ()
forall (m :: * -> *) a.
MonadIO m =>
Ptr GLUnurbs -> GLenum -> FunPtr a -> m ()
gluNurbsCallback Ptr GLUnurbs
nurbsObj GLenum
GLU_NURBS_VERTEX FunPtr NURBSVertexCallback
callbackPtr
      IO a
action

--------------------------------------------------------------------------------
-- chapter 7.2: Callbacks (normal)

type NURBSNormalCallback = Normal3 GLfloat -> IO ()

withNURBSNormalCallback :: NURBSObj -> NURBSNormalCallback -> IO a -> IO a
withNURBSNormalCallback :: forall a. Ptr GLUnurbs -> NURBSNormalCallback -> IO a -> IO a
withNURBSNormalCallback Ptr GLUnurbs
nurbsObj NURBSNormalCallback
normalCallback IO a
action =
   IO (FunPtr NURBSVertexCallback)
-> (FunPtr NURBSVertexCallback -> IO ())
-> (FunPtr NURBSVertexCallback -> IO a)
-> IO a
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (NURBSVertexCallback -> IO (FunPtr NURBSVertexCallback)
makeNURBSNormalCallback (\Ptr GLfloat
p -> Ptr (Normal3 GLfloat) -> IO (Normal3 GLfloat)
forall a. Storable a => Ptr a -> IO a
peek (Ptr GLfloat -> Ptr (Normal3 GLfloat)
forall a b. Ptr a -> Ptr b
castPtr Ptr GLfloat
p) IO (Normal3 GLfloat) -> NURBSNormalCallback -> IO ()
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= NURBSNormalCallback
normalCallback))
           FunPtr NURBSVertexCallback -> IO ()
forall a. FunPtr a -> IO ()
freeHaskellFunPtr ((FunPtr NURBSVertexCallback -> IO a) -> IO a)
-> (FunPtr NURBSVertexCallback -> IO a) -> IO a
forall a b. (a -> b) -> a -> b
$ \FunPtr NURBSVertexCallback
callbackPtr -> do
      Ptr GLUnurbs -> GLenum -> FunPtr NURBSVertexCallback -> IO ()
forall (m :: * -> *) a.
MonadIO m =>
Ptr GLUnurbs -> GLenum -> FunPtr a -> m ()
gluNurbsCallback Ptr GLUnurbs
nurbsObj GLenum
GLU_NURBS_NORMAL FunPtr NURBSVertexCallback
callbackPtr
      IO a
action

--------------------------------------------------------------------------------
-- chapter 7.2: Callbacks (color)

type NURBSColorCallback = Color4 GLfloat -> IO ()

withNURBSColorCallback :: NURBSObj -> NURBSColorCallback -> IO a -> IO a
withNURBSColorCallback :: forall a. Ptr GLUnurbs -> NURBSColorCallback -> IO a -> IO a
withNURBSColorCallback Ptr GLUnurbs
nurbsObj NURBSColorCallback
colorCallback IO a
action =
   IO (FunPtr NURBSVertexCallback)
-> (FunPtr NURBSVertexCallback -> IO ())
-> (FunPtr NURBSVertexCallback -> IO a)
-> IO a
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (NURBSVertexCallback -> IO (FunPtr NURBSVertexCallback)
makeNURBSColorCallback (\Ptr GLfloat
p -> Ptr (Color4 GLfloat) -> IO (Color4 GLfloat)
forall a. Storable a => Ptr a -> IO a
peek (Ptr GLfloat -> Ptr (Color4 GLfloat)
forall a b. Ptr a -> Ptr b
castPtr Ptr GLfloat
p) IO (Color4 GLfloat) -> NURBSColorCallback -> IO ()
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= NURBSColorCallback
colorCallback))
           FunPtr NURBSVertexCallback -> IO ()
forall a. FunPtr a -> IO ()
freeHaskellFunPtr ((FunPtr NURBSVertexCallback -> IO a) -> IO a)
-> (FunPtr NURBSVertexCallback -> IO a) -> IO a
forall a b. (a -> b) -> a -> b
$ \FunPtr NURBSVertexCallback
callbackPtr -> do
      Ptr GLUnurbs -> GLenum -> FunPtr NURBSVertexCallback -> IO ()
forall (m :: * -> *) a.
MonadIO m =>
Ptr GLUnurbs -> GLenum -> FunPtr a -> m ()
gluNurbsCallback Ptr GLUnurbs
nurbsObj GLenum
GLU_NURBS_COLOR FunPtr NURBSVertexCallback
callbackPtr
      IO a
action

--------------------------------------------------------------------------------
-- chapter 7.2: Callbacks (end)

type NURBSEndCallback = IO ()

withNURBSEndCallback :: NURBSObj -> NURBSEndCallback -> IO a -> IO a
withNURBSEndCallback :: forall a. Ptr GLUnurbs -> IO () -> IO a -> IO a
withNURBSEndCallback Ptr GLUnurbs
nurbsObj IO ()
endCallback IO a
action =
   IO (FunPtr (IO ()))
-> (FunPtr (IO ()) -> IO ()) -> (FunPtr (IO ()) -> IO a) -> IO a
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (IO () -> IO (FunPtr (IO ()))
makeNURBSEndCallback IO ()
endCallback)
           FunPtr (IO ()) -> IO ()
forall a. FunPtr a -> IO ()
freeHaskellFunPtr ((FunPtr (IO ()) -> IO a) -> IO a)
-> (FunPtr (IO ()) -> IO a) -> IO a
forall a b. (a -> b) -> a -> b
$ \FunPtr (IO ())
callbackPtr -> do
      Ptr GLUnurbs -> GLenum -> FunPtr (IO ()) -> IO ()
forall (m :: * -> *) a.
MonadIO m =>
Ptr GLUnurbs -> GLenum -> FunPtr a -> m ()
gluNurbsCallback Ptr GLUnurbs
nurbsObj GLenum
GLU_NURBS_END FunPtr (IO ())
callbackPtr
      IO a
action

--------------------------------------------------------------------------------
-- chapter 7.2: Callbacks (error)

type ErrorCallback = GLenum -> IO ()

withErrorCallback :: NURBSObj -> ErrorCallback -> IO a -> IO a
withErrorCallback :: forall a. Ptr GLUnurbs -> NURBSBeginCallback -> IO a -> IO a
withErrorCallback Ptr GLUnurbs
nurbsObj NURBSBeginCallback
errorCallback IO a
action =
   IO (FunPtr NURBSBeginCallback)
-> (FunPtr NURBSBeginCallback -> IO ())
-> (FunPtr NURBSBeginCallback -> IO a)
-> IO a
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (NURBSBeginCallback -> IO (FunPtr NURBSBeginCallback)
makeNURBSErrorCallback NURBSBeginCallback
errorCallback)
           FunPtr NURBSBeginCallback -> IO ()
forall a. FunPtr a -> IO ()
freeHaskellFunPtr ((FunPtr NURBSBeginCallback -> IO a) -> IO a)
-> (FunPtr NURBSBeginCallback -> IO a) -> IO a
forall a b. (a -> b) -> a -> b
$ \FunPtr NURBSBeginCallback
callbackPtr -> do
      Ptr GLUnurbs -> GLenum -> FunPtr NURBSBeginCallback -> IO ()
forall (m :: * -> *) a.
MonadIO m =>
Ptr GLUnurbs -> GLenum -> FunPtr a -> m ()
gluNurbsCallback Ptr GLUnurbs
nurbsObj GLenum
GLU_NURBS_ERROR FunPtr NURBSBeginCallback
callbackPtr
      IO a
action

checkForNURBSError :: NURBSObj -> IO a -> IO a
checkForNURBSError :: forall a. Ptr GLUnurbs -> IO a -> IO a
checkForNURBSError Ptr GLUnurbs
nurbsObj = Ptr GLUnurbs -> NURBSBeginCallback -> IO a -> IO a
forall a. Ptr GLUnurbs -> NURBSBeginCallback -> IO a -> IO a
withErrorCallback Ptr GLUnurbs
nurbsObj NURBSBeginCallback
recordErrorCode

--------------------------------------------------------------------------------
-- chapter 7.3: NURBS Curves

nurbsBeginEndCurve :: NURBSObj -> IO a -> IO a
nurbsBeginEndCurve :: forall a. Ptr GLUnurbs -> IO a -> IO a
nurbsBeginEndCurve Ptr GLUnurbs
nurbsObj =
   IO () -> IO () -> IO a -> IO a
forall a b c. IO a -> IO b -> IO c -> IO c
bracket_ (Ptr GLUnurbs -> IO ()
forall (m :: * -> *). MonadIO m => Ptr GLUnurbs -> m ()
gluBeginCurve Ptr GLUnurbs
nurbsObj) (Ptr GLUnurbs -> IO ()
forall (m :: * -> *). MonadIO m => Ptr GLUnurbs -> m ()
gluEndCurve Ptr GLUnurbs
nurbsObj)


nurbsCurve :: ControlPoint c => NURBSObj -> GLint -> Ptr GLfloat -> GLint -> Ptr (c GLfloat) -> GLint -> IO ()
nurbsCurve :: forall (c :: * -> *).
ControlPoint c =>
Ptr GLUnurbs
-> GLint
-> Ptr GLfloat
-> GLint
-> Ptr (c GLfloat)
-> GLint
-> IO ()
nurbsCurve Ptr GLUnurbs
nurbsObj GLint
knotCount Ptr GLfloat
knots GLint
stride Ptr (c GLfloat)
control GLint
order =
   Ptr GLUnurbs
-> GLint
-> Ptr GLfloat
-> GLint
-> Ptr GLfloat
-> GLint
-> NURBSBeginCallback
forall (m :: * -> *).
MonadIO m =>
Ptr GLUnurbs
-> GLint
-> Ptr GLfloat
-> GLint
-> Ptr GLfloat
-> GLint
-> GLenum
-> m ()
gluNurbsCurve Ptr GLUnurbs
nurbsObj GLint
knotCount Ptr GLfloat
knots GLint
stride (Ptr (c GLfloat) -> Ptr GLfloat
forall a b. Ptr a -> Ptr b
castPtr Ptr (c GLfloat)
control) GLint
order (c GLfloat -> GLenum
forall (c :: * -> *) d. (ControlPoint c, Domain d) => c d -> GLenum
map1Target (Ptr (c GLfloat) -> c GLfloat
forall (c :: * -> *). Ptr (c GLfloat) -> c GLfloat
pseudoPeek Ptr (c GLfloat)
control))

pseudoPeek :: Ptr (c GLfloat) -> c GLfloat
pseudoPeek :: forall (c :: * -> *). Ptr (c GLfloat) -> c GLfloat
pseudoPeek Ptr (c GLfloat)
_ = c GLfloat
forall a. HasCallStack => a
undefined

--------------------------------------------------------------------------------
-- chapter 7.4: NURBS Surfaces

nurbsBeginEndSurface :: NURBSObj -> IO a -> IO a
nurbsBeginEndSurface :: forall a. Ptr GLUnurbs -> IO a -> IO a
nurbsBeginEndSurface Ptr GLUnurbs
nurbsObj =
   IO () -> IO () -> IO a -> IO a
forall a b c. IO a -> IO b -> IO c -> IO c
bracket_ (Ptr GLUnurbs -> IO ()
forall (m :: * -> *). MonadIO m => Ptr GLUnurbs -> m ()
gluBeginSurface Ptr GLUnurbs
nurbsObj) (Ptr GLUnurbs -> IO ()
forall (m :: * -> *). MonadIO m => Ptr GLUnurbs -> m ()
gluEndSurface Ptr GLUnurbs
nurbsObj)


nurbsSurface :: ControlPoint c => NURBSObj -> GLint -> Ptr GLfloat -> GLint -> Ptr GLfloat -> GLint -> GLint -> Ptr (c GLfloat) -> GLint -> GLint -> IO ()
nurbsSurface :: forall (c :: * -> *).
ControlPoint c =>
Ptr GLUnurbs
-> GLint
-> Ptr GLfloat
-> GLint
-> Ptr GLfloat
-> GLint
-> GLint
-> Ptr (c GLfloat)
-> GLint
-> GLint
-> IO ()
nurbsSurface Ptr GLUnurbs
nurbsObj GLint
sKnotCount Ptr GLfloat
sKnots GLint
tKnotCount Ptr GLfloat
tKnots GLint
sStride GLint
tStride Ptr (c GLfloat)
control GLint
sOrder GLint
tOrder =
   Ptr GLUnurbs
-> GLint
-> Ptr GLfloat
-> GLint
-> Ptr GLfloat
-> GLint
-> GLint
-> Ptr GLfloat
-> GLint
-> GLint
-> NURBSBeginCallback
forall (m :: * -> *).
MonadIO m =>
Ptr GLUnurbs
-> GLint
-> Ptr GLfloat
-> GLint
-> Ptr GLfloat
-> GLint
-> GLint
-> Ptr GLfloat
-> GLint
-> GLint
-> GLenum
-> m ()
gluNurbsSurface Ptr GLUnurbs
nurbsObj GLint
sKnotCount Ptr GLfloat
sKnots GLint
tKnotCount Ptr GLfloat
tKnots GLint
sStride GLint
tStride (Ptr (c GLfloat) -> Ptr GLfloat
forall a b. Ptr a -> Ptr b
castPtr Ptr (c GLfloat)
control) GLint
sOrder GLint
tOrder (c GLfloat -> GLenum
forall (c :: * -> *) d. (ControlPoint c, Domain d) => c d -> GLenum
map2Target (Ptr (c GLfloat) -> c GLfloat
forall (c :: * -> *). Ptr (c GLfloat) -> c GLfloat
pseudoPeek Ptr (c GLfloat)
control))

--------------------------------------------------------------------------------
-- chapter 7.5: Trimming

class TrimmingPoint p where
   trimmingTarget :: p GLfloat -> GLenum

instance TrimmingPoint Vertex2 where
   trimmingTarget :: Vertex2 GLfloat -> GLenum
trimmingTarget = GLenum -> Vertex2 GLfloat -> GLenum
forall a b. a -> b -> a
const GLenum
GLU_MAP1_TRIM_2

instance TrimmingPoint Vertex3 where
   trimmingTarget :: Vertex3 GLfloat -> GLenum
trimmingTarget = GLenum -> Vertex3 GLfloat -> GLenum
forall a b. a -> b -> a
const GLenum
GLU_MAP1_TRIM_3

nurbsBeginEndTrim :: NURBSObj -> IO a -> IO a
nurbsBeginEndTrim :: forall a. Ptr GLUnurbs -> IO a -> IO a
nurbsBeginEndTrim Ptr GLUnurbs
nurbsObj =
   IO () -> IO () -> IO a -> IO a
forall a b c. IO a -> IO b -> IO c -> IO c
bracket_ (Ptr GLUnurbs -> IO ()
forall (m :: * -> *). MonadIO m => Ptr GLUnurbs -> m ()
gluBeginTrim Ptr GLUnurbs
nurbsObj) (Ptr GLUnurbs -> IO ()
forall (m :: * -> *). MonadIO m => Ptr GLUnurbs -> m ()
gluEndTrim Ptr GLUnurbs
nurbsObj)

pwlCurve :: TrimmingPoint p => NURBSObj -> GLint -> Ptr (p GLfloat) -> GLint -> IO ()
pwlCurve :: forall (p :: * -> *).
TrimmingPoint p =>
Ptr GLUnurbs -> GLint -> Ptr (p GLfloat) -> GLint -> IO ()
pwlCurve Ptr GLUnurbs
nurbsObj GLint
count Ptr (p GLfloat)
points GLint
stride =
   Ptr GLUnurbs -> GLint -> Ptr GLfloat -> GLint -> NURBSBeginCallback
forall (m :: * -> *).
MonadIO m =>
Ptr GLUnurbs -> GLint -> Ptr GLfloat -> GLint -> GLenum -> m ()
gluPwlCurve Ptr GLUnurbs
nurbsObj GLint
count (Ptr (p GLfloat) -> Ptr GLfloat
forall a b. Ptr a -> Ptr b
castPtr Ptr (p GLfloat)
points) GLint
stride (p GLfloat -> GLenum
forall (p :: * -> *). TrimmingPoint p => p GLfloat -> GLenum
trimmingTarget (Ptr (p GLfloat) -> p GLfloat
forall (c :: * -> *). Ptr (c GLfloat) -> c GLfloat
pseudoPeek Ptr (p GLfloat)
points))

trimmingCurve :: TrimmingPoint c => NURBSObj -> GLint -> Ptr GLfloat -> GLint -> Ptr (c GLfloat) -> GLint -> IO ()
trimmingCurve :: forall (c :: * -> *).
TrimmingPoint c =>
Ptr GLUnurbs
-> GLint
-> Ptr GLfloat
-> GLint
-> Ptr (c GLfloat)
-> GLint
-> IO ()
trimmingCurve Ptr GLUnurbs
nurbsObj GLint
knotCount Ptr GLfloat
knots GLint
stride Ptr (c GLfloat)
control GLint
order =
   Ptr GLUnurbs
-> GLint
-> Ptr GLfloat
-> GLint
-> Ptr GLfloat
-> GLint
-> NURBSBeginCallback
forall (m :: * -> *).
MonadIO m =>
Ptr GLUnurbs
-> GLint
-> Ptr GLfloat
-> GLint
-> Ptr GLfloat
-> GLint
-> GLenum
-> m ()
gluNurbsCurve Ptr GLUnurbs
nurbsObj GLint
knotCount Ptr GLfloat
knots GLint
stride (Ptr (c GLfloat) -> Ptr GLfloat
forall a b. Ptr a -> Ptr b
castPtr Ptr (c GLfloat)
control) GLint
order (c GLfloat -> GLenum
forall (p :: * -> *). TrimmingPoint p => p GLfloat -> GLenum
trimmingTarget (Ptr (c GLfloat) -> c GLfloat
forall (c :: * -> *). Ptr (c GLfloat) -> c GLfloat
pseudoPeek Ptr (c GLfloat)
control))

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

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

marshalNURBSMode :: NURBSMode -> GLfloat
marshalNURBSMode :: NURBSMode -> GLfloat
marshalNURBSMode NURBSMode
x = GLenum -> GLfloat
forall a b. (Integral a, Num b) => a -> b
fromIntegral (GLenum -> GLfloat) -> GLenum -> GLfloat
forall a b. (a -> b) -> a -> b
$ case NURBSMode
x of
   NURBSMode
NURBSTessellator -> GLenum
GLU_NURBS_TESSELLATOR
   NURBSMode
NURBSRenderer -> GLenum
GLU_NURBS_RENDERER

setNURBSMode :: NURBSObj -> NURBSMode -> IO ()
setNURBSMode :: Ptr GLUnurbs -> NURBSMode -> IO ()
setNURBSMode Ptr GLUnurbs
nurbsObj = Ptr GLUnurbs -> GLenum -> GLfloat -> IO ()
forall (m :: * -> *).
MonadIO m =>
Ptr GLUnurbs -> GLenum -> GLfloat -> m ()
gluNurbsProperty Ptr GLUnurbs
nurbsObj GLenum
GLU_NURBS_MODE (GLfloat -> IO ()) -> (NURBSMode -> GLfloat) -> NURBSMode -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NURBSMode -> GLfloat
marshalNURBSMode

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

setNURBSCulling :: NURBSObj -> Capability -> IO ()
setNURBSCulling :: Ptr GLUnurbs -> Capability -> IO ()
setNURBSCulling Ptr GLUnurbs
nurbsObj = Ptr GLUnurbs -> GLenum -> GLfloat -> IO ()
forall (m :: * -> *).
MonadIO m =>
Ptr GLUnurbs -> GLenum -> GLfloat -> m ()
gluNurbsProperty Ptr GLUnurbs
nurbsObj GLenum
GLU_CULLING (GLfloat -> IO ())
-> (Capability -> GLfloat) -> Capability -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GLboolean -> GLfloat
forall a b. (Integral a, Num b) => a -> b
fromIntegral (GLboolean -> GLfloat)
-> (Capability -> GLboolean) -> Capability -> GLfloat
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Capability -> GLboolean
marshalCapability

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

data SamplingMethod' =
     PathLength'
   | ParametricError'
   | DomainDistance'
   | ObjectPathLength'
   | ObjectParametricError'

marshalSamplingMethod' :: SamplingMethod' -> GLfloat
marshalSamplingMethod' :: SamplingMethod' -> GLfloat
marshalSamplingMethod' SamplingMethod'
x = GLenum -> GLfloat
forall a b. (Integral a, Num b) => a -> b
fromIntegral (GLenum -> GLfloat) -> GLenum -> GLfloat
forall a b. (a -> b) -> a -> b
$ case SamplingMethod'
x of
   SamplingMethod'
PathLength' -> GLenum
GLU_PATH_LENGTH
   SamplingMethod'
ParametricError' -> GLenum
GLU_PARAMETRIC_TOLERANCE
   SamplingMethod'
DomainDistance' -> GLenum
GLU_DOMAIN_DISTANCE
   SamplingMethod'
ObjectPathLength' -> GLenum
GLU_OBJECT_PATH_LENGTH
   SamplingMethod'
ObjectParametricError' -> GLenum
GLU_OBJECT_PARAMETRIC_ERROR

setSamplingMethod' :: NURBSObj -> SamplingMethod' -> IO ()
setSamplingMethod' :: Ptr GLUnurbs -> SamplingMethod' -> IO ()
setSamplingMethod' Ptr GLUnurbs
nurbsObj = Ptr GLUnurbs -> GLenum -> GLfloat -> IO ()
forall (m :: * -> *).
MonadIO m =>
Ptr GLUnurbs -> GLenum -> GLfloat -> m ()
gluNurbsProperty Ptr GLUnurbs
nurbsObj GLenum
GLU_SAMPLING_METHOD (GLfloat -> IO ())
-> (SamplingMethod' -> GLfloat) -> SamplingMethod' -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SamplingMethod' -> GLfloat
marshalSamplingMethod'

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

data SamplingMethod =
     PathLength GLfloat
   | ParametricError GLfloat
   | DomainDistance GLfloat GLfloat
   | ObjectPathLength GLfloat
   | ObjectParametricError GLfloat
   deriving ( SamplingMethod -> SamplingMethod -> Bool
(SamplingMethod -> SamplingMethod -> Bool)
-> (SamplingMethod -> SamplingMethod -> Bool) -> Eq SamplingMethod
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SamplingMethod -> SamplingMethod -> Bool
$c/= :: SamplingMethod -> SamplingMethod -> Bool
== :: SamplingMethod -> SamplingMethod -> Bool
$c== :: SamplingMethod -> SamplingMethod -> Bool
Eq, Eq SamplingMethod
Eq SamplingMethod
-> (SamplingMethod -> SamplingMethod -> Ordering)
-> (SamplingMethod -> SamplingMethod -> Bool)
-> (SamplingMethod -> SamplingMethod -> Bool)
-> (SamplingMethod -> SamplingMethod -> Bool)
-> (SamplingMethod -> SamplingMethod -> Bool)
-> (SamplingMethod -> SamplingMethod -> SamplingMethod)
-> (SamplingMethod -> SamplingMethod -> SamplingMethod)
-> Ord SamplingMethod
SamplingMethod -> SamplingMethod -> Bool
SamplingMethod -> SamplingMethod -> Ordering
SamplingMethod -> SamplingMethod -> SamplingMethod
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 :: SamplingMethod -> SamplingMethod -> SamplingMethod
$cmin :: SamplingMethod -> SamplingMethod -> SamplingMethod
max :: SamplingMethod -> SamplingMethod -> SamplingMethod
$cmax :: SamplingMethod -> SamplingMethod -> SamplingMethod
>= :: SamplingMethod -> SamplingMethod -> Bool
$c>= :: SamplingMethod -> SamplingMethod -> Bool
> :: SamplingMethod -> SamplingMethod -> Bool
$c> :: SamplingMethod -> SamplingMethod -> Bool
<= :: SamplingMethod -> SamplingMethod -> Bool
$c<= :: SamplingMethod -> SamplingMethod -> Bool
< :: SamplingMethod -> SamplingMethod -> Bool
$c< :: SamplingMethod -> SamplingMethod -> Bool
compare :: SamplingMethod -> SamplingMethod -> Ordering
$ccompare :: SamplingMethod -> SamplingMethod -> Ordering
Ord, Int -> SamplingMethod -> ShowS
[SamplingMethod] -> ShowS
SamplingMethod -> String
(Int -> SamplingMethod -> ShowS)
-> (SamplingMethod -> String)
-> ([SamplingMethod] -> ShowS)
-> Show SamplingMethod
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SamplingMethod] -> ShowS
$cshowList :: [SamplingMethod] -> ShowS
show :: SamplingMethod -> String
$cshow :: SamplingMethod -> String
showsPrec :: Int -> SamplingMethod -> ShowS
$cshowsPrec :: Int -> SamplingMethod -> ShowS
Show )

setSamplingMethod :: NURBSObj -> SamplingMethod -> IO ()
setSamplingMethod :: Ptr GLUnurbs -> SamplingMethod -> IO ()
setSamplingMethod Ptr GLUnurbs
nurbsObj SamplingMethod
x = case SamplingMethod
x of
   PathLength GLfloat
s -> do
      Ptr GLUnurbs -> GLenum -> GLfloat -> IO ()
forall (m :: * -> *).
MonadIO m =>
Ptr GLUnurbs -> GLenum -> GLfloat -> m ()
gluNurbsProperty Ptr GLUnurbs
nurbsObj GLenum
GLU_SAMPLING_TOLERANCE GLfloat
s
      Ptr GLUnurbs -> SamplingMethod' -> IO ()
setSamplingMethod' Ptr GLUnurbs
nurbsObj SamplingMethod'
PathLength'
   ParametricError GLfloat
p -> do
      Ptr GLUnurbs -> GLenum -> GLfloat -> IO ()
forall (m :: * -> *).
MonadIO m =>
Ptr GLUnurbs -> GLenum -> GLfloat -> m ()
gluNurbsProperty Ptr GLUnurbs
nurbsObj GLenum
GLU_PARAMETRIC_TOLERANCE GLfloat
p
      Ptr GLUnurbs -> SamplingMethod' -> IO ()
setSamplingMethod' Ptr GLUnurbs
nurbsObj SamplingMethod'
ParametricError'
   DomainDistance GLfloat
u GLfloat
v -> do
      Ptr GLUnurbs -> GLenum -> GLfloat -> IO ()
forall (m :: * -> *).
MonadIO m =>
Ptr GLUnurbs -> GLenum -> GLfloat -> m ()
gluNurbsProperty Ptr GLUnurbs
nurbsObj GLenum
GLU_U_STEP GLfloat
u
      Ptr GLUnurbs -> GLenum -> GLfloat -> IO ()
forall (m :: * -> *).
MonadIO m =>
Ptr GLUnurbs -> GLenum -> GLfloat -> m ()
gluNurbsProperty Ptr GLUnurbs
nurbsObj GLenum
GLU_V_STEP GLfloat
v
      Ptr GLUnurbs -> SamplingMethod' -> IO ()
setSamplingMethod' Ptr GLUnurbs
nurbsObj SamplingMethod'
DomainDistance'
   ObjectPathLength GLfloat
s -> do
      Ptr GLUnurbs -> GLenum -> GLfloat -> IO ()
forall (m :: * -> *).
MonadIO m =>
Ptr GLUnurbs -> GLenum -> GLfloat -> m ()
gluNurbsProperty Ptr GLUnurbs
nurbsObj GLenum
GLU_SAMPLING_TOLERANCE GLfloat
s
      Ptr GLUnurbs -> SamplingMethod' -> IO ()
setSamplingMethod' Ptr GLUnurbs
nurbsObj SamplingMethod'
ObjectPathLength'
   ObjectParametricError GLfloat
p -> do
      Ptr GLUnurbs -> GLenum -> GLfloat -> IO ()
forall (m :: * -> *).
MonadIO m =>
Ptr GLUnurbs -> GLenum -> GLfloat -> m ()
gluNurbsProperty Ptr GLUnurbs
nurbsObj GLenum
GLU_PARAMETRIC_TOLERANCE GLfloat
p
      Ptr GLUnurbs -> SamplingMethod' -> IO ()
setSamplingMethod' Ptr GLUnurbs
nurbsObj SamplingMethod'
ObjectParametricError'

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

setAutoLoadMatrix :: NURBSObj -> Bool -> IO ()
setAutoLoadMatrix :: Ptr GLUnurbs -> Bool -> IO ()
setAutoLoadMatrix Ptr GLUnurbs
nurbsObj = Ptr GLUnurbs -> GLenum -> GLfloat -> IO ()
forall (m :: * -> *).
MonadIO m =>
Ptr GLUnurbs -> GLenum -> GLfloat -> m ()
gluNurbsProperty Ptr GLUnurbs
nurbsObj GLenum
GLU_AUTO_LOAD_MATRIX (GLfloat -> IO ()) -> (Bool -> GLfloat) -> Bool -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> GLfloat
forall a. Num a => Bool -> a
marshalGLboolean

loadSamplingMatrices :: (Matrix m1, Matrix m2) => NURBSObj -> Maybe (m1 GLfloat, m2 GLfloat, (Position, Size)) -> IO ()
loadSamplingMatrices :: forall (m1 :: * -> *) (m2 :: * -> *).
(Matrix m1, Matrix m2) =>
Ptr GLUnurbs
-> Maybe (m1 GLfloat, m2 GLfloat, (Position, Size)) -> IO ()
loadSamplingMatrices Ptr GLUnurbs
nurbsObj =
   IO ()
-> ((m1 GLfloat, m2 GLfloat, (Position, Size)) -> IO ())
-> Maybe (m1 GLfloat, m2 GLfloat, (Position, Size))
-> IO ()
forall b a. b -> (a -> b) -> Maybe a -> b
maybe
      (Ptr GLUnurbs -> Bool -> IO ()
setAutoLoadMatrix Ptr GLUnurbs
nurbsObj Bool
True)
      (\(m1 GLfloat
mv, m2 GLfloat
proj, (Position GLint
x GLint
y, Size GLint
w GLint
h)) -> do
          m1 GLfloat -> NURBSVertexCallback -> IO ()
forall (m :: * -> *) c a.
(Matrix m, MatrixComponent c) =>
m c -> (Ptr c -> IO a) -> IO a
withMatrixColumnMajor m1 GLfloat
mv (NURBSVertexCallback -> IO ()) -> NURBSVertexCallback -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr GLfloat
mvBuf ->
             m2 GLfloat -> NURBSVertexCallback -> IO ()
forall (m :: * -> *) c a.
(Matrix m, MatrixComponent c) =>
m c -> (Ptr c -> IO a) -> IO a
withMatrixColumnMajor m2 GLfloat
proj (NURBSVertexCallback -> IO ()) -> NURBSVertexCallback -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr GLfloat
projBuf ->
                [GLint] -> (Ptr GLint -> IO ()) -> IO ()
forall a b. Storable a => [a] -> (Ptr a -> IO b) -> IO b
withArray [GLint
x, GLint
y, GLint -> GLint
forall a b. (Integral a, Num b) => a -> b
fromIntegral GLint
w, GLint -> GLint
forall a b. (Integral a, Num b) => a -> b
fromIntegral GLint
h] ((Ptr GLint -> IO ()) -> IO ()) -> (Ptr GLint -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr GLint
viewportBuf ->
                  Ptr GLUnurbs -> Ptr GLfloat -> Ptr GLfloat -> Ptr GLint -> IO ()
forall (m :: * -> *).
MonadIO m =>
Ptr GLUnurbs -> Ptr GLfloat -> Ptr GLfloat -> Ptr GLint -> m ()
gluLoadSamplingMatrices Ptr GLUnurbs
nurbsObj Ptr GLfloat
mvBuf Ptr GLfloat
projBuf Ptr GLint
viewportBuf
          Ptr GLUnurbs -> Bool -> IO ()
setAutoLoadMatrix Ptr GLUnurbs
nurbsObj Bool
False)

withMatrixColumnMajor :: (Matrix m, MatrixComponent c) => m c -> (Ptr c -> IO a) -> IO a
withMatrixColumnMajor :: forall (m :: * -> *) c a.
(Matrix m, MatrixComponent c) =>
m c -> (Ptr c -> IO a) -> IO a
withMatrixColumnMajor m c
mat Ptr c -> IO a
act =
   m c -> (MatrixOrder -> Ptr c -> IO a) -> IO a
forall (m :: * -> *) c a.
(Matrix m, MatrixComponent c) =>
m c -> (MatrixOrder -> Ptr c -> IO a) -> IO a
withMatrix m c
mat ((MatrixOrder -> Ptr c -> IO a) -> IO a)
-> (MatrixOrder -> Ptr c -> IO a) -> IO a
forall a b. (a -> b) -> a -> b
$ \MatrixOrder
order Ptr c
p ->
      if MatrixOrder
order MatrixOrder -> MatrixOrder -> Bool
forall a. Eq a => a -> a -> Bool
== MatrixOrder
ColumnMajor
         then Ptr c -> IO a
act Ptr c
p
         else do
            [c]
elems <- (Int -> IO c) -> [Int] -> IO [c]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (Ptr c -> Int -> IO c
forall a. Storable a => Ptr a -> Int -> IO a
peekElemOff Ptr c
p) [ Int
0, Int
4,  Int
8, Int
12,
                                            Int
1, Int
5,  Int
9, Int
13,
                                            Int
2, Int
6, Int
10, Int
14,
                                            Int
3, Int
7, Int
11, Int
15 ]
            [c] -> (Ptr c -> IO a) -> IO a
forall a b. Storable a => [a] -> (Ptr a -> IO b) -> IO b
withArray [c]
elems Ptr c -> IO a
act

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

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

marshalDisplayMode' :: DisplayMode' -> GLfloat
marshalDisplayMode' :: DisplayMode' -> GLfloat
marshalDisplayMode' DisplayMode'
x = GLenum -> GLfloat
forall a b. (Integral a, Num b) => a -> b
fromIntegral (GLenum -> GLfloat) -> GLenum -> GLfloat
forall a b. (a -> b) -> a -> b
$ case DisplayMode'
x of
   DisplayMode'
Fill' -> GLenum
GLU_FILL
   DisplayMode'
OutlinePolygon -> GLenum
GLU_OUTLINE_POLYGON
   DisplayMode'
OutlinePatch -> GLenum
GLU_OUTLINE_PATCH

setDisplayMode' :: NURBSObj -> DisplayMode' -> IO ()
setDisplayMode' :: Ptr GLUnurbs -> DisplayMode' -> IO ()
setDisplayMode' Ptr GLUnurbs
nurbsObj = Ptr GLUnurbs -> GLenum -> GLfloat -> IO ()
forall (m :: * -> *).
MonadIO m =>
Ptr GLUnurbs -> GLenum -> GLfloat -> m ()
gluNurbsProperty Ptr GLUnurbs
nurbsObj GLenum
GLU_DISPLAY_MODE (GLfloat -> IO ())
-> (DisplayMode' -> GLfloat) -> DisplayMode' -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DisplayMode' -> GLfloat
marshalDisplayMode'