summaryrefslogtreecommitdiff
path: root/mainObj.hs
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2019-04-22 05:05:31 -0400
committerJoe Crayne <joe@jerkface.net>2019-04-22 05:05:31 -0400
commit158564b28f4316b4c140457d543ec4d65391a043 (patch)
tree7889891c8112bfa05af8bd94d6d8de053f617456 /mainObj.hs
parenta5be1222b3522dd9e58a10dfb4d3210970faab02 (diff)
Pass entire model-view-projection matrix from haskell.
Diffstat (limited to 'mainObj.hs')
-rw-r--r--mainObj.hs17
1 files changed, 11 insertions, 6 deletions
diff --git a/mainObj.hs b/mainObj.hs
index 9792ff6..0d53a26 100644
--- a/mainObj.hs
+++ b/mainObj.hs
@@ -74,18 +74,23 @@ destroyState :: GLArea -> State -> IO ()
74destroyState glarea st = do 74destroyState glarea st = do
75 widgetRemoveTickCallback glarea (stTickCallback st) 75 widgetRemoveTickCallback glarea (stTickCallback st)
76 76
77deg30 :: Float
78deg30 = pi/6
79
77setUniforms :: glctx -> GLStorage -> State -> IO () 80setUniforms :: glctx -> GLStorage -> State -> IO ()
78setUniforms gl storage st = do 81setUniforms gl storage st = do
79 t <- getSeconds $ stTimeKeeper st 82 t <- getSeconds $ stTimeKeeper st
80 let tf = realToFrac t :: Float 83 let tf = realToFrac t :: Float
81 roZ = rotMatrixZ (-tf) 84 rot = rotMatrixZ (-tf) <> rotMatrixX (-tf)
82 roX = rotMatrixX (-tf) 85 pos = rot #> fromList [0,0,10]
83 ro = roZ <> roX 86 up = rot #> fromList [0,1,0]
84 pos = ro #> fromList [0,0,10]
85 up = ro #> fromList [0,1,0]
86 cam = lookat pos 0 up 87 cam = lookat pos 0 up
88 aspect = 1
89 proj = perspective 0.1 100 deg30 aspect
90 mvp = proj <> cam
91
87 LC.updateUniforms storage $ do 92 LC.updateUniforms storage $ do
88 "cam" @= return (cam :: Matrix Float) 93 "cam" @= return (mvp :: Matrix Float)
89 94
90main :: IO () 95main :: IO ()
91main = do 96main = do