diff options
author | Joe Crayne <joe@jerkface.net> | 2019-05-02 17:08:04 -0400 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2019-05-02 17:08:04 -0400 |
commit | 44ec6fa45b71d95650d05ea4e16550698ca7fb93 (patch) | |
tree | c40247b1cccea5a3c63473d47de50d5f56908d6c | |
parent | 5abe70c7457ebedc5e4e348e3dc5a7b830fab897 (diff) |
Use compiler-support for TextureCube.
-rw-r--r-- | MeshSketch.hs | 7 | ||||
-rw-r--r-- | hello_obj2.lc | 7 |
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 | |||
32 | import LambdaCube.Gtk | 32 | import LambdaCube.Gtk |
33 | import LambdaCube.GL.Data (uploadCubeMapToGPU) | 33 | import LambdaCube.GL.Data (uploadCubeMapToGPU) |
34 | import LambdaCube.GL.Type (TextureData(..)) | 34 | import LambdaCube.GL.Type (TextureData(..)) |
35 | import Text.Show.Pretty (ppShow) | 35 | -- import Text.Show.Pretty (ppShow) |
36 | 36 | ||
37 | import CubeMap | 37 | import CubeMap |
38 | import GLWidget (nullableContext, withCurrentGL) | 38 | import GLWidget (nullableContext, withCurrentGL) |
@@ -43,7 +43,6 @@ import LoadMesh | |||
43 | import InfinitePlane | 43 | import InfinitePlane |
44 | import MtlParser (ObjMaterial(..)) | 44 | import MtlParser (ObjMaterial(..)) |
45 | import Matrix | 45 | import Matrix |
46 | import SavedPipeline | ||
47 | 46 | ||
48 | -- State created by uploadState. | 47 | -- State created by uploadState. |
49 | data State = State | 48 | data 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 | |||
11 | point p = V4 p%x p%y p%z 1 | 11 | point p = V4 p%x p%y p%z 1 |
12 | 12 | ||
13 | 13 | ||
14 | makeFrame (cubemap :: Texture) | 14 | makeFrame (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 | ||
47 | textureCubeSlot s = Texture2DSlot s | 47 | textureCubeSlot s = TextureCubeSlot s |
48 | 48 | ||
49 | main :: Output | ||
49 | main = renderFrame $ | 50 | main = renderFrame $ |
50 | makeFrame (textureCubeSlot "CubeMap") | 51 | makeFrame (textureCubeSlot "CubeMap") |
51 | (fetch "SkyCube" ((Attribute "position"))) | 52 | (fetch "SkyCube" ((Attribute "position"))) |