summaryrefslogtreecommitdiff
path: root/testdata/editor-examples/RecursiveTexture.lc
diff options
context:
space:
mode:
authorCsaba Hruska <csaba.hruska@gmail.com>2016-02-05 17:51:27 +0100
committerCsaba Hruska <csaba.hruska@gmail.com>2016-02-05 17:51:27 +0100
commit749410713b5c1dce369c57d74fafd504ae068960 (patch)
treef70942ff63958b446b8963342fa0b413bffb903b /testdata/editor-examples/RecursiveTexture.lc
parentd392619689e78a1a379e8a7ba27b49cdba471b06 (diff)
add editor examples as tests
Diffstat (limited to 'testdata/editor-examples/RecursiveTexture.lc')
-rw-r--r--testdata/editor-examples/RecursiveTexture.lc24
1 files changed, 24 insertions, 0 deletions
diff --git a/testdata/editor-examples/RecursiveTexture.lc b/testdata/editor-examples/RecursiveTexture.lc
new file mode 100644
index 00000000..10938f56
--- /dev/null
+++ b/testdata/editor-examples/RecursiveTexture.lc
@@ -0,0 +1,24 @@
1clear = imageFrame (emptyDepthImage 1, emptyColorImage teal)
2
3triangleRasterCtx = TriangleCtx CullNone PolygonFill NoOffset LastVertex
4colorFragmentCtx = (DepthOp Less True, ColorOp NoBlending (V4 True True True True))
5
6cubeVertexStream = fetch "stream4" Triangle (Attribute "position4" :: Vec 4 Float, Attribute "vertexUV" :: Vec 2 Float)
7rotMatrix = Uniform "MVP" :: Mat 4 4 Float
8
9setAlpha v = v * V4 1.0 1 1 0 + V4 0 0 0 1
10
11cube' res (n :: Float) fb =
12 clear
13 `overlay`
14 cubeVertexStream
15 & mapPrimitives (\(v, u) -> (rotMatrix *. scale 0.4 (rotMatrixX (n/10) *. v), u))
16 & rasterizePrimitives triangleRasterCtx Smooth
17 & mapFragments (\a -> setAlpha $ (a%yyyx *! 0.5 + texture2D sampler a) *! 0.7)
18 & accumulateWith colorFragmentCtx
19 where
20 sampler = Sampler LinearFilter MirroredRepeat $ Texture2D (V2 res res) (PrjImageColor fb)
21
22main :: Output
23main = ScreenOut $ snd $ iterate (\(n, f) -> (n+1, cube' 256 n f)) (0, clear) !! 15
24