diff options
author | Csaba Hruska <csaba.hruska@gmail.com> | 2016-07-10 14:57:22 +0200 |
---|---|---|
committer | Csaba Hruska <csaba.hruska@gmail.com> | 2016-07-10 14:57:22 +0200 |
commit | 9d06d5a3b467ddf56147f87531fb56b35375dbd2 (patch) | |
tree | 8708b8773589fcfe9042e9b99db96b68f5484b60 | |
parent | 7f48d5e7dc0e02dc0da20c0ae3d0af9c6e041848 (diff) |
add updateObjectUniforms
-rw-r--r-- | lambdacube-gl.cabal | 2 | ||||
-rw-r--r-- | src/LambdaCube/GL.hs | 3 | ||||
-rw-r--r-- | src/LambdaCube/GL/Input.hs | 12 |
3 files changed, 12 insertions, 5 deletions
diff --git a/lambdacube-gl.cabal b/lambdacube-gl.cabal index 9a2e16a..4f8d733 100644 --- a/lambdacube-gl.cabal +++ b/lambdacube-gl.cabal | |||
@@ -1,5 +1,5 @@ | |||
1 | name: lambdacube-gl | 1 | name: lambdacube-gl |
2 | version: 0.5.0.5 | 2 | version: 0.5.1.0 |
3 | synopsis: OpenGL 3.3 Core Profile backend for LambdaCube 3D | 3 | synopsis: OpenGL 3.3 Core Profile backend for LambdaCube 3D |
4 | description: OpenGL 3.3 Core Profile backend for LambdaCube 3D | 4 | description: OpenGL 3.3 Core Profile backend for LambdaCube 3D |
5 | homepage: http://lambdacube3d.com | 5 | homepage: http://lambdacube3d.com |
diff --git a/src/LambdaCube/GL.hs b/src/LambdaCube/GL.hs index 2b5c814..f852eab 100644 --- a/src/LambdaCube/GL.hs +++ b/src/LambdaCube/GL.hs | |||
@@ -90,7 +90,8 @@ module LambdaCube.GL ( | |||
90 | makeSchema, | 90 | makeSchema, |
91 | 91 | ||
92 | (@=), | 92 | (@=), |
93 | updateUniforms | 93 | updateUniforms, |
94 | updateObjectUniforms | ||
94 | ) where | 95 | ) where |
95 | 96 | ||
96 | import LambdaCube.GL.Type | 97 | import LambdaCube.GL.Type |
diff --git a/src/LambdaCube/GL/Input.hs b/src/LambdaCube/GL/Input.hs index 7a3b809..00b2773 100644 --- a/src/LambdaCube/GL/Input.hs +++ b/src/LambdaCube/GL/Input.hs | |||
@@ -394,12 +394,12 @@ uniformFTexture2D n is = case Map.lookup n is of | |||
394 | Just (SFTexture2D fun) -> fun | 394 | Just (SFTexture2D fun) -> fun |
395 | _ -> nullSetter n "FTexture2D" | 395 | _ -> nullSetter n "FTexture2D" |
396 | 396 | ||
397 | type UniM = Writer [GLStorage -> IO ()] | 397 | type UniM = Writer [Map GLUniformName InputSetter -> IO ()] |
398 | 398 | ||
399 | class UniformSetter a where | 399 | class UniformSetter a where |
400 | (@=) :: GLUniformName -> IO a -> UniM () | 400 | (@=) :: GLUniformName -> IO a -> UniM () |
401 | 401 | ||
402 | setUniM setUni n act = tell [\s -> let f = setUni n (uniformSetter s) in f =<< act] | 402 | setUniM setUni n act = tell [\s -> let f = setUni n s in f =<< act] |
403 | 403 | ||
404 | instance UniformSetter Bool where (@=) = setUniM uniformBool | 404 | instance UniformSetter Bool where (@=) = setUniM uniformBool |
405 | instance UniformSetter V2B where (@=) = setUniM uniformV2B | 405 | instance UniformSetter V2B where (@=) = setUniM uniformV2B |
@@ -428,4 +428,10 @@ instance UniformSetter M43F where (@=) = setUniM uniformM43F | |||
428 | instance UniformSetter M44F where (@=) = setUniM uniformM44F | 428 | instance UniformSetter M44F where (@=) = setUniM uniformM44F |
429 | instance UniformSetter TextureData where (@=) = setUniM uniformFTexture2D | 429 | instance UniformSetter TextureData where (@=) = setUniM uniformFTexture2D |
430 | 430 | ||
431 | updateUniforms storage m = sequence_ $ let l = map ($ storage) $ execWriter m in l | 431 | updateUniforms storage m = sequence_ l where |
432 | setters = uniformSetter storage | ||
433 | l = map ($ setters) $ execWriter m | ||
434 | |||
435 | updateObjectUniforms object m = sequence_ l where | ||
436 | setters = objectUniformSetter object | ||
437 | l = map ($ setters) $ execWriter m | ||