From 96ffab821c88238e0217dcfa0584f188d1a82ca5 Mon Sep 17 00:00:00 2001 From: Marc Sunet Date: Wed, 29 Aug 2012 13:45:26 +0200 Subject: Render now calls useProgram --- Spear.lkshw | 4 ++-- Spear/Scene/GameObject.hs | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Spear.lkshw b/Spear.lkshw index 3c4b807..d50242a 100644 --- a/Spear.lkshw +++ b/Spear.lkshw @@ -1,10 +1,10 @@ Version of workspace file format: 1 Time of storage: - "Wed Aug 29 13:08:08 CEST 2012" + "Wed Aug 29 13:16:24 CEST 2012" Name of the workspace: "Spear" File paths of contained packages: ["demos/simple-scene/simple-scene.cabal","Spear.cabal"] Maybe file path of an active package: - Just "demos/simple-scene/simple-scene.cabal" \ No newline at end of file + Just "Spear.cabal" \ No newline at end of file diff --git a/Spear/Scene/GameObject.hs b/Spear/Scene/GameObject.hs index 0fcdd4f..8a445a7 100644 --- a/Spear/Scene/GameObject.hs +++ b/Spear/Scene/GameObject.hs @@ -17,6 +17,7 @@ where import Spear.Collision.Collision import Spear.Collision.Collisioner as Col +import Spear.GLSL.Management import Spear.GLSL.Uniform import Spear.Math.AABB import qualified Spear.Math.Camera as Cam @@ -148,8 +149,8 @@ goRender sprog aprog cam go = mat = S2.transform go style = gameStyle go in case renderer go of - Left smr -> goRender' style spu mat cam (SM.bind spu smr) (SM.render spu smr) - Right amr -> goRender' style apu mat cam (AM.bind apu amr) (AM.render apu amr) + Left smr -> goRender' style sprog spu mat cam (SM.bind spu smr) (SM.render spu smr) + Right amr -> goRender' style aprog apu mat cam (AM.bind apu amr) (AM.render apu amr) type Bind = IO () @@ -157,21 +158,23 @@ type Bind = IO () type Render = IO () -goRender' :: ProgramUniforms u +goRender' :: (ProgramUniforms u, Program p) => GameStyle + -> p -> u -> M3.Matrix3 -> Cam.Camera -> Bind -> Render -> IO () -goRender' style uniforms model cam bindRenderer render = +goRender' style prog uniforms model cam bindRenderer render = let view = M4.inverseTransform $ Cam.transform cam modelview = case style of RPG -> view * rpgTransform 0 model PLT -> view * pltTransform model normalmat = fastNormalMatrix modelview in do + useProgram . program $ prog uniformMat4 (projLoc uniforms) $ Cam.projection cam uniformMat4 (modelviewLoc uniforms) modelview uniformMat3 (normalmatLoc uniforms) normalmat -- cgit v1.2.3