diff options
author | Csaba Hruska <csaba.hruska@gmail.com> | 2016-02-05 19:12:34 +0100 |
---|---|---|
committer | Csaba Hruska <csaba.hruska@gmail.com> | 2016-02-05 19:12:34 +0100 |
commit | 4216211642c4dcc7087942549363a77db2b7cce7 (patch) | |
tree | a44a0e6ccb7781e6c54dd7fbcbe167f925a83412 /testdata/editor-examples | |
parent | 605afb588d3c4d1fb6e9c0fbbcb820f59b88f04b (diff) |
add tetrahedron example
Diffstat (limited to 'testdata/editor-examples')
-rw-r--r-- | testdata/editor-examples/Tetrahedron.lc | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/testdata/editor-examples/Tetrahedron.lc b/testdata/editor-examples/Tetrahedron.lc new file mode 100644 index 00000000..3de44242 --- /dev/null +++ b/testdata/editor-examples/Tetrahedron.lc | |||
@@ -0,0 +1,31 @@ | |||
1 | tetrahedron = | ||
2 | [ V3 0 0 0, V3 1 0 0, V3 0 1 0 | ||
3 | , V3 1 0 0, V3 0 1 0, V3 0 0 1 | ||
4 | , V3 0 1 0, V3 0 0 1, V3 0 0 0 | ||
5 | , V3 0 0 1, V3 0 0 0, V3 0 0 1 | ||
6 | ] | ||
7 | |||
8 | f x = (x + sin x + sin (1.1 * x)) `mod` 4 * 2 | ||
9 | |||
10 | makeFrame (time :: Float) | ||
11 | (projmat :: Mat 4 4 Float) | ||
12 | (vertexstream :: PrimitiveStream Triangle (Vec 4 Float)) | ||
13 | |||
14 | = imageFrame (emptyDepthImage 1, emptyColorImage navy) | ||
15 | `overlay` accumulablefragments | ||
16 | where | ||
17 | accumulablefragments | ||
18 | = vertexstream | ||
19 | & mapPrimitives (\x -> (scale 0.5 (projmat *. x), x)) | ||
20 | & rasterizePrimitives (TriangleCtx CullNone PolygonFill NoOffset LastVertex) Smooth | ||
21 | & filterFragments (\x -> True) | ||
22 | & mapFragments (\x -> (rotMatrixZ time *. rotMatrixY time *. x) *! f time) | ||
23 | & accumulateWith (DepthOp Less True, ColorOp NoBlending (V4 True True True True)) | ||
24 | |||
25 | main = renderFrame $ | ||
26 | makeFrame (Uniform "Time") | ||
27 | (Uniform "MVP") | ||
28 | tetrahedronStream | ||
29 | |||
30 | tetrahedronStream = fetchArrays Triangle $ map (\v -> V4 v%x v%y v%z 1) tetrahedron | ||
31 | |||