diff options
author | Joe Crayne <joe@jerkface.net> | 2019-04-22 05:05:31 -0400 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2019-04-22 05:05:31 -0400 |
commit | 158564b28f4316b4c140457d543ec4d65391a043 (patch) | |
tree | 7889891c8112bfa05af8bd94d6d8de053f617456 /mainObj.hs | |
parent | a5be1222b3522dd9e58a10dfb4d3210970faab02 (diff) |
Pass entire model-view-projection matrix from haskell.
Diffstat (limited to 'mainObj.hs')
-rw-r--r-- | mainObj.hs | 17 |
1 files changed, 11 insertions, 6 deletions
@@ -74,18 +74,23 @@ destroyState :: GLArea -> State -> IO () | |||
74 | destroyState glarea st = do | 74 | destroyState glarea st = do |
75 | widgetRemoveTickCallback glarea (stTickCallback st) | 75 | widgetRemoveTickCallback glarea (stTickCallback st) |
76 | 76 | ||
77 | deg30 :: Float | ||
78 | deg30 = pi/6 | ||
79 | |||
77 | setUniforms :: glctx -> GLStorage -> State -> IO () | 80 | setUniforms :: glctx -> GLStorage -> State -> IO () |
78 | setUniforms gl storage st = do | 81 | setUniforms 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 | ||
90 | main :: IO () | 95 | main :: IO () |
91 | main = do | 96 | main = do |