diff options
author | Csaba Hruska <csaba.hruska@gmail.com> | 2016-01-16 19:19:53 +0100 |
---|---|---|
committer | Csaba Hruska <csaba.hruska@gmail.com> | 2016-01-16 19:19:53 +0100 |
commit | 69e227e723f46920b75274d14cfd09da9abad288 (patch) | |
tree | 1cead01a021874499d0664bd7a3a814299a28218 /examples/hello.lc | |
parent | e3780f65e84234ce8b8aa3569a0963a1637681af (diff) |
update sample
Diffstat (limited to 'examples/hello.lc')
-rw-r--r-- | examples/hello.lc | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/examples/hello.lc b/examples/hello.lc index 20f8292..55e7c73 100644 --- a/examples/hello.lc +++ b/examples/hello.lc | |||
@@ -1,13 +1,16 @@ | |||
1 | time = Uniform "time" :: Float | 1 | makeFrame (time :: Float) |
2 | sampler = Sampler PointFilter MirroredRepeat (Texture2DSlot "diffuseTexture") | 2 | (texture :: Texture) |
3 | main = let | 3 | (prims :: Stream (Primitive Triangle (Vec 2 Float, Vec 2 Float))) |
4 | emptyFB = FrameBuffer (colorImage1 (V4 0.0 0.0 0.4 1.0)) | 4 | |
5 | rasterCtx = TriangleCtx CullNone PolygonFill NoOffset LastVertex | 5 | = imageFrame (emptyColorImage (V4 0 0 0.4 1)) |
6 | fragmentCtx = (ColorOp NoBlending (V4 True True True True)) | 6 | `overlay` |
7 | vertexShader (p,uv) = VertexOut (rotMatrixZ time *. (V4 p%x p%y (-1) 1)) 1.0 () (Smooth uv) | 7 | prims |
8 | vertexStream = Fetch @Triangle "objects" (Attribute "position" :: Vec 2 Float, Attribute "uv" :: Vec 2 Float) | 8 | & mapPrimitives (\(p,uv) -> (rotMatrixZ time *. (V4 p%x p%y (-1) 1), uv)) |
9 | primitiveStream = Transform vertexShader vertexStream | 9 | & rasterizePrimitives (TriangleCtx CullNone PolygonFill NoOffset LastVertex) Smooth |
10 | fragmentStream = Rasterize rasterCtx primitiveStream | 10 | & mapFragments (\uv -> texture2D (Sampler PointFilter MirroredRepeat texture) uv) |
11 | fragmentShader = FragmentShader $ \uv -> texture2D sampler uv | 11 | & accumulateWith (ColorOp NoBlending (V4 True True True True)) |
12 | frame = accumulate fragmentCtx PassAll fragmentShader fragmentStream emptyFB | 12 | |
13 | in ScreenOut frame | 13 | main = renderFrame $ |
14 | makeFrame (Uniform "time") | ||
15 | (Texture2DSlot "diffuseTexture") | ||
16 | (fetch_ "objects" (Attribute "position", Attribute "uv")) | ||