summaryrefslogtreecommitdiff
path: root/testdata/example08.lc
diff options
context:
space:
mode:
authorCsaba Hruska <csaba.hruska@gmail.com>2016-01-19 15:59:35 +0100
committerCsaba Hruska <csaba.hruska@gmail.com>2016-01-19 16:10:49 +0100
commitcb69693769ebfcdac605c90f38a20c788b08eaf3 (patch)
tree3689094c7ff13f45cc928a7dfaafff2652ed4c03 /testdata/example08.lc
parentd5f3ef4a65218b966f7463511896fd901a4d1d77 (diff)
normalise paths and fix self export handling
Diffstat (limited to 'testdata/example08.lc')
-rw-r--r--testdata/example08.lc40
1 files changed, 40 insertions, 0 deletions
diff --git a/testdata/example08.lc b/testdata/example08.lc
new file mode 100644
index 00000000..b6ebbd0e
--- /dev/null
+++ b/testdata/example08.lc
@@ -0,0 +1,40 @@
1time = Uniform "Time" :: Float
2
3image color = FrameBuffer (DepthImage @1 1000.0, ColorImage @1 (color :: Vec 4 Float))
4
5triangleRasterCtx = TriangleCtx CullNone PolygonFill NoOffset LastVertex
6colorFragmentCtx = (DepthOp Less True, ColorOp NoBlending (V4 True True True True))
7
8rasterizeWith = rasterizePrimitives
9triangles = triangleRasterCtx
10
11cubeVertexStream = fetch "stream4" Triangle (Attribute "position4" :: Vec 4 Float)
12mapFragments2 s fs bg = accumulate colorFragmentCtx (\a -> fs a) s bg
13
14cube fv f bg = (cubeVertexStream -- cube vertices
15 & mapPrimitives (\v -> (fv v, v))
16 & rasterizeWith triangles Smooth -- rasterize
17 `mapFragments2` f) bg
18
19trMat a b = a *. b
20rotate' v = (Uniform "MVP" :: Mat 4 4 Float) *. v
21trX a b = V4 (a :: Float) 0 0.0 0 + b
22
23main = ScreenOut $
24 foldl' (\fb a -> cube (
25 trMat (rotMatrixZ $ time *! a) .
26 rotate' .
27 (trX (0.5 *! a +! sin time *! 0.1)) .
28 (scale 0.04) .
29 trMat (rotMatrixX (time *! 2.0 *! a))
30 ) id fb)
31 (image navy)
32 [ a | x <- [ (-0.5,True)
33 , (0.0,True)
34 , (0.5,True)
35 , (0.3,True)
36 , (0.75,True)
37 ] `append` [(a,True) | a <- [(-1.0)..2.0]]
38 , let (a,b) = x
39 , b
40 ]