summaryrefslogtreecommitdiff
path: root/testdata/fetcharrays01.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/fetcharrays01.lc
parentd5f3ef4a65218b966f7463511896fd901a4d1d77 (diff)
normalise paths and fix self export handling
Diffstat (limited to 'testdata/fetcharrays01.lc')
-rw-r--r--testdata/fetcharrays01.lc52
1 files changed, 52 insertions, 0 deletions
diff --git a/testdata/fetcharrays01.lc b/testdata/fetcharrays01.lc
new file mode 100644
index 00000000..57bbe40e
--- /dev/null
+++ b/testdata/fetcharrays01.lc
@@ -0,0 +1,52 @@
1cubeNormals :: [Vec 3 Float]
2cubeNormals =
3 [ V3 0.0 1.0 0.0, V3 0.0 1.0 0.0, V3 0.0 1.0 0.0
4 , V3 0.0 1.0 0.0, V3 0.0 1.0 0.0, V3 0.0 1.0 0.0
5 , V3 0.0 (-1.0) 0.0, V3 0.0 (-1.0) 0.0, V3 0.0 (-1.0) 0.0
6 , V3 0.0 (-1.0) 0.0, V3 0.0 (-1.0) 0.0, V3 0.0 (-1.0) 0.0
7 , V3 0.0 (-0.0) 1.0, V3 0.0 (-0.0) 1.0, V3 0.0 (-0.0) 1.0
8 , V3 (-0.0) 0.0 1.0, V3 (-0.0) 0.0 1.0, V3 (-0.0) 0.0 1.0
9 , V3 (-0.0) (-0.0) (-1.0), V3 (-0.0) (-0.0) (-1.0), V3 (-0.0) (-0.0) (-1.0)
10 , V3 0.0 0.0 (-1.0), V3 0.0 0.0 (-1.0), V3 0.0 0.0 (-1.0)
11 , V3 (-1.0) 0.0 0.0, V3 (-1.0) 0.0 0.0, V3 (-1.0) 0.0 0.0
12 , V3 (-1.0) 0.0 0.0, V3 (-1.0) 0.0 0.0, V3 (-1.0) 0.0 0.0
13 , V3 1.0 0.0 0.0, V3 1.0 0.0 0.0, V3 1.0 0.0 0.0
14 , V3 1.0 0.0 0.0, V3 1.0 0.0 0.0, V3 1.0 0.0 0.0
15 ]
16
17cubeVertices :: [Vec 3 Float]
18cubeVertices =
19 [ V3 1.0 1.0 1.0, V3 (-1.0) 1.0 1.0, V3 (-1.0) 1.0 (-1.0)
20 , V3 (-1.0) 1.0 (-1.0), V3 1.0 1.0 (-1.0), V3 1.0 1.0 1.0
21 , V3 1.0 (-1.0) (-1.0), V3 (-1.0) (-1.0) (-1.0), V3 (-1.0) (-1.0) 1.0
22 , V3 (-1.0) (-1.0) 1.0, V3 1.0 (-1.0) 1.0, V3 1.0 (-1.0) (-1.0)
23 , V3 1.0 (-1.0) 1.0, V3 (-1.0) (-1.0) 1.0, V3 (-1.0) 1.0 1.0
24 , V3 (-1.0) 1.0 1.0, V3 1.0 1.0 1.0, V3 1.0 (-1.0) 1.0
25 , V3 1.0 1.0 (-1.0), V3 (-1.0) 1.0 (-1.0), V3 (-1.0) (-1.0) (-1.0)
26 , V3 (-1.0) (-1.0) (-1.0), V3 1.0 (-1.0) (-1.0), V3 1.0 1.0 (-1.0)
27 , V3 (-1.0) (-1.0) 1.0, V3 (-1.0) (-1.0) (-1.0), V3 (-1.0) 1.0 (-1.0)
28 , V3 (-1.0) 1.0 (-1.0), V3 (-1.0) 1.0 1.0, V3 (-1.0) (-1.0) 1.0
29 , V3 1.0 (-1.0) (-1.0), V3 1.0 (-1.0) 1.0, V3 1.0 1.0 1.0
30 , V3 1.0 1.0 1.0, V3 1.0 1.0 (-1.0), V3 1.0 (-1.0) (-1.0)
31 ]
32
33cubeVertexStream = fetchArrays Triangle (cubeVertices,cubeNormals)
34
35clear = FrameBuffer $ (DepthImage @1 1000, ColorImage @1 red) -- ...
36
37triangleRasterCtx = TriangleCtx CullNone PolygonFill NoOffset LastVertex
38colorFragmentCtx = accumulationContext (DepthOp Less True, ColorOp NoBlending (V4 True True True True))
39
40rasterizeWith = rasterizePrimitives
41triangles = triangleRasterCtx
42
43mapFragments2 s fs = accumulate colorFragmentCtx ( \a -> fs a) s clear
44transform s f = mapPrimitives (\(p,n) -> let v = v3FToV4F p in (f v, v)) s
45
46rotate' v = (Uniform "MVP" :: Mat 4 4 Float) `PrimMulMatVec` v
47
48main = cubeVertexStream -- cube vertices
49 `transform` (scale 0.5 . rotate') -- scale them
50 & rasterizeWith triangles Smooth -- rasterize
51 `mapFragments2` id
52 & ScreenOut -- draw into screen