summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MeshSketch.hs13
-rw-r--r--hello_obj2.lc9
2 files changed, 15 insertions, 7 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 ()
diff --git a/hello_obj2.lc b/hello_obj2.lc
index d0fc35b..52d4a52 100644
--- a/hello_obj2.lc
+++ b/hello_obj2.lc
@@ -7,7 +7,9 @@ blendplane = -- NoBlending -- BlendLogicOp Xor
7 ((OneBF,SrcAlpha),(DstAlpha,DstAlpha)) 7 ((OneBF,SrcAlpha),(DstAlpha,DstAlpha))
8 (V4 0 0 0 0) 8 (V4 0 0 0 0)
9 9
10makeFrame (cameraPosition :: Vec 3 Float) 10makeFrame (cubemap :: Texture)
11 (skybox :: PrimitiveStream Triangle ((Vec 3 Float)))
12 (cameraPosition :: Vec 3 Float)
11 (cam :: Mat 4 4 Float) 13 (cam :: Mat 4 4 Float)
12 (color :: Vec 4 Float) 14 (color :: Vec 4 Float)
13 (texture :: Texture) 15 (texture :: Texture)
@@ -30,9 +32,12 @@ makeFrame (cameraPosition :: Vec 3 Float)
30 in ((r + V4 0 0 0 (0.8)))) 32 in ((r + V4 0 0 0 (0.8))))
31 & accumulateWith (DepthOp Less True, ColorOp blendplane (V4 True True True True)) 33 & accumulateWith (DepthOp Less True, ColorOp blendplane (V4 True True True True))
32 34
35textureCubeSlot s = Texture2DSlot s
33 36
34main = renderFrame $ 37main = renderFrame $
35 makeFrame (Uniform "CameraPosition") 38 makeFrame (textureCubeSlot "CubeMap")
39 (fetch "SkyCube" ((Attribute "position")))
40 (Uniform "CameraPosition")
36 (Uniform "ViewProjection") 41 (Uniform "ViewProjection")
37 (Uniform "diffuseColor") 42 (Uniform "diffuseColor")
38 (Texture2DSlot "diffuseTexture") 43 (Texture2DSlot "diffuseTexture")