{-# LANGUAGE KindSignatures #-}
module Graphics.Rendering.OpenGL.GL.Evaluators (
Order, maxOrder, Domain, MapDescriptor(..), ControlPoint,
Map1(..), GLmap1, map1,
Map2(..), GLmap2, map2,
evalCoord1, evalCoord1v, evalCoord2, evalCoord2v,
mapGrid1, mapGrid2,
evalMesh1, evalMesh2,
evalPoint1, evalPoint2,
autoNormal
) where
import Control.Monad
import Data.List
import Data.StateVar
import Foreign.ForeignPtr
import Foreign.Marshal.Array
import Foreign.Marshal.Utils
import Foreign.Ptr
import Foreign.Storable
import Graphics.Rendering.OpenGL.GL.Capability
import Graphics.Rendering.OpenGL.GL.ControlPoint
import Graphics.Rendering.OpenGL.GL.Domain
import Graphics.Rendering.OpenGL.GL.PeekPoke
import Graphics.Rendering.OpenGL.GL.PolygonMode
import Graphics.Rendering.OpenGL.GL.QueryUtils
import Graphics.Rendering.OpenGL.GL.VertexArrays
import Graphics.GL
type Order = GLint
maxOrder :: GettableStateVar Order
maxOrder :: GettableStateVar Order
maxOrder = GettableStateVar Order -> GettableStateVar Order
forall a. IO a -> IO a
makeGettableStateVar ((Order -> Order) -> PName1I -> GettableStateVar Order
forall p a. GetPName1I p => (Order -> a) -> p -> IO a
getInteger1 Order -> Order
forall a. a -> a
id PName1I
GetMaxEvalOrder)
data MapDescriptor d =
MapDescriptor (d, d) Stride Order NumComponents
deriving ( MapDescriptor d -> MapDescriptor d -> Bool
(MapDescriptor d -> MapDescriptor d -> Bool)
-> (MapDescriptor d -> MapDescriptor d -> Bool)
-> Eq (MapDescriptor d)
forall d. Eq d => MapDescriptor d -> MapDescriptor d -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MapDescriptor d -> MapDescriptor d -> Bool
$c/= :: forall d. Eq d => MapDescriptor d -> MapDescriptor d -> Bool
== :: MapDescriptor d -> MapDescriptor d -> Bool
$c== :: forall d. Eq d => MapDescriptor d -> MapDescriptor d -> Bool
Eq, Eq (MapDescriptor d)
Eq (MapDescriptor d)
-> (MapDescriptor d -> MapDescriptor d -> Ordering)
-> (MapDescriptor d -> MapDescriptor d -> Bool)
-> (MapDescriptor d -> MapDescriptor d -> Bool)
-> (MapDescriptor d -> MapDescriptor d -> Bool)
-> (MapDescriptor d -> MapDescriptor d -> Bool)
-> (MapDescriptor d -> MapDescriptor d -> MapDescriptor d)
-> (MapDescriptor d -> MapDescriptor d -> MapDescriptor d)
-> Ord (MapDescriptor d)
MapDescriptor d -> MapDescriptor d -> Bool
MapDescriptor d -> MapDescriptor d -> Ordering
MapDescriptor d -> MapDescriptor d -> MapDescriptor d
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
forall d. Ord d => Eq (MapDescriptor d)
forall d. Ord d => MapDescriptor d -> MapDescriptor d -> Bool
forall d. Ord d => MapDescriptor d -> MapDescriptor d -> Ordering
forall d.
Ord d =>
MapDescriptor d -> MapDescriptor d -> MapDescriptor d
min :: MapDescriptor d -> MapDescriptor d -> MapDescriptor d
$cmin :: forall d.
Ord d =>
MapDescriptor d -> MapDescriptor d -> MapDescriptor d
max :: MapDescriptor d -> MapDescriptor d -> MapDescriptor d
$cmax :: forall d.
Ord d =>
MapDescriptor d -> MapDescriptor d -> MapDescriptor d
>= :: MapDescriptor d -> MapDescriptor d -> Bool
$c>= :: forall d. Ord d => MapDescriptor d -> MapDescriptor d -> Bool
> :: MapDescriptor d -> MapDescriptor d -> Bool
$c> :: forall d. Ord d => MapDescriptor d -> MapDescriptor d -> Bool
<= :: MapDescriptor d -> MapDescriptor d -> Bool
$c<= :: forall d. Ord d => MapDescriptor d -> MapDescriptor d -> Bool
< :: MapDescriptor d -> MapDescriptor d -> Bool
$c< :: forall d. Ord d => MapDescriptor d -> MapDescriptor d -> Bool
compare :: MapDescriptor d -> MapDescriptor d -> Ordering
$ccompare :: forall d. Ord d => MapDescriptor d -> MapDescriptor d -> Ordering
$cp1Ord :: forall d. Ord d => Eq (MapDescriptor d)
Ord, Int -> MapDescriptor d -> ShowS
[MapDescriptor d] -> ShowS
MapDescriptor d -> String
(Int -> MapDescriptor d -> ShowS)
-> (MapDescriptor d -> String)
-> ([MapDescriptor d] -> ShowS)
-> Show (MapDescriptor d)
forall d. Show d => Int -> MapDescriptor d -> ShowS
forall d. Show d => [MapDescriptor d] -> ShowS
forall d. Show d => MapDescriptor d -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MapDescriptor d] -> ShowS
$cshowList :: forall d. Show d => [MapDescriptor d] -> ShowS
show :: MapDescriptor d -> String
$cshow :: forall d. Show d => MapDescriptor d -> String
showsPrec :: Int -> MapDescriptor d -> ShowS
$cshowsPrec :: forall d. Show d => Int -> MapDescriptor d -> ShowS
Show )
totalComponents1 :: MapDescriptor d -> Int
totalComponents1 :: MapDescriptor d -> Int
totalComponents1 (MapDescriptor (d, d)
_ Order
stride Order
order Order
numComp) =
Order -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Order
stride Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Order -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Order
order Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1) Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Order -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Order
numComp
totalComponents2 :: MapDescriptor d -> MapDescriptor d -> Int
totalComponents2 :: MapDescriptor d -> MapDescriptor d -> Int
totalComponents2 MapDescriptor d
uDescriptor vDescriptor :: MapDescriptor d
vDescriptor@(MapDescriptor (d, d)
_ Order
_ Order
_ Order
numComp) =
MapDescriptor d -> Int
forall d. MapDescriptor d -> Int
totalComponents1 MapDescriptor d
uDescriptor Int -> Int -> Int
forall a. Num a => a -> a -> a
+ MapDescriptor d -> Int
forall d. MapDescriptor d -> Int
totalComponents1 MapDescriptor d
vDescriptor Int -> Int -> Int
forall a. Num a => a -> a -> a
- Order -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Order
numComp
peekControlPoints1 ::
(ControlPoint c, Domain d) => MapDescriptor d -> Ptr d -> IO [c d]
peekControlPoints1 :: MapDescriptor d -> Ptr d -> IO [c d]
peekControlPoints1 MapDescriptor d
descriptor Ptr d
ptr =
(Ptr (c d) -> IO (c d)) -> [Ptr (c d)] -> IO [c d]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Ptr (c d) -> IO (c d)
forall (c :: * -> *) d.
(ControlPoint c, Domain d) =>
Ptr (c d) -> IO (c d)
peekControlPoint (MapDescriptor d -> Ptr d -> [Ptr (c d)]
forall d a. Domain d => MapDescriptor d -> Ptr d -> [Ptr a]
controlPointPtrs1 MapDescriptor d
descriptor Ptr d
ptr)
peekControlPoints2 ::
(ControlPoint c, Domain d)
=> MapDescriptor d -> MapDescriptor d -> Ptr d -> IO [[c d]]
peekControlPoints2 :: MapDescriptor d -> MapDescriptor d -> Ptr d -> IO [[c d]]
peekControlPoints2 MapDescriptor d
uDescriptor MapDescriptor d
vDescriptor Ptr d
ptr =
([Ptr (c d)] -> IO [c d]) -> [[Ptr (c d)]] -> IO [[c d]]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ((Ptr (c d) -> IO (c d)) -> [Ptr (c d)] -> IO [c d]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Ptr (c d) -> IO (c d)
forall (c :: * -> *) d.
(ControlPoint c, Domain d) =>
Ptr (c d) -> IO (c d)
peekControlPoint) (MapDescriptor d -> MapDescriptor d -> Ptr d -> [[Ptr (c d)]]
forall d a.
Domain d =>
MapDescriptor d -> MapDescriptor d -> Ptr d -> [[Ptr a]]
controlPointPtrs2 MapDescriptor d
uDescriptor MapDescriptor d
vDescriptor Ptr d
ptr)
pokeControlPoints1 ::
(ControlPoint c, Domain d) => MapDescriptor d -> Ptr d -> [c d] -> IO ()
pokeControlPoints1 :: MapDescriptor d -> Ptr d -> [c d] -> IO ()
pokeControlPoints1 MapDescriptor d
descriptor Ptr d
ptr =
(Ptr (c d) -> c d -> IO ()) -> [Ptr (c d)] -> [c d] -> IO ()
forall (m :: * -> *) a b c.
Applicative m =>
(a -> b -> m c) -> [a] -> [b] -> m ()
zipWithM_ Ptr (c d) -> c d -> IO ()
forall (c :: * -> *) d.
(ControlPoint c, Domain d) =>
Ptr (c d) -> c d -> IO ()
pokeControlPoint (MapDescriptor d -> Ptr d -> [Ptr (c d)]
forall d a. Domain d => MapDescriptor d -> Ptr d -> [Ptr a]
controlPointPtrs1 MapDescriptor d
descriptor Ptr d
ptr)
pokeControlPoints2 ::
(ControlPoint c, Domain d)
=> MapDescriptor d -> MapDescriptor d -> Ptr d -> [[c d]] -> IO ()
pokeControlPoints2 :: MapDescriptor d -> MapDescriptor d -> Ptr d -> [[c d]] -> IO ()
pokeControlPoints2 MapDescriptor d
uDescriptor MapDescriptor d
vDescriptor Ptr d
ptr =
([Ptr (c d)] -> [c d] -> IO ())
-> [[Ptr (c d)]] -> [[c d]] -> IO ()
forall (m :: * -> *) a b c.
Applicative m =>
(a -> b -> m c) -> [a] -> [b] -> m ()
zipWithM_ ((Ptr (c d) -> c d -> IO ()) -> [Ptr (c d)] -> [c d] -> IO ()
forall (m :: * -> *) a b c.
Applicative m =>
(a -> b -> m c) -> [a] -> [b] -> m ()
zipWithM_ Ptr (c d) -> c d -> IO ()
forall (c :: * -> *) d.
(ControlPoint c, Domain d) =>
Ptr (c d) -> c d -> IO ()
pokeControlPoint)
(MapDescriptor d -> MapDescriptor d -> Ptr d -> [[Ptr (c d)]]
forall d a.
Domain d =>
MapDescriptor d -> MapDescriptor d -> Ptr d -> [[Ptr a]]
controlPointPtrs2 MapDescriptor d
uDescriptor MapDescriptor d
vDescriptor Ptr d
ptr)
controlPointPtrs1 :: Domain d => MapDescriptor d -> Ptr d -> [Ptr a]
controlPointPtrs1 :: MapDescriptor d -> Ptr d -> [Ptr a]
controlPointPtrs1 (MapDescriptor (d, d)
_ Order
stride Order
order Order
_) Ptr d
ptr =
[ Ptr d
ptr Ptr d -> Int -> Ptr a
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
o Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
s) | Int
o <- [ Int
0 .. Order -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Order
order Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1 ] ]
where s :: Int
s = Ptr d -> Int
forall a. Storable a => Ptr a -> Int
sizeOfPtr Ptr d
ptr Int -> Int -> Int
forall a. Num a => a -> a -> a
* Order -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Order
stride
controlPointPtrs2 ::
Domain d => MapDescriptor d -> MapDescriptor d -> Ptr d -> [[Ptr a]]
controlPointPtrs2 :: MapDescriptor d -> MapDescriptor d -> Ptr d -> [[Ptr a]]
controlPointPtrs2 MapDescriptor d
uDescriptor MapDescriptor d
vDescriptor Ptr d
ptr =
[ MapDescriptor d -> Ptr d -> [Ptr a]
forall d a. Domain d => MapDescriptor d -> Ptr d -> [Ptr a]
controlPointPtrs1 MapDescriptor d
vDescriptor Ptr d
p | Ptr d
p <- MapDescriptor d -> Ptr d -> [Ptr d]
forall d a. Domain d => MapDescriptor d -> Ptr d -> [Ptr a]
controlPointPtrs1 MapDescriptor d
uDescriptor Ptr d
ptr ]
sizeOfPtr :: Storable a => Ptr a -> Int
sizeOfPtr :: Ptr a -> Int
sizeOfPtr = a -> Int
forall a. Storable a => a -> Int
sizeOf (a -> Int) -> (Ptr a -> a) -> Ptr a -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Ptr a -> a
forall a b. a -> b -> a
const a
forall a. HasCallStack => a
undefined :: Ptr a -> a)
class Map1 m where
withNewMap1 :: (ControlPoint c, Domain d)
=> MapDescriptor d -> (Ptr d -> IO ()) -> IO (m c d)
withMap1 :: (ControlPoint c, Domain d)
=> m c d -> (MapDescriptor d -> Ptr d -> IO a) -> IO a
newMap1 :: (ControlPoint c, Domain d)
=> (d, d) -> [c d] -> IO (m c d)
getMap1Components :: (ControlPoint c, Domain d)
=> m c d -> IO ((d, d), [c d])
withNewMap1 descriptor :: MapDescriptor d
descriptor@(MapDescriptor (d, d)
domain Order
_ Order
_ Order
_) Ptr d -> IO ()
act = do
Int -> (Ptr d -> IO (m c d)) -> IO (m c d)
forall a b. Storable a => Int -> (Ptr a -> IO b) -> IO b
allocaArray (MapDescriptor d -> Int
forall d. MapDescriptor d -> Int
totalComponents1 MapDescriptor d
descriptor) ((Ptr d -> IO (m c d)) -> IO (m c d))
-> (Ptr d -> IO (m c d)) -> IO (m c d)
forall a b. (a -> b) -> a -> b
$ \Ptr d
ptr -> do
Ptr d -> IO ()
act Ptr d
ptr
[c d]
controlPoints <- MapDescriptor d -> Ptr d -> IO [c d]
forall (c :: * -> *) d.
(ControlPoint c, Domain d) =>
MapDescriptor d -> Ptr d -> IO [c d]
peekControlPoints1 MapDescriptor d
descriptor Ptr d
ptr
(d, d) -> [c d] -> IO (m c d)
forall (m :: (* -> *) -> * -> *) (c :: * -> *) d.
(Map1 m, ControlPoint c, Domain d) =>
(d, d) -> [c d] -> IO (m c d)
newMap1 (d, d)
domain [c d]
controlPoints
withMap1 m c d
m MapDescriptor d -> Ptr d -> IO a
act = do
((d, d)
domain, [c d]
controlPoints) <- m c d -> IO ((d, d), [c d])
forall (m :: (* -> *) -> * -> *) (c :: * -> *) d.
(Map1 m, ControlPoint c, Domain d) =>
m c d -> IO ((d, d), [c d])
getMap1Components m c d
m
let stride :: Order
stride = c d -> Order
forall (c :: * -> *) d. (ControlPoint c, Domain d) => c d -> Order
numComponents ([c d] -> c d
forall a. [a] -> a
head [c d]
controlPoints)
order :: Order
order = [c d] -> Order
forall i a. Num i => [a] -> i
genericLength [c d]
controlPoints
descriptor :: MapDescriptor d
descriptor = (d, d) -> Order -> Order -> Order -> MapDescriptor d
forall d. (d, d) -> Order -> Order -> Order -> MapDescriptor d
MapDescriptor (d, d)
domain Order
stride Order
order (Order -> Order
forall a b. (Integral a, Num b) => a -> b
fromIntegral Order
stride)
Int -> (Ptr d -> IO a) -> IO a
forall a b. Storable a => Int -> (Ptr a -> IO b) -> IO b
allocaArray (MapDescriptor d -> Int
forall d. MapDescriptor d -> Int
totalComponents1 MapDescriptor d
descriptor) ((Ptr d -> IO a) -> IO a) -> (Ptr d -> IO a) -> IO a
forall a b. (a -> b) -> a -> b
$ \Ptr d
ptr -> do
MapDescriptor d -> Ptr d -> [c d] -> IO ()
forall (c :: * -> *) d.
(ControlPoint c, Domain d) =>
MapDescriptor d -> Ptr d -> [c d] -> IO ()
pokeControlPoints1 MapDescriptor d
descriptor Ptr d
ptr [c d]
controlPoints
MapDescriptor d -> Ptr d -> IO a
act MapDescriptor d
descriptor Ptr d
ptr
newMap1 (d, d)
domain [c d]
controlPoints = do
let stride :: Order
stride = c d -> Order
forall (c :: * -> *) d. (ControlPoint c, Domain d) => c d -> Order
numComponents ([c d] -> c d
forall a. [a] -> a
head [c d]
controlPoints)
order :: Order
order = [c d] -> Order
forall i a. Num i => [a] -> i
genericLength [c d]
controlPoints
descriptor :: MapDescriptor d
descriptor = (d, d) -> Order -> Order -> Order -> MapDescriptor d
forall d. (d, d) -> Order -> Order -> Order -> MapDescriptor d
MapDescriptor (d, d)
domain Order
stride Order
order (Order -> Order
forall a b. (Integral a, Num b) => a -> b
fromIntegral Order
stride)
MapDescriptor d -> (Ptr d -> IO ()) -> IO (m c d)
forall (m :: (* -> *) -> * -> *) (c :: * -> *) d.
(Map1 m, ControlPoint c, Domain d) =>
MapDescriptor d -> (Ptr d -> IO ()) -> IO (m c d)
withNewMap1 MapDescriptor d
descriptor ((Ptr d -> IO ()) -> IO (m c d)) -> (Ptr d -> IO ()) -> IO (m c d)
forall a b. (a -> b) -> a -> b
$ \Ptr d
ptr ->
MapDescriptor d -> Ptr d -> [c d] -> IO ()
forall (c :: * -> *) d.
(ControlPoint c, Domain d) =>
MapDescriptor d -> Ptr d -> [c d] -> IO ()
pokeControlPoints1 MapDescriptor d
descriptor Ptr d
ptr [c d]
controlPoints
getMap1Components m c d
m =
m c d
-> (MapDescriptor d -> Ptr d -> IO ((d, d), [c d]))
-> IO ((d, d), [c d])
forall (m :: (* -> *) -> * -> *) (c :: * -> *) d a.
(Map1 m, ControlPoint c, Domain d) =>
m c d -> (MapDescriptor d -> Ptr d -> IO a) -> IO a
withMap1 m c d
m ((MapDescriptor d -> Ptr d -> IO ((d, d), [c d]))
-> IO ((d, d), [c d]))
-> (MapDescriptor d -> Ptr d -> IO ((d, d), [c d]))
-> IO ((d, d), [c d])
forall a b. (a -> b) -> a -> b
$ \descriptor :: MapDescriptor d
descriptor@(MapDescriptor (d, d)
domain Order
_ Order
_ Order
_) Ptr d
ptr -> do
[c d]
controlPoints <- MapDescriptor d -> Ptr d -> IO [c d]
forall (c :: * -> *) d.
(ControlPoint c, Domain d) =>
MapDescriptor d -> Ptr d -> IO [c d]
peekControlPoints1 MapDescriptor d
descriptor Ptr d
ptr
((d, d), [c d]) -> IO ((d, d), [c d])
forall (m :: * -> *) a. Monad m => a -> m a
return ((d, d)
domain, [c d]
controlPoints)
data GLmap1 (c :: * -> *) d =
GLmap1 (MapDescriptor d) (ForeignPtr d)
deriving ( GLmap1 c d -> GLmap1 c d -> Bool
(GLmap1 c d -> GLmap1 c d -> Bool)
-> (GLmap1 c d -> GLmap1 c d -> Bool) -> Eq (GLmap1 c d)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall (c :: * -> *) d. Eq d => GLmap1 c d -> GLmap1 c d -> Bool
/= :: GLmap1 c d -> GLmap1 c d -> Bool
$c/= :: forall (c :: * -> *) d. Eq d => GLmap1 c d -> GLmap1 c d -> Bool
== :: GLmap1 c d -> GLmap1 c d -> Bool
$c== :: forall (c :: * -> *) d. Eq d => GLmap1 c d -> GLmap1 c d -> Bool
Eq, Eq (GLmap1 c d)
Eq (GLmap1 c d)
-> (GLmap1 c d -> GLmap1 c d -> Ordering)
-> (GLmap1 c d -> GLmap1 c d -> Bool)
-> (GLmap1 c d -> GLmap1 c d -> Bool)
-> (GLmap1 c d -> GLmap1 c d -> Bool)
-> (GLmap1 c d -> GLmap1 c d -> Bool)
-> (GLmap1 c d -> GLmap1 c d -> GLmap1 c d)
-> (GLmap1 c d -> GLmap1 c d -> GLmap1 c d)
-> Ord (GLmap1 c d)
GLmap1 c d -> GLmap1 c d -> Bool
GLmap1 c d -> GLmap1 c d -> Ordering
GLmap1 c d -> GLmap1 c d -> GLmap1 c d
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
forall (c :: * -> *) d. Ord d => Eq (GLmap1 c d)
forall (c :: * -> *) d. Ord d => GLmap1 c d -> GLmap1 c d -> Bool
forall (c :: * -> *) d.
Ord d =>
GLmap1 c d -> GLmap1 c d -> Ordering
forall (c :: * -> *) d.
Ord d =>
GLmap1 c d -> GLmap1 c d -> GLmap1 c d
min :: GLmap1 c d -> GLmap1 c d -> GLmap1 c d
$cmin :: forall (c :: * -> *) d.
Ord d =>
GLmap1 c d -> GLmap1 c d -> GLmap1 c d
max :: GLmap1 c d -> GLmap1 c d -> GLmap1 c d
$cmax :: forall (c :: * -> *) d.
Ord d =>
GLmap1 c d -> GLmap1 c d -> GLmap1 c d
>= :: GLmap1 c d -> GLmap1 c d -> Bool
$c>= :: forall (c :: * -> *) d. Ord d => GLmap1 c d -> GLmap1 c d -> Bool
> :: GLmap1 c d -> GLmap1 c d -> Bool
$c> :: forall (c :: * -> *) d. Ord d => GLmap1 c d -> GLmap1 c d -> Bool
<= :: GLmap1 c d -> GLmap1 c d -> Bool
$c<= :: forall (c :: * -> *) d. Ord d => GLmap1 c d -> GLmap1 c d -> Bool
< :: GLmap1 c d -> GLmap1 c d -> Bool
$c< :: forall (c :: * -> *) d. Ord d => GLmap1 c d -> GLmap1 c d -> Bool
compare :: GLmap1 c d -> GLmap1 c d -> Ordering
$ccompare :: forall (c :: * -> *) d.
Ord d =>
GLmap1 c d -> GLmap1 c d -> Ordering
$cp1Ord :: forall (c :: * -> *) d. Ord d => Eq (GLmap1 c d)
Ord, Int -> GLmap1 c d -> ShowS
[GLmap1 c d] -> ShowS
GLmap1 c d -> String
(Int -> GLmap1 c d -> ShowS)
-> (GLmap1 c d -> String)
-> ([GLmap1 c d] -> ShowS)
-> Show (GLmap1 c d)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall (c :: * -> *) d. Show d => Int -> GLmap1 c d -> ShowS
forall (c :: * -> *) d. Show d => [GLmap1 c d] -> ShowS
forall (c :: * -> *) d. Show d => GLmap1 c d -> String
showList :: [GLmap1 c d] -> ShowS
$cshowList :: forall (c :: * -> *) d. Show d => [GLmap1 c d] -> ShowS
show :: GLmap1 c d -> String
$cshow :: forall (c :: * -> *) d. Show d => GLmap1 c d -> String
showsPrec :: Int -> GLmap1 c d -> ShowS
$cshowsPrec :: forall (c :: * -> *) d. Show d => Int -> GLmap1 c d -> ShowS
Show )
instance Map1 GLmap1 where
withNewMap1 :: MapDescriptor d -> (Ptr d -> IO ()) -> IO (GLmap1 c d)
withNewMap1 MapDescriptor d
descriptor Ptr d -> IO ()
act = do
ForeignPtr d
fp <- Int -> IO (ForeignPtr d)
forall a. Storable a => Int -> IO (ForeignPtr a)
mallocForeignPtrArray (MapDescriptor d -> Int
forall d. MapDescriptor d -> Int
totalComponents1 MapDescriptor d
descriptor)
ForeignPtr d -> (Ptr d -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr d
fp Ptr d -> IO ()
act
GLmap1 c d -> IO (GLmap1 c d)
forall (m :: * -> *) a. Monad m => a -> m a
return (GLmap1 c d -> IO (GLmap1 c d)) -> GLmap1 c d -> IO (GLmap1 c d)
forall a b. (a -> b) -> a -> b
$ MapDescriptor d -> ForeignPtr d -> GLmap1 c d
forall (c :: * -> *) d.
MapDescriptor d -> ForeignPtr d -> GLmap1 c d
GLmap1 MapDescriptor d
descriptor ForeignPtr d
fp
withMap1 :: GLmap1 c d -> (MapDescriptor d -> Ptr d -> IO a) -> IO a
withMap1 (GLmap1 MapDescriptor d
descriptor ForeignPtr d
fp) MapDescriptor d -> Ptr d -> IO a
act =
ForeignPtr d -> (Ptr d -> IO a) -> IO a
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr d
fp ((Ptr d -> IO a) -> IO a) -> (Ptr d -> IO a) -> IO a
forall a b. (a -> b) -> a -> b
$ MapDescriptor d -> Ptr d -> IO a
act MapDescriptor d
descriptor
map1 :: (Map1 m, ControlPoint c, Domain d) => StateVar (Maybe (m c d))
map1 :: StateVar (Maybe (m c d))
map1 = (c d -> EnableCap)
-> (c d -> IO (m c d))
-> (c d -> m c d -> IO ())
-> StateVar (Maybe (m c d))
forall (c :: * -> *) d (m :: (* -> *) -> * -> *).
(c d -> EnableCap)
-> (c d -> IO (m c d))
-> (c d -> m c d -> IO ())
-> StateVar (Maybe (m c d))
makeMap1StateVar c d -> EnableCap
forall (c :: * -> *) d.
(ControlPoint c, Domain d) =>
c d -> EnableCap
enableCap1 c d -> IO (m c d)
forall (m :: (* -> *) -> * -> *) (c :: * -> *) d.
(Map1 m, ControlPoint c, Domain d) =>
c d -> IO (m c d)
getMap1 c d -> m c d -> IO ()
forall (m :: (* -> *) -> * -> *) (c :: * -> *) d.
(Map1 m, ControlPoint c, Domain d) =>
c d -> m c d -> IO ()
setMap1
makeMap1StateVar ::
(c d -> EnableCap) -> (c d -> IO (m c d)) -> (c d -> m c d -> IO ())
-> StateVar (Maybe (m c d))
makeMap1StateVar :: (c d -> EnableCap)
-> (c d -> IO (m c d))
-> (c d -> m c d -> IO ())
-> StateVar (Maybe (m c d))
makeMap1StateVar c d -> EnableCap
getCap c d -> IO (m c d)
getAct c d -> m c d -> IO ()
setAct =
IO EnableCap
-> IO (m c d) -> (m c d -> IO ()) -> StateVar (Maybe (m c d))
forall a.
IO EnableCap -> IO a -> (a -> IO ()) -> StateVar (Maybe a)
makeStateVarMaybe
(EnableCap -> IO EnableCap
forall (m :: * -> *) a. Monad m => a -> m a
return (c d -> EnableCap
getCap c d
forall a. HasCallStack => a
undefined))
(c d -> IO (m c d)
getAct c d
forall a. HasCallStack => a
undefined)
(c d -> m c d -> IO ()
setAct c d
forall a. HasCallStack => a
undefined)
getMap1 :: (Map1 m, ControlPoint c, Domain d) => c d -> IO (m c d)
getMap1 :: c d -> IO (m c d)
getMap1 c d
dummyControlPoint = do
let target :: GLenum
target = c d -> GLenum
forall (c :: * -> *) d. (ControlPoint c, Domain d) => c d -> GLenum
map1Target c d
dummyControlPoint
numComp :: Order
numComp = Order -> Order
forall a b. (Integral a, Num b) => a -> b
fromIntegral (c d -> Order
forall (c :: * -> *) d. (ControlPoint c, Domain d) => c d -> Order
numComponents c d
dummyControlPoint)
(d, d)
domain <- Int -> (Ptr d -> IO (d, d)) -> IO (d, d)
forall a b. Storable a => Int -> (Ptr a -> IO b) -> IO b
allocaArray Int
2 ((Ptr d -> IO (d, d)) -> IO (d, d))
-> (Ptr d -> IO (d, d)) -> IO (d, d)
forall a b. (a -> b) -> a -> b
$ \Ptr d
ptr -> do
GLenum -> GLenum -> Ptr d -> IO ()
forall d. Domain d => GLenum -> GLenum -> Ptr d -> IO ()
glGetMapv GLenum
target (GetMapQuery -> GLenum
marshalGetMapQuery GetMapQuery
Domain) Ptr d
ptr
(d -> d -> (d, d)) -> Ptr d -> IO (d, d)
forall a b. Storable a => (a -> a -> b) -> Ptr a -> IO b
peek2 (,) Ptr d
ptr
Order
order <- Order
-> (Ptr Order -> GettableStateVar Order) -> GettableStateVar Order
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Order
0 ((Ptr Order -> GettableStateVar Order) -> GettableStateVar Order)
-> (Ptr Order -> GettableStateVar Order) -> GettableStateVar Order
forall a b. (a -> b) -> a -> b
$ \Ptr Order
ptr -> do
GLenum -> GLenum -> Ptr Order -> IO ()
forall (m :: * -> *).
MonadIO m =>
GLenum -> GLenum -> Ptr Order -> m ()
glGetMapiv GLenum
target (GetMapQuery -> GLenum
marshalGetMapQuery GetMapQuery
Order) Ptr Order
ptr
(Order -> Order)
-> GettableStateVar Order -> GettableStateVar Order
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Order -> Order
forall a b. (Integral a, Num b) => a -> b
fromIntegral (GettableStateVar Order -> GettableStateVar Order)
-> GettableStateVar Order -> GettableStateVar Order
forall a b. (a -> b) -> a -> b
$ Ptr Order -> GettableStateVar Order
forall a. Storable a => Ptr a -> IO a
peek Ptr Order
ptr
MapDescriptor d -> (Ptr d -> IO ()) -> IO (m c d)
forall (m :: (* -> *) -> * -> *) (c :: * -> *) d.
(Map1 m, ControlPoint c, Domain d) =>
MapDescriptor d -> (Ptr d -> IO ()) -> IO (m c d)
withNewMap1 ((d, d) -> Order -> Order -> Order -> MapDescriptor d
forall d. (d, d) -> Order -> Order -> Order -> MapDescriptor d
MapDescriptor (d, d)
domain (c d -> Order
forall (c :: * -> *) d. (ControlPoint c, Domain d) => c d -> Order
numComponents c d
dummyControlPoint) Order
order Order
numComp) ((Ptr d -> IO ()) -> IO (m c d)) -> (Ptr d -> IO ()) -> IO (m c d)
forall a b. (a -> b) -> a -> b
$
GLenum -> GLenum -> Ptr d -> IO ()
forall d. Domain d => GLenum -> GLenum -> Ptr d -> IO ()
glGetMapv GLenum
target (GetMapQuery -> GLenum
marshalGetMapQuery GetMapQuery
Coeff)
setMap1 :: (Map1 m, ControlPoint c, Domain d) => c d -> m c d -> IO ()
setMap1 :: c d -> m c d -> IO ()
setMap1 c d
dummyControlPoint m c d
m =
m c d -> (MapDescriptor d -> Ptr d -> IO ()) -> IO ()
forall (m :: (* -> *) -> * -> *) (c :: * -> *) d a.
(Map1 m, ControlPoint c, Domain d) =>
m c d -> (MapDescriptor d -> Ptr d -> IO a) -> IO a
withMap1 m c d
m ((MapDescriptor d -> Ptr d -> IO ()) -> IO ())
-> (MapDescriptor d -> Ptr d -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \(MapDescriptor (d
u1, d
u2) Order
stride Order
order Order
_) ->
GLenum -> d -> d -> Order -> Order -> Ptr d -> IO ()
forall d.
Domain d =>
GLenum -> d -> d -> Order -> Order -> Ptr d -> IO ()
glMap1 (c d -> GLenum
forall (c :: * -> *) d. (ControlPoint c, Domain d) => c d -> GLenum
map1Target c d
dummyControlPoint) d
u1 d
u2
(Order -> Order
forall a b. (Integral a, Num b) => a -> b
fromIntegral Order
stride) (Order -> Order
forall a b. (Integral a, Num b) => a -> b
fromIntegral Order
order)
class Map2 m where
withNewMap2 :: (ControlPoint c, Domain d)
=> MapDescriptor d -> MapDescriptor d -> (Ptr d -> IO ()) -> IO (m c d)
withMap2 :: (ControlPoint c, Domain d)
=> m c d -> (MapDescriptor d -> MapDescriptor d -> Ptr d -> IO a) -> IO a
newMap2 :: (ControlPoint c, Domain d)
=> (d, d) -> (d, d) -> [[c d]] -> IO (m c d)
getMap2Components :: (ControlPoint c, Domain d)
=> m c d -> IO ((d, d), (d, d), [[c d]])
withNewMap2 uDescriptor :: MapDescriptor d
uDescriptor@(MapDescriptor (d, d)
uDomain Order
_ Order
_ Order
_)
vDescriptor :: MapDescriptor d
vDescriptor@(MapDescriptor (d, d)
vDomain Order
_ Order
_ Order
_) Ptr d -> IO ()
act =
Int -> (Ptr d -> IO (m c d)) -> IO (m c d)
forall a b. Storable a => Int -> (Ptr a -> IO b) -> IO b
allocaArray (MapDescriptor d -> MapDescriptor d -> Int
forall d. MapDescriptor d -> MapDescriptor d -> Int
totalComponents2 MapDescriptor d
uDescriptor MapDescriptor d
vDescriptor) ((Ptr d -> IO (m c d)) -> IO (m c d))
-> (Ptr d -> IO (m c d)) -> IO (m c d)
forall a b. (a -> b) -> a -> b
$ \Ptr d
ptr -> do
Ptr d -> IO ()
act Ptr d
ptr
[[c d]]
controlPoints <- MapDescriptor d -> MapDescriptor d -> Ptr d -> IO [[c d]]
forall (c :: * -> *) d.
(ControlPoint c, Domain d) =>
MapDescriptor d -> MapDescriptor d -> Ptr d -> IO [[c d]]
peekControlPoints2 MapDescriptor d
uDescriptor MapDescriptor d
vDescriptor Ptr d
ptr
(d, d) -> (d, d) -> [[c d]] -> IO (m c d)
forall (m :: (* -> *) -> * -> *) (c :: * -> *) d.
(Map2 m, ControlPoint c, Domain d) =>
(d, d) -> (d, d) -> [[c d]] -> IO (m c d)
newMap2 (d, d)
uDomain (d, d)
vDomain [[c d]]
controlPoints
withMap2 m c d
m MapDescriptor d -> MapDescriptor d -> Ptr d -> IO a
act = do
((d, d)
uDomain, (d, d)
vDomain, [[c d]]
controlPoints) <- m c d -> IO ((d, d), (d, d), [[c d]])
forall (m :: (* -> *) -> * -> *) (c :: * -> *) d.
(Map2 m, ControlPoint c, Domain d) =>
m c d -> IO ((d, d), (d, d), [[c d]])
getMap2Components m c d
m
let vStride :: Order
vStride = c d -> Order
forall (c :: * -> *) d. (ControlPoint c, Domain d) => c d -> Order
numComponents ([c d] -> c d
forall a. [a] -> a
head ([[c d]] -> [c d]
forall a. [a] -> a
head [[c d]]
controlPoints))
vOrder :: Order
vOrder = [c d] -> Order
forall i a. Num i => [a] -> i
genericLength ([[c d]] -> [c d]
forall a. [a] -> a
head [[c d]]
controlPoints)
uStride :: Order
uStride = Order
vStride Order -> Order -> Order
forall a. Num a => a -> a -> a
* Order -> Order
forall a b. (Integral a, Num b) => a -> b
fromIntegral Order
vOrder
uOrder :: Order
uOrder = [[c d]] -> Order
forall i a. Num i => [a] -> i
genericLength [[c d]]
controlPoints
numComp :: Order
numComp = Order -> Order
forall a b. (Integral a, Num b) => a -> b
fromIntegral Order
vStride
uDescriptor :: MapDescriptor d
uDescriptor = (d, d) -> Order -> Order -> Order -> MapDescriptor d
forall d. (d, d) -> Order -> Order -> Order -> MapDescriptor d
MapDescriptor (d, d)
uDomain Order
uStride Order
uOrder Order
numComp
vDescriptor :: MapDescriptor d
vDescriptor = (d, d) -> Order -> Order -> Order -> MapDescriptor d
forall d. (d, d) -> Order -> Order -> Order -> MapDescriptor d
MapDescriptor (d, d)
vDomain Order
vStride Order
vOrder Order
numComp
Int -> (Ptr d -> IO a) -> IO a
forall a b. Storable a => Int -> (Ptr a -> IO b) -> IO b
allocaArray (MapDescriptor d -> MapDescriptor d -> Int
forall d. MapDescriptor d -> MapDescriptor d -> Int
totalComponents2 MapDescriptor d
uDescriptor MapDescriptor d
vDescriptor) ((Ptr d -> IO a) -> IO a) -> (Ptr d -> IO a) -> IO a
forall a b. (a -> b) -> a -> b
$ \Ptr d
ptr -> do
MapDescriptor d -> MapDescriptor d -> Ptr d -> [[c d]] -> IO ()
forall (c :: * -> *) d.
(ControlPoint c, Domain d) =>
MapDescriptor d -> MapDescriptor d -> Ptr d -> [[c d]] -> IO ()
pokeControlPoints2 MapDescriptor d
uDescriptor MapDescriptor d
vDescriptor Ptr d
ptr [[c d]]
controlPoints
MapDescriptor d -> MapDescriptor d -> Ptr d -> IO a
act MapDescriptor d
uDescriptor MapDescriptor d
vDescriptor Ptr d
ptr
newMap2 (d, d)
uDomain (d, d)
vDomain [[c d]]
controlPoints = do
let vStride :: Order
vStride = c d -> Order
forall (c :: * -> *) d. (ControlPoint c, Domain d) => c d -> Order
numComponents ([c d] -> c d
forall a. [a] -> a
head ([[c d]] -> [c d]
forall a. [a] -> a
head [[c d]]
controlPoints))
vOrder :: Order
vOrder = [c d] -> Order
forall i a. Num i => [a] -> i
genericLength ([[c d]] -> [c d]
forall a. [a] -> a
head [[c d]]
controlPoints)
uStride :: Order
uStride = Order
vStride Order -> Order -> Order
forall a. Num a => a -> a -> a
* Order -> Order
forall a b. (Integral a, Num b) => a -> b
fromIntegral Order
vOrder
uOrder :: Order
uOrder = [[c d]] -> Order
forall i a. Num i => [a] -> i
genericLength [[c d]]
controlPoints
numComp :: Order
numComp = Order -> Order
forall a b. (Integral a, Num b) => a -> b
fromIntegral Order
vStride
uDescriptor :: MapDescriptor d
uDescriptor = (d, d) -> Order -> Order -> Order -> MapDescriptor d
forall d. (d, d) -> Order -> Order -> Order -> MapDescriptor d
MapDescriptor (d, d)
uDomain Order
uStride Order
uOrder Order
numComp
vDescriptor :: MapDescriptor d
vDescriptor = (d, d) -> Order -> Order -> Order -> MapDescriptor d
forall d. (d, d) -> Order -> Order -> Order -> MapDescriptor d
MapDescriptor (d, d)
vDomain Order
vStride Order
vOrder Order
numComp
MapDescriptor d
-> MapDescriptor d -> (Ptr d -> IO ()) -> IO (m c d)
forall (m :: (* -> *) -> * -> *) (c :: * -> *) d.
(Map2 m, ControlPoint c, Domain d) =>
MapDescriptor d
-> MapDescriptor d -> (Ptr d -> IO ()) -> IO (m c d)
withNewMap2 MapDescriptor d
uDescriptor MapDescriptor d
vDescriptor ((Ptr d -> IO ()) -> IO (m c d)) -> (Ptr d -> IO ()) -> IO (m c d)
forall a b. (a -> b) -> a -> b
$ \Ptr d
ptr ->
MapDescriptor d -> MapDescriptor d -> Ptr d -> [[c d]] -> IO ()
forall (c :: * -> *) d.
(ControlPoint c, Domain d) =>
MapDescriptor d -> MapDescriptor d -> Ptr d -> [[c d]] -> IO ()
pokeControlPoints2 MapDescriptor d
uDescriptor MapDescriptor d
vDescriptor Ptr d
ptr [[c d]]
controlPoints
getMap2Components m c d
m =
m c d
-> (MapDescriptor d
-> MapDescriptor d -> Ptr d -> IO ((d, d), (d, d), [[c d]]))
-> IO ((d, d), (d, d), [[c d]])
forall (m :: (* -> *) -> * -> *) (c :: * -> *) d a.
(Map2 m, ControlPoint c, Domain d) =>
m c d
-> (MapDescriptor d -> MapDescriptor d -> Ptr d -> IO a) -> IO a
withMap2 m c d
m ((MapDescriptor d
-> MapDescriptor d -> Ptr d -> IO ((d, d), (d, d), [[c d]]))
-> IO ((d, d), (d, d), [[c d]]))
-> (MapDescriptor d
-> MapDescriptor d -> Ptr d -> IO ((d, d), (d, d), [[c d]]))
-> IO ((d, d), (d, d), [[c d]])
forall a b. (a -> b) -> a -> b
$ \uDescriptor :: MapDescriptor d
uDescriptor@(MapDescriptor (d, d)
uDomain Order
_ Order
_ Order
_)
vDescriptor :: MapDescriptor d
vDescriptor@(MapDescriptor (d, d)
vDomain Order
_ Order
_ Order
_) Ptr d
ptr -> do
[[c d]]
controlPoints <- MapDescriptor d -> MapDescriptor d -> Ptr d -> IO [[c d]]
forall (c :: * -> *) d.
(ControlPoint c, Domain d) =>
MapDescriptor d -> MapDescriptor d -> Ptr d -> IO [[c d]]
peekControlPoints2 MapDescriptor d
uDescriptor MapDescriptor d
vDescriptor Ptr d
ptr
((d, d), (d, d), [[c d]]) -> IO ((d, d), (d, d), [[c d]])
forall (m :: * -> *) a. Monad m => a -> m a
return ((d, d)
uDomain, (d, d)
vDomain, [[c d]]
controlPoints)
data GLmap2 (c :: * -> *) d =
GLmap2 (MapDescriptor d) (MapDescriptor d) (ForeignPtr d)
deriving ( GLmap2 c d -> GLmap2 c d -> Bool
(GLmap2 c d -> GLmap2 c d -> Bool)
-> (GLmap2 c d -> GLmap2 c d -> Bool) -> Eq (GLmap2 c d)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall (c :: * -> *) d. Eq d => GLmap2 c d -> GLmap2 c d -> Bool
/= :: GLmap2 c d -> GLmap2 c d -> Bool
$c/= :: forall (c :: * -> *) d. Eq d => GLmap2 c d -> GLmap2 c d -> Bool
== :: GLmap2 c d -> GLmap2 c d -> Bool
$c== :: forall (c :: * -> *) d. Eq d => GLmap2 c d -> GLmap2 c d -> Bool
Eq, Eq (GLmap2 c d)
Eq (GLmap2 c d)
-> (GLmap2 c d -> GLmap2 c d -> Ordering)
-> (GLmap2 c d -> GLmap2 c d -> Bool)
-> (GLmap2 c d -> GLmap2 c d -> Bool)
-> (GLmap2 c d -> GLmap2 c d -> Bool)
-> (GLmap2 c d -> GLmap2 c d -> Bool)
-> (GLmap2 c d -> GLmap2 c d -> GLmap2 c d)
-> (GLmap2 c d -> GLmap2 c d -> GLmap2 c d)
-> Ord (GLmap2 c d)
GLmap2 c d -> GLmap2 c d -> Bool
GLmap2 c d -> GLmap2 c d -> Ordering
GLmap2 c d -> GLmap2 c d -> GLmap2 c d
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
forall (c :: * -> *) d. Ord d => Eq (GLmap2 c d)
forall (c :: * -> *) d. Ord d => GLmap2 c d -> GLmap2 c d -> Bool
forall (c :: * -> *) d.
Ord d =>
GLmap2 c d -> GLmap2 c d -> Ordering
forall (c :: * -> *) d.
Ord d =>
GLmap2 c d -> GLmap2 c d -> GLmap2 c d
min :: GLmap2 c d -> GLmap2 c d -> GLmap2 c d
$cmin :: forall (c :: * -> *) d.
Ord d =>
GLmap2 c d -> GLmap2 c d -> GLmap2 c d
max :: GLmap2 c d -> GLmap2 c d -> GLmap2 c d
$cmax :: forall (c :: * -> *) d.
Ord d =>
GLmap2 c d -> GLmap2 c d -> GLmap2 c d
>= :: GLmap2 c d -> GLmap2 c d -> Bool
$c>= :: forall (c :: * -> *) d. Ord d => GLmap2 c d -> GLmap2 c d -> Bool
> :: GLmap2 c d -> GLmap2 c d -> Bool
$c> :: forall (c :: * -> *) d. Ord d => GLmap2 c d -> GLmap2 c d -> Bool
<= :: GLmap2 c d -> GLmap2 c d -> Bool
$c<= :: forall (c :: * -> *) d. Ord d => GLmap2 c d -> GLmap2 c d -> Bool
< :: GLmap2 c d -> GLmap2 c d -> Bool
$c< :: forall (c :: * -> *) d. Ord d => GLmap2 c d -> GLmap2 c d -> Bool
compare :: GLmap2 c d -> GLmap2 c d -> Ordering
$ccompare :: forall (c :: * -> *) d.
Ord d =>
GLmap2 c d -> GLmap2 c d -> Ordering
$cp1Ord :: forall (c :: * -> *) d. Ord d => Eq (GLmap2 c d)
Ord, Int -> GLmap2 c d -> ShowS
[GLmap2 c d] -> ShowS
GLmap2 c d -> String
(Int -> GLmap2 c d -> ShowS)
-> (GLmap2 c d -> String)
-> ([GLmap2 c d] -> ShowS)
-> Show (GLmap2 c d)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall (c :: * -> *) d. Show d => Int -> GLmap2 c d -> ShowS
forall (c :: * -> *) d. Show d => [GLmap2 c d] -> ShowS
forall (c :: * -> *) d. Show d => GLmap2 c d -> String
showList :: [GLmap2 c d] -> ShowS
$cshowList :: forall (c :: * -> *) d. Show d => [GLmap2 c d] -> ShowS
show :: GLmap2 c d -> String
$cshow :: forall (c :: * -> *) d. Show d => GLmap2 c d -> String
showsPrec :: Int -> GLmap2 c d -> ShowS
$cshowsPrec :: forall (c :: * -> *) d. Show d => Int -> GLmap2 c d -> ShowS
Show )
instance Map2 GLmap2 where
withNewMap2 :: MapDescriptor d
-> MapDescriptor d -> (Ptr d -> IO ()) -> IO (GLmap2 c d)
withNewMap2 MapDescriptor d
uDescriptor MapDescriptor d
vDescriptor Ptr d -> IO ()
act = do
ForeignPtr d
fp <- Int -> IO (ForeignPtr d)
forall a. Storable a => Int -> IO (ForeignPtr a)
mallocForeignPtrArray (MapDescriptor d -> MapDescriptor d -> Int
forall d. MapDescriptor d -> MapDescriptor d -> Int
totalComponents2 MapDescriptor d
uDescriptor MapDescriptor d
vDescriptor)
ForeignPtr d -> (Ptr d -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr d
fp Ptr d -> IO ()
act
GLmap2 c d -> IO (GLmap2 c d)
forall (m :: * -> *) a. Monad m => a -> m a
return (GLmap2 c d -> IO (GLmap2 c d)) -> GLmap2 c d -> IO (GLmap2 c d)
forall a b. (a -> b) -> a -> b
$ MapDescriptor d -> MapDescriptor d -> ForeignPtr d -> GLmap2 c d
forall (c :: * -> *) d.
MapDescriptor d -> MapDescriptor d -> ForeignPtr d -> GLmap2 c d
GLmap2 MapDescriptor d
uDescriptor MapDescriptor d
vDescriptor ForeignPtr d
fp
withMap2 :: GLmap2 c d
-> (MapDescriptor d -> MapDescriptor d -> Ptr d -> IO a) -> IO a
withMap2 (GLmap2 MapDescriptor d
uDescriptor MapDescriptor d
vDescriptor ForeignPtr d
fp) MapDescriptor d -> MapDescriptor d -> Ptr d -> IO a
act =
ForeignPtr d -> (Ptr d -> IO a) -> IO a
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr d
fp ((Ptr d -> IO a) -> IO a) -> (Ptr d -> IO a) -> IO a
forall a b. (a -> b) -> a -> b
$ MapDescriptor d -> MapDescriptor d -> Ptr d -> IO a
act MapDescriptor d
uDescriptor MapDescriptor d
vDescriptor
map2 :: (Map2 m, ControlPoint c, Domain d) => StateVar (Maybe (m c d))
map2 :: StateVar (Maybe (m c d))
map2 = (c d -> EnableCap)
-> (c d -> IO (m c d))
-> (c d -> m c d -> IO ())
-> StateVar (Maybe (m c d))
forall (c :: * -> *) d (m :: (* -> *) -> * -> *).
(c d -> EnableCap)
-> (c d -> IO (m c d))
-> (c d -> m c d -> IO ())
-> StateVar (Maybe (m c d))
makeMap2StateVar c d -> EnableCap
forall (c :: * -> *) d.
(ControlPoint c, Domain d) =>
c d -> EnableCap
enableCap2 c d -> IO (m c d)
forall (m :: (* -> *) -> * -> *) (c :: * -> *) d.
(Map2 m, ControlPoint c, Domain d) =>
c d -> IO (m c d)
getMap2 c d -> m c d -> IO ()
forall (m :: (* -> *) -> * -> *) (c :: * -> *) d.
(Map2 m, ControlPoint c, Domain d) =>
c d -> m c d -> IO ()
setMap2
makeMap2StateVar ::
(c d -> EnableCap) -> (c d -> IO (m c d)) -> (c d -> m c d -> IO ())
-> StateVar (Maybe (m c d))
makeMap2StateVar :: (c d -> EnableCap)
-> (c d -> IO (m c d))
-> (c d -> m c d -> IO ())
-> StateVar (Maybe (m c d))
makeMap2StateVar c d -> EnableCap
getCap c d -> IO (m c d)
getAct c d -> m c d -> IO ()
setAct =
IO EnableCap
-> IO (m c d) -> (m c d -> IO ()) -> StateVar (Maybe (m c d))
forall a.
IO EnableCap -> IO a -> (a -> IO ()) -> StateVar (Maybe a)
makeStateVarMaybe
(EnableCap -> IO EnableCap
forall (m :: * -> *) a. Monad m => a -> m a
return (c d -> EnableCap
getCap c d
forall a. HasCallStack => a
undefined))
(c d -> IO (m c d)
getAct c d
forall a. HasCallStack => a
undefined)
(c d -> m c d -> IO ()
setAct c d
forall a. HasCallStack => a
undefined)
getMap2 :: (Map2 m, ControlPoint c, Domain d) => c d -> IO (m c d)
getMap2 :: c d -> IO (m c d)
getMap2 c d
dummyControlPoint = do
let target :: GLenum
target = c d -> GLenum
forall (c :: * -> *) d. (ControlPoint c, Domain d) => c d -> GLenum
map2Target c d
dummyControlPoint
((d, d)
uDomain, (d, d)
vDomain) <- Int -> (Ptr d -> IO ((d, d), (d, d))) -> IO ((d, d), (d, d))
forall a b. Storable a => Int -> (Ptr a -> IO b) -> IO b
allocaArray Int
4 ((Ptr d -> IO ((d, d), (d, d))) -> IO ((d, d), (d, d)))
-> (Ptr d -> IO ((d, d), (d, d))) -> IO ((d, d), (d, d))
forall a b. (a -> b) -> a -> b
$ \Ptr d
ptr -> do
GLenum -> GLenum -> Ptr d -> IO ()
forall d. Domain d => GLenum -> GLenum -> Ptr d -> IO ()
glGetMapv GLenum
target (GetMapQuery -> GLenum
marshalGetMapQuery GetMapQuery
Domain) Ptr d
ptr
(d -> d -> d -> d -> ((d, d), (d, d)))
-> Ptr d -> IO ((d, d), (d, d))
forall a b. Storable a => (a -> a -> a -> a -> b) -> Ptr a -> IO b
peek4 (\d
u1 d
u2 d
v1 d
v2 -> ((d
u1, d
u2), (d
v1, d
v2))) Ptr d
ptr
(Order
uOrder, Order
vOrder) <- [Order] -> (Ptr Order -> IO (Order, Order)) -> IO (Order, Order)
forall a b. Storable a => [a] -> (Ptr a -> IO b) -> IO b
withArray [Order
0,Order
0] ((Ptr Order -> IO (Order, Order)) -> IO (Order, Order))
-> (Ptr Order -> IO (Order, Order)) -> IO (Order, Order)
forall a b. (a -> b) -> a -> b
$ \Ptr Order
ptr -> do
GLenum -> GLenum -> Ptr Order -> IO ()
forall (m :: * -> *).
MonadIO m =>
GLenum -> GLenum -> Ptr Order -> m ()
glGetMapiv GLenum
target (GetMapQuery -> GLenum
marshalGetMapQuery GetMapQuery
Order) Ptr Order
ptr
(Order -> Order -> (Order, Order))
-> Ptr Order -> IO (Order, Order)
forall a b. Storable a => (a -> a -> b) -> Ptr a -> IO b
peek2 (,) Ptr Order
ptr
let vStride :: Order
vStride = c d -> Order
forall (c :: * -> *) d. (ControlPoint c, Domain d) => c d -> Order
numComponents c d
dummyControlPoint
uStride :: Order
uStride = Order
vStride Order -> Order -> Order
forall a. Num a => a -> a -> a
* Order -> Order
forall a b. (Integral a, Num b) => a -> b
fromIntegral Order
vOrder
MapDescriptor d
-> MapDescriptor d -> (Ptr d -> IO ()) -> IO (m c d)
forall (m :: (* -> *) -> * -> *) (c :: * -> *) d.
(Map2 m, ControlPoint c, Domain d) =>
MapDescriptor d
-> MapDescriptor d -> (Ptr d -> IO ()) -> IO (m c d)
withNewMap2 ((d, d) -> Order -> Order -> Order -> MapDescriptor d
forall d. (d, d) -> Order -> Order -> Order -> MapDescriptor d
MapDescriptor (d, d)
uDomain Order
uStride Order
uOrder (Order -> Order
forall a b. (Integral a, Num b) => a -> b
fromIntegral Order
vStride))
((d, d) -> Order -> Order -> Order -> MapDescriptor d
forall d. (d, d) -> Order -> Order -> Order -> MapDescriptor d
MapDescriptor (d, d)
vDomain Order
vStride Order
vOrder (Order -> Order
forall a b. (Integral a, Num b) => a -> b
fromIntegral Order
vStride)) ((Ptr d -> IO ()) -> IO (m c d)) -> (Ptr d -> IO ()) -> IO (m c d)
forall a b. (a -> b) -> a -> b
$
GLenum -> GLenum -> Ptr d -> IO ()
forall d. Domain d => GLenum -> GLenum -> Ptr d -> IO ()
glGetMapv GLenum
target (GetMapQuery -> GLenum
marshalGetMapQuery GetMapQuery
Coeff)
setMap2 :: (Map2 m, ControlPoint c, Domain d) => c d -> m c d -> IO ()
setMap2 :: c d -> m c d -> IO ()
setMap2 c d
dummyControlPoint m c d
m =
m c d
-> (MapDescriptor d -> MapDescriptor d -> Ptr d -> IO ()) -> IO ()
forall (m :: (* -> *) -> * -> *) (c :: * -> *) d a.
(Map2 m, ControlPoint c, Domain d) =>
m c d
-> (MapDescriptor d -> MapDescriptor d -> Ptr d -> IO a) -> IO a
withMap2 m c d
m ((MapDescriptor d -> MapDescriptor d -> Ptr d -> IO ()) -> IO ())
-> (MapDescriptor d -> MapDescriptor d -> Ptr d -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \(MapDescriptor (d
u1, d
u2) Order
uStride Order
uOrder Order
_)
(MapDescriptor (d
v1, d
v2) Order
vStride Order
vOrder Order
_) ->
GLenum
-> d
-> d
-> Order
-> Order
-> d
-> d
-> Order
-> Order
-> Ptr d
-> IO ()
forall d.
Domain d =>
GLenum
-> d
-> d
-> Order
-> Order
-> d
-> d
-> Order
-> Order
-> Ptr d
-> IO ()
glMap2 (c d -> GLenum
forall (c :: * -> *) d. (ControlPoint c, Domain d) => c d -> GLenum
map2Target c d
dummyControlPoint)
d
u1 d
u2 (Order -> Order
forall a b. (Integral a, Num b) => a -> b
fromIntegral Order
uStride) (Order -> Order
forall a b. (Integral a, Num b) => a -> b
fromIntegral Order
uOrder)
d
v1 d
v2 (Order -> Order
forall a b. (Integral a, Num b) => a -> b
fromIntegral Order
vStride) (Order -> Order
forall a b. (Integral a, Num b) => a -> b
fromIntegral Order
vOrder)
data GetMapQuery =
Coeff
| Order
| Domain
marshalGetMapQuery :: GetMapQuery -> GLenum
marshalGetMapQuery :: GetMapQuery -> GLenum
marshalGetMapQuery GetMapQuery
x = case GetMapQuery
x of
GetMapQuery
Coeff -> GLenum
GL_COEFF
GetMapQuery
Order -> GLenum
GL_ORDER
GetMapQuery
Domain -> GLenum
GL_DOMAIN
mapGrid1 :: Domain d => StateVar (GLint, (d, d))
mapGrid1 :: StateVar (Order, (d, d))
mapGrid1 =
IO (Order, (d, d))
-> ((Order, (d, d)) -> IO ()) -> StateVar (Order, (d, d))
forall a. IO a -> (a -> IO ()) -> StateVar a
makeStateVar
(do Order
n <- (Order -> Order) -> PName1I -> GettableStateVar Order
forall p a. GetPName1I p => (Order -> a) -> p -> IO a
getInteger1 Order -> Order
forall a. a -> a
id PName1I
GetMap1GridSegments
(d, d)
domain <- (d -> d -> (d, d)) -> PName2F -> IO (d, d)
forall d p a.
(Domain d, GetPName2F p) =>
(d -> d -> a) -> p -> IO a
get2 (,) PName2F
GetMap1GridDomain
(Order, (d, d)) -> IO (Order, (d, d))
forall (m :: * -> *) a. Monad m => a -> m a
return (Order
n, (d, d)
domain))
(\(Order
n, (d
u1, d
u2)) -> Order -> d -> d -> IO ()
forall d. Domain d => Order -> d -> d -> IO ()
glMapGrid1 Order
n d
u1 d
u2)
mapGrid2 :: Domain d => StateVar ((GLint, (d, d)), (GLint, (d, d)))
mapGrid2 :: StateVar ((Order, (d, d)), (Order, (d, d)))
mapGrid2 =
IO ((Order, (d, d)), (Order, (d, d)))
-> (((Order, (d, d)), (Order, (d, d))) -> IO ())
-> StateVar ((Order, (d, d)), (Order, (d, d)))
forall a. IO a -> (a -> IO ()) -> StateVar a
makeStateVar
(do (Order
un, Order
vn) <- (Order -> Order -> (Order, Order)) -> PName2I -> IO (Order, Order)
forall p a. GetPName2I p => (Order -> Order -> a) -> p -> IO a
getInteger2 (,) PName2I
GetMap2GridSegments
(d
u1, d
u2, d
v1, d
v2) <- (d -> d -> d -> d -> (d, d, d, d)) -> PName4F -> IO (d, d, d, d)
forall d p a.
(Domain d, GetPName4F p) =>
(d -> d -> d -> d -> a) -> p -> IO a
get4 (,,,) PName4F
GetMap2GridDomain
((Order, (d, d)), (Order, (d, d)))
-> IO ((Order, (d, d)), (Order, (d, d)))
forall (m :: * -> *) a. Monad m => a -> m a
return ((Order
un, (d
u1, d
u2)), (Order
vn, (d
v1, d
v2))))
(\((Order
un, (d
u1, d
u2)), (Order
vn, (d
v1, d
v2))) -> Order -> d -> d -> Order -> d -> d -> IO ()
forall d. Domain d => Order -> d -> d -> Order -> d -> d -> IO ()
glMapGrid2 Order
un d
u1 d
u2 Order
vn d
v1 d
v2)
evalMesh1 :: PolygonMode -> (GLint, GLint) -> IO ()
evalMesh1 :: PolygonMode -> (Order, Order) -> IO ()
evalMesh1 PolygonMode
m (Order
p1, Order
p2) = GLenum -> Order -> Order -> IO ()
forall (m :: * -> *). MonadIO m => GLenum -> Order -> Order -> m ()
glEvalMesh1 (PolygonMode -> GLenum
marshalPolygonMode PolygonMode
m) Order
p1 Order
p2
evalMesh2 :: PolygonMode -> (GLint, GLint) -> (GLint, GLint) -> IO ()
evalMesh2 :: PolygonMode -> (Order, Order) -> (Order, Order) -> IO ()
evalMesh2 PolygonMode
m (Order
p1, Order
p2) (Order
q1, Order
q2) = GLenum -> Order -> Order -> Order -> Order -> IO ()
forall (m :: * -> *).
MonadIO m =>
GLenum -> Order -> Order -> Order -> Order -> m ()
glEvalMesh2 (PolygonMode -> GLenum
marshalPolygonMode PolygonMode
m) Order
p1 Order
p2 Order
q1 Order
q2
evalPoint1 :: GLint -> IO ()
evalPoint1 :: Order -> IO ()
evalPoint1 = Order -> IO ()
forall (m :: * -> *). MonadIO m => Order -> m ()
glEvalPoint1
evalPoint2 :: (GLint, GLint) -> IO ()
evalPoint2 :: (Order, Order) -> IO ()
evalPoint2 = (Order -> Order -> IO ()) -> (Order, Order) -> IO ()
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry Order -> Order -> IO ()
forall (m :: * -> *). MonadIO m => Order -> Order -> m ()
glEvalPoint2
autoNormal :: StateVar Capability
autoNormal :: StateVar Capability
autoNormal = EnableCap -> StateVar Capability
makeCapability EnableCap
CapAutoNormal