diff options
author | Csaba Hruska <csaba.hruska@gmail.com> | 2015-06-05 08:32:27 +0100 |
---|---|---|
committer | Csaba Hruska <csaba.hruska@gmail.com> | 2015-06-05 08:32:27 +0100 |
commit | 23747de92cb2883e3a0ce97805e354ea502378fc (patch) | |
tree | 540f2cc33280af75d6a87c53fa76172193dacc32 /SampleIR.hs | |
parent | 9fc7b885064bf0c16a7b057bcfa3d39e8e178535 (diff) |
add time uniform input to sample
Diffstat (limited to 'SampleIR.hs')
-rw-r--r-- | SampleIR.hs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/SampleIR.hs b/SampleIR.hs index 1332b6d..3568b38 100644 --- a/SampleIR.hs +++ b/SampleIR.hs | |||
@@ -9,7 +9,7 @@ import Data.Vect | |||
9 | import qualified Data.Trie as T | 9 | import qualified Data.Trie as T |
10 | import qualified Data.Vector.Storable as SV | 10 | import qualified Data.Vector.Storable as SV |
11 | import qualified Data.Vector as V | 11 | import qualified Data.Vector as V |
12 | import Text.Show.Pretty | 12 | import Text.Show.Pretty hiding (Float) |
13 | 13 | ||
14 | import Backend.GL as GL | 14 | import Backend.GL as GL |
15 | import Backend.GL.Mesh | 15 | import Backend.GL.Mesh |
@@ -125,7 +125,7 @@ main = do | |||
125 | { GL.slots = T.fromList [("stream",SlotSchema Triangles $ T.fromList [("position",TV3F),("normal",TV3F),("UVTex",TV2F)]) | 125 | { GL.slots = T.fromList [("stream",SlotSchema Triangles $ T.fromList [("position",TV3F),("normal",TV3F),("UVTex",TV2F)]) |
126 | ,("stream4",SlotSchema Triangles $ T.fromList [("position4",TV4F),("vertexUV",TV2F)]) | 126 | ,("stream4",SlotSchema Triangles $ T.fromList [("position4",TV4F),("vertexUV",TV2F)]) |
127 | ] | 127 | ] |
128 | , uniforms = T.fromList [("MVP",M44F),("MVP2",M44F)] | 128 | , uniforms = T.fromList [("MVP",M44F),("MVP2",M44F),("Time",Float)] |
129 | } | 129 | } |
130 | pplInput <- mkGLPipelineInput inputSchema | 130 | pplInput <- mkGLPipelineInput inputSchema |
131 | 131 | ||
@@ -156,8 +156,9 @@ main = do | |||
156 | let uniformMap = uniformSetter pplInput | 156 | let uniformMap = uniformSetter pplInput |
157 | texture = uniformFTexture2D "myTextureSampler" uniformMap | 157 | texture = uniformFTexture2D "myTextureSampler" uniformMap |
158 | mvp = uniformM44F "MVP" uniformMap | 158 | mvp = uniformM44F "MVP" uniformMap |
159 | mvp' = uniformM44F "MVP2" uniformMap | 159 | mvp' = uniformM44F "MVP2" uniformMap |
160 | pm = perspective 0.1 100 (pi/4) (fromIntegral w / fromIntegral h) | 160 | pm = perspective 0.1 100 (pi/4) (fromIntegral w / fromIntegral h) |
161 | time = uniformFloat "Time" uniformMap | ||
161 | 162 | ||
162 | setScreenSize pplInput (fromIntegral w) (fromIntegral h) | 163 | setScreenSize pplInput (fromIntegral w) (fromIntegral h) |
163 | Just t <- getTime | 164 | Just t <- getTime |
@@ -165,6 +166,7 @@ main = do | |||
165 | mm = fromProjective $ rotationEuler $ Vec3 angle 0 0 | 166 | mm = fromProjective $ rotationEuler $ Vec3 angle 0 0 |
166 | mvp $! mat4ToM44F $! mm .*. cm .*. pm | 167 | mvp $! mat4ToM44F $! mm .*. cm .*. pm |
167 | mvp' $! mat4ToM44F $! mm .*. cm' .*. pm | 168 | mvp' $! mat4ToM44F $! mm .*. cm' .*. pm |
169 | time $ realToFrac t | ||
168 | renderPipeline renderer | 170 | renderPipeline renderer |
169 | swapBuffers win >> pollEvents | 171 | swapBuffers win >> pollEvents |
170 | 172 | ||