summaryrefslogtreecommitdiff
path: root/MeshSketch.hs
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2019-04-29 23:11:39 -0400
committerJoe Crayne <joe@jerkface.net>2019-04-29 23:11:39 -0400
commitc9c0db44f79c5ad13c0937d8e36fa828447f9585 (patch)
treecaf5695cab2c9030f13f0b2a039f015508908124 /MeshSketch.hs
parentc9d1da96a78c78f18ba0d995d6a0376a00452b80 (diff)
Skybox-related uniforms.
Diffstat (limited to 'MeshSketch.hs')
-rw-r--r--MeshSketch.hs13
1 files changed, 8 insertions, 5 deletions
diff --git a/MeshSketch.hs b/MeshSketch.hs
index 288488b..7f01d4d 100644
--- a/MeshSketch.hs
+++ b/MeshSketch.hs
@@ -131,11 +131,11 @@ uploadState obj glarea storage = do
131 skybox <- newIORef 0 131 skybox <- newIORef 0
132 Right ts <- skyboxLoad skyboxes 0 132 Right ts <- skyboxLoad skyboxes 0
133 skybox_id <- uploadCubeMapToGPU ts 133 skybox_id <- uploadCubeMapToGPU ts
134 -- LC.updateUniforms storage $ do 134 LC.updateUniforms storage $ do
135 -- "CubeMap" @= return skybox_id 135 "CubeMap" @= return skybox_id
136 skytex <- newIORef skybox_id 136 skytex <- newIORef skybox_id
137 mi <- LC.uploadMeshToGPU cubeMesh 137 mi <- LC.uploadMeshToGPU cubeMesh
138 -- LC.addMeshToObjectArray storage "SkyCube" [] mi -- TODO 138 LC.addMeshToObjectArray storage "SkyCube" [] mi
139 139
140 let st = State 140 let st = State
141 { stAnimator = tm 141 { stAnimator = tm
@@ -194,6 +194,8 @@ new = do
194 objName <- head . (++ ["cube.obj"]) <$> getArgs 194 objName <- head . (++ ["cube.obj"]) <$> getArgs
195 mobj <- loadOBJ objName 195 mobj <- loadOBJ objName
196 mpipeline <- loadPipeline "hello_obj2.json" $ do 196 mpipeline <- loadPipeline "hello_obj2.json" $ do
197 defObjectArray "SkyCube" Triangles $ do
198 "position" @: Attribute_V3F
197 defObjectArray "objects" Triangles $ do 199 defObjectArray "objects" Triangles $ do
198 "position" @: Attribute_V4F 200 "position" @: Attribute_V4F
199 "normal" @: Attribute_V3F 201 "normal" @: Attribute_V3F
@@ -201,6 +203,7 @@ new = do
201 defObjectArray "plane" Triangles $ do 203 defObjectArray "plane" Triangles $ do
202 "position" @: Attribute_V4F 204 "position" @: Attribute_V4F
203 defUniforms $ do 205 defUniforms $ do
206 "CubeMap" @: FTextureCube
204 "CameraPosition" @: V3F 207 "CameraPosition" @: V3F
205 "ViewProjection" @: M44F 208 "ViewProjection" @: M44F
206 "diffuseTexture" @: FTexture2D 209 "diffuseTexture" @: FTexture2D
@@ -314,8 +317,8 @@ onEvent w realized ev = do
314 Right ts <- skyboxLoad (stSkyboxes st) idx 317 Right ts <- skyboxLoad (stSkyboxes st) idx
315 disposeTexture =<< readIORef (stSkyTexture st) 318 disposeTexture =<< readIORef (stSkyTexture st)
316 skybox_id <- uploadCubeMapToGPU ts 319 skybox_id <- uploadCubeMapToGPU ts
317 -- LC.updateUniforms storage $ do 320 LC.updateUniforms (stStorage realized) $ do
318 -- "CubeMap" @= return skybox_id 321 "CubeMap" @= return skybox_id
319 writeIORef (stSkyTexture st) skybox_id 322 writeIORef (stSkyTexture st) skybox_id
320 put (skyboxNames (stSkyboxes st) !! idx) 323 put (skyboxNames (stSkyboxes st) !! idx)
321 return () 324 return ()