From 44ec6fa45b71d95650d05ea4e16550698ca7fb93 Mon Sep 17 00:00:00 2001 From: Joe Crayne Date: Thu, 2 May 2019 17:08:04 -0400 Subject: Use compiler-support for TextureCube. --- MeshSketch.hs | 7 +++---- 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 import LambdaCube.Gtk import LambdaCube.GL.Data (uploadCubeMapToGPU) import LambdaCube.GL.Type (TextureData(..)) -import Text.Show.Pretty (ppShow) +-- import Text.Show.Pretty (ppShow) import CubeMap import GLWidget (nullableContext, withCurrentGL) @@ -43,7 +43,6 @@ import LoadMesh import InfinitePlane import MtlParser (ObjMaterial(..)) import Matrix -import SavedPipeline -- State created by uploadState. data State = State @@ -200,8 +199,8 @@ new = do m <- do objName <- head . (++ ["cube.obj"]) <$> getArgs mobj <- loadOBJ objName - -- mpipeline <- loadPipeline "hello_obj2.json" $ do - mpipeline <- (\s -> return (Right (DynamicPipeline savedPipeline (makeSchema s)))) $ do + -- mpipeline <- (\s -> return (Right (DynamicPipeline savedPipeline (makeSchema s)))) $ do + mpipeline <- loadPipeline "hello_obj2.json" $ do defObjectArray "SkyCube" Triangles $ do "position" @: Attribute_V3F 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 point p = V4 p%x p%y p%z 1 -makeFrame (cubemap :: Texture) +makeFrame (cubemap :: TextureCube) (skybox :: PrimitiveStream Triangle ((Vec 3 Float))) (cameraPosition :: Vec 3 Float) (cam :: Mat 4 4 Float) @@ -27,7 +27,7 @@ makeFrame (cubemap :: Texture) p' = cam *. point (p + cameraPosition) in (p', texcoord)) & rasterizePrimitives (TriangleCtx CullNone PolygonFill NoOffset LastVertex) ((Smooth)) - & mapFragments (\((d)) -> ((texture2D (Sampler PointFilter MirroredRepeat cubemap) d%xy ))) + & mapFragments (\((d)) -> (( textureCube cubemap d ))) & accumulateWith (DepthOp Always False, ColorOp NoBlending (V4 True True True True)) `overlay` prims @@ -44,8 +44,9 @@ makeFrame (cubemap :: Texture) in ((r + V4 0 0 0 (0.8)))) & accumulateWith (DepthOp Less True, ColorOp blendplane (V4 True True True True)) -textureCubeSlot s = Texture2DSlot s +textureCubeSlot s = TextureCubeSlot s +main :: Output main = renderFrame $ makeFrame (textureCubeSlot "CubeMap") (fetch "SkyCube" ((Attribute "position"))) -- cgit v1.2.3