summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2019-05-06 19:29:36 -0400
committerJoe Crayne <joe@jerkface.net>2019-05-06 19:29:36 -0400
commit4c5fe84a424cf6329c7b8cb305d6958ed33b62e6 (patch)
tree69ce2307436808d57242e57976cd34c0b2a118cb
parentd78081b4c9486a7b1ef4211a175bf4f32e66d1f8 (diff)
Renamed LambdaCube.GL.Uniform.
-rw-r--r--LambdaCube/GL/HMatrix.hs18
1 files changed, 7 insertions, 11 deletions
diff --git a/LambdaCube/GL/HMatrix.hs b/LambdaCube/GL/HMatrix.hs
index 127656e..026d5c1 100644
--- a/LambdaCube/GL/HMatrix.hs
+++ b/LambdaCube/GL/HMatrix.hs
@@ -1,27 +1,23 @@
1{-# LANGUAGE PatternSynonyms #-}
2{-# LANGUAGE FlexibleInstances #-} 1{-# LANGUAGE FlexibleInstances #-}
3{-# LANGUAGE MultiParamTypeClasses #-} 2{-# LANGUAGE MultiParamTypeClasses #-}
4module LambdaCube.GL.HMatrix where 3module LambdaCube.GL.HMatrix where
5 4
6import GHC.TypeLits 5import GHC.TypeLits
7 6import LambdaCube.GL.Input.Type
8import LambdaCube.GL.Uniform
9import Numeric.LinearAlgebra 7import Numeric.LinearAlgebra
10import Numeric.LinearAlgebra.Devel 8import Numeric.LinearAlgebra.Devel
11 9
12import Graphics.Rendering.OpenGL.GL (GLboolean)
13
14instance Uniformable (Matrix Float) where 10instance Uniformable (Matrix Float) where
15 uniformContexts _ = contexts floatMatrices 11 uniformContexts _ = contexts floatMatrices
16 12
17instance (KnownNat r, KnownNat c) => IsUniform (Matrix Float) (UMatrix r c Float) where 13instance (KnownNat r, KnownNat c) => GLData (Matrix Float) (GLMatrix r c Float) where
18 marshalUniform abi mat = case matrixDimensions abi of 14 marshalUniform abi mat = case matrixDimensions abi of
19 (r,c) | fromIntegral (natVal r) /= rows mat -> Nothing 15 (r,c) | fromIntegral (natVal r) /= rows mat -> Nothing
20 | fromIntegral (natVal c) /= cols mat -> Nothing 16 | fromIntegral (natVal c) /= cols mat -> Nothing
21 _ -> let isRowOrder = case orderOf mat of 17 _ -> let isRowOrder = case orderOf mat of
22 RowMajor -> 1 :: GLboolean 18 RowMajor -> 1
23 ColumnMajor -> 0 :: GLboolean 19 ColumnMajor -> 0
24 in Just $ MarshalUMatrix 20 in Just $ MarshalGLMatrix
25 $ \f -> apply mat (\ptr -> f 1 isRowOrder ptr) (\r c sr sc ptr -> ptr) 21 $ \f -> apply mat (\ptr -> f 1 isRowOrder ptr) (\r c sr sc ptr -> ptr)
26 22
27instance Uniformable (Vector Float) where 23instance Uniformable (Vector Float) where
@@ -31,10 +27,10 @@ instance Uniformable (Vector Float) where
31 supports TypeV3F 27 supports TypeV3F
32 supports TypeV4F 28 supports TypeV4F
33 29
34instance KnownNat n => IsUniform (Vector Float) (USimple n Float) where 30instance KnownNat n => GLData (Vector Float) (GLVector n Float) where
35 marshalUniform abi vec 31 marshalUniform abi vec
36 | natVal (vectorLength abi) /= fromIntegral (size vec) = Nothing 32 | natVal (vectorLength abi) /= fromIntegral (size vec) = Nothing
37 | otherwise = Just $ MarshalUSimple 33 | otherwise = Just $ MarshalGLVector
38 $ \f -> apply vec (\ptr -> f 1 ptr) (\n ptr -> ptr) 34 $ \f -> apply vec (\ptr -> f 1 ptr) (\n ptr -> ptr)
39 35
40{- 36{-