diff options
author | Csaba Hruska <csaba.hruska@gmail.com> | 2016-02-05 17:51:27 +0100 |
---|---|---|
committer | Csaba Hruska <csaba.hruska@gmail.com> | 2016-02-05 17:51:27 +0100 |
commit | 749410713b5c1dce369c57d74fafd504ae068960 (patch) | |
tree | f70942ff63958b446b8963342fa0b413bffb903b /testdata/editor-examples/RecursiveTexture.lc | |
parent | d392619689e78a1a379e8a7ba27b49cdba471b06 (diff) |
add editor examples as tests
Diffstat (limited to 'testdata/editor-examples/RecursiveTexture.lc')
-rw-r--r-- | testdata/editor-examples/RecursiveTexture.lc | 24 |
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 @@ | |||
1 | clear = imageFrame (emptyDepthImage 1, emptyColorImage teal) | ||
2 | |||
3 | triangleRasterCtx = TriangleCtx CullNone PolygonFill NoOffset LastVertex | ||
4 | colorFragmentCtx = (DepthOp Less True, ColorOp NoBlending (V4 True True True True)) | ||
5 | |||
6 | cubeVertexStream = fetch "stream4" Triangle (Attribute "position4" :: Vec 4 Float, Attribute "vertexUV" :: Vec 2 Float) | ||
7 | rotMatrix = Uniform "MVP" :: Mat 4 4 Float | ||
8 | |||
9 | setAlpha v = v * V4 1.0 1 1 0 + V4 0 0 0 1 | ||
10 | |||
11 | cube' 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 | |||
22 | main :: Output | ||
23 | main = ScreenOut $ snd $ iterate (\(n, f) -> (n+1, cube' 256 n f)) (0, clear) !! 15 | ||
24 | |||