aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Spear/Render/AnimatedModel.hs30
-rw-r--r--Spear/Render/StaticModel.hs28
2 files changed, 33 insertions, 25 deletions
diff --git a/Spear/Render/AnimatedModel.hs b/Spear/Render/AnimatedModel.hs
index 2673db8..1703141 100644
--- a/Spear/Render/AnimatedModel.hs
+++ b/Spear/Render/AnimatedModel.hs
@@ -1,20 +1,24 @@
1module Spear.Render.AnimatedModel 1module Spear.Render.AnimatedModel
2( 2(
3 -- * Data types
3 AnimatedModelResource 4 AnimatedModelResource
4, AnimatedModelRenderer 5, AnimatedModelRenderer
5, AnimationSpeed 6, AnimationSpeed
7 -- * Construction and destruction
6, animatedModelResource 8, animatedModelResource
7, animatedModelRenderer 9, animatedModelRenderer
8, Spear.Render.AnimatedModel.release 10, Spear.Render.AnimatedModel.release
11 -- * Manipulation
12, update
9, setAnimation 13, setAnimation
10, currentAnimation 14, currentAnimation
11, animationSpeed 15, animationSpeed
12, setAnimationSpeed 16, setAnimationSpeed
13, bind
14, render
15, update
16, box 17, box
17, modelRes 18, modelRes
19 -- * Rendering
20, bind
21, render
18) 22)
19where 23where
20 24
@@ -179,6 +183,16 @@ setAnimationSpeed :: AnimationSpeed -> AnimatedModelRenderer -> AnimatedModelRen
179setAnimationSpeed s r = r { animationSpeed = s } 183setAnimationSpeed s r = r { animationSpeed = s }
180 184
181 185
186-- | Get the model's ith bounding box.
187box :: Int -> AnimatedModelResource -> Box
188box i model = boxes model V.! i
189
190
191-- | Get the renderer's model resource.
192modelRes :: AnimatedModelRenderer -> AnimatedModelResource
193modelRes = modelResource
194
195
182-- | Bind the given 'AnimatedModelRenderer' to prepare it for rendering. 196-- | Bind the given 'AnimatedModelRenderer' to prepare it for rendering.
183bind :: AnimatedProgramUniforms -> AnimatedModelRenderer -> IO () 197bind :: AnimatedProgramUniforms -> AnimatedModelRenderer -> IO ()
184bind (AnimatedProgramUniforms kaLoc kdLoc ksLoc shiLoc texLoc _ _ _ _) modelRend = 198bind (AnimatedProgramUniforms kaLoc kdLoc ksLoc shiLoc texLoc _ _ _ _) modelRend =
@@ -202,13 +216,3 @@ render uniforms (AnimatedModelRenderer model _ _ _ curFrame fp _) =
202 glUniform1f (shiLoc uniforms) $ unsafeCoerce shi 216 glUniform1f (shiLoc uniforms) $ unsafeCoerce shi
203 glUniform1f (fpLoc uniforms) (unsafeCoerce fp) 217 glUniform1f (fpLoc uniforms) (unsafeCoerce fp)
204 drawArrays gl_TRIANGLES (n*curFrame) n 218 drawArrays gl_TRIANGLES (n*curFrame) n
205
206
207-- | Get the model's ith bounding box.
208box :: Int -> AnimatedModelResource -> Box
209box i model = boxes model V.! i
210
211
212-- | Get the renderer's model resource.
213modelRes :: AnimatedModelRenderer -> AnimatedModelResource
214modelRes = modelResource
diff --git a/Spear/Render/StaticModel.hs b/Spear/Render/StaticModel.hs
index 473df1b..31acaa2 100644
--- a/Spear/Render/StaticModel.hs
+++ b/Spear/Render/StaticModel.hs
@@ -1,14 +1,18 @@
1module Spear.Render.StaticModel 1module Spear.Render.StaticModel
2( 2(
3 -- * Data types
3 StaticModelResource 4 StaticModelResource
4, StaticModelRenderer 5, StaticModelRenderer
6 -- * Construction and destruction
5, staticModelResource 7, staticModelResource
6, staticModelRenderer 8, staticModelRenderer
7, Spear.Render.StaticModel.release 9, Spear.Render.StaticModel.release
8, bind 10 -- * Manipulation
9, render
10, box 11, box
11, modelRes 12, modelRes
13 -- * Rendering
14, bind
15, render
12) 16)
13where 17where
14 18
@@ -107,6 +111,16 @@ staticModelRenderer :: StaticModelResource -> StaticModelRenderer
107staticModelRenderer = StaticModelRenderer 111staticModelRenderer = StaticModelRenderer
108 112
109 113
114-- | Get the model's ith bounding box.
115box :: Int -> StaticModelResource -> Box
116box i model = boxes model V.! i
117
118
119-- | Get the renderer's model resource.
120modelRes :: StaticModelRenderer -> StaticModelResource
121modelRes = model
122
123
110-- | Bind the given 'StaticModelRenderer' to prepare it for rendering. 124-- | Bind the given 'StaticModelRenderer' to prepare it for rendering.
111bind :: StaticProgramUniforms -> StaticModelRenderer -> IO () 125bind :: StaticProgramUniforms -> StaticModelRenderer -> IO ()
112bind (StaticProgramUniforms kaLoc kdLoc ksLoc shiLoc texLoc _ _ _) (StaticModelRenderer model) = 126bind (StaticProgramUniforms kaLoc kdLoc ksLoc shiLoc texLoc _ _ _) (StaticModelRenderer model) =
@@ -128,13 +142,3 @@ render uniforms (StaticModelRenderer model) =
128 uniformVec4 (ksLoc uniforms) ks 142 uniformVec4 (ksLoc uniforms) ks
129 glUniform1f (shiLoc uniforms) $ unsafeCoerce shi 143 glUniform1f (shiLoc uniforms) $ unsafeCoerce shi
130 drawArrays gl_TRIANGLES 0 $ nVertices model 144 drawArrays gl_TRIANGLES 0 $ nVertices model
131
132
133-- | Get the model's ith bounding box.
134box :: Int -> StaticModelResource -> Box
135box i model = boxes model V.! i
136
137
138-- | Get the renderer's model resource.
139modelRes :: StaticModelRenderer -> StaticModelResource
140modelRes = model