summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2019-05-02 17:08:04 -0400
committerJoe Crayne <joe@jerkface.net>2019-05-02 17:08:04 -0400
commit44ec6fa45b71d95650d05ea4e16550698ca7fb93 (patch)
treec40247b1cccea5a3c63473d47de50d5f56908d6c
parent5abe70c7457ebedc5e4e348e3dc5a7b830fab897 (diff)
Use compiler-support for TextureCube.
-rw-r--r--MeshSketch.hs7
-rw-r--r--hello_obj2.lc7
2 files changed, 7 insertions, 7 deletions
diff --git a/MeshSketch.hs b/MeshSketch.hs
index 5bf6fea..02ba53a 100644
--- a/MeshSketch.hs
+++ b/MeshSketch.hs
@@ -32,7 +32,7 @@ import LambdaCube.IR as LC
32import LambdaCube.Gtk 32import LambdaCube.Gtk
33import LambdaCube.GL.Data (uploadCubeMapToGPU) 33import LambdaCube.GL.Data (uploadCubeMapToGPU)
34import LambdaCube.GL.Type (TextureData(..)) 34import LambdaCube.GL.Type (TextureData(..))
35import Text.Show.Pretty (ppShow) 35-- import Text.Show.Pretty (ppShow)
36 36
37import CubeMap 37import CubeMap
38import GLWidget (nullableContext, withCurrentGL) 38import GLWidget (nullableContext, withCurrentGL)
@@ -43,7 +43,6 @@ import LoadMesh
43import InfinitePlane 43import InfinitePlane
44import MtlParser (ObjMaterial(..)) 44import MtlParser (ObjMaterial(..))
45import Matrix 45import Matrix
46import SavedPipeline
47 46
48-- State created by uploadState. 47-- State created by uploadState.
49data State = State 48data State = State
@@ -200,8 +199,8 @@ new = do
200 m <- do 199 m <- do
201 objName <- head . (++ ["cube.obj"]) <$> getArgs 200 objName <- head . (++ ["cube.obj"]) <$> getArgs
202 mobj <- loadOBJ objName 201 mobj <- loadOBJ objName
203 -- mpipeline <- loadPipeline "hello_obj2.json" $ do 202 -- mpipeline <- (\s -> return (Right (DynamicPipeline savedPipeline (makeSchema s)))) $ do
204 mpipeline <- (\s -> return (Right (DynamicPipeline savedPipeline (makeSchema s)))) $ do 203 mpipeline <- loadPipeline "hello_obj2.json" $ do
205 defObjectArray "SkyCube" Triangles $ do 204 defObjectArray "SkyCube" Triangles $ do
206 "position" @: Attribute_V3F 205 "position" @: Attribute_V3F
207 defObjectArray "objects" Triangles $ do 206 defObjectArray "objects" Triangles $ do
diff --git a/hello_obj2.lc b/hello_obj2.lc
index db28333..991c3c2 100644
--- a/hello_obj2.lc
+++ b/hello_obj2.lc
@@ -11,7 +11,7 @@ point :: Vec 3 Float -> Vec 4 Float
11point p = V4 p%x p%y p%z 1 11point p = V4 p%x p%y p%z 1
12 12
13 13
14makeFrame (cubemap :: Texture) 14makeFrame (cubemap :: TextureCube)
15 (skybox :: PrimitiveStream Triangle ((Vec 3 Float))) 15 (skybox :: PrimitiveStream Triangle ((Vec 3 Float)))
16 (cameraPosition :: Vec 3 Float) 16 (cameraPosition :: Vec 3 Float)
17 (cam :: Mat 4 4 Float) 17 (cam :: Mat 4 4 Float)
@@ -27,7 +27,7 @@ makeFrame (cubemap :: Texture)
27 p' = cam *. point (p + cameraPosition) 27 p' = cam *. point (p + cameraPosition)
28 in (p', texcoord)) 28 in (p', texcoord))
29 & rasterizePrimitives (TriangleCtx CullNone PolygonFill NoOffset LastVertex) ((Smooth)) 29 & rasterizePrimitives (TriangleCtx CullNone PolygonFill NoOffset LastVertex) ((Smooth))
30 & mapFragments (\((d)) -> ((texture2D (Sampler PointFilter MirroredRepeat cubemap) d%xy ))) 30 & mapFragments (\((d)) -> (( textureCube cubemap d )))
31 & accumulateWith (DepthOp Always False, ColorOp NoBlending (V4 True True True True)) 31 & accumulateWith (DepthOp Always False, ColorOp NoBlending (V4 True True True True))
32 `overlay` 32 `overlay`
33 prims 33 prims
@@ -44,8 +44,9 @@ makeFrame (cubemap :: Texture)
44 in ((r + V4 0 0 0 (0.8)))) 44 in ((r + V4 0 0 0 (0.8))))
45 & accumulateWith (DepthOp Less True, ColorOp blendplane (V4 True True True True)) 45 & accumulateWith (DepthOp Less True, ColorOp blendplane (V4 True True True True))
46 46
47textureCubeSlot s = Texture2DSlot s 47textureCubeSlot s = TextureCubeSlot s
48 48
49main :: Output
49main = renderFrame $ 50main = renderFrame $
50 makeFrame (textureCubeSlot "CubeMap") 51 makeFrame (textureCubeSlot "CubeMap")
51 (fetch "SkyCube" ((Attribute "position"))) 52 (fetch "SkyCube" ((Attribute "position")))