summaryrefslogtreecommitdiff
path: root/testdata/later.ignore/DemoUtils.lc
diff options
context:
space:
mode:
Diffstat (limited to 'testdata/later.ignore/DemoUtils.lc')
-rw-r--r--testdata/later.ignore/DemoUtils.lc48
1 files changed, 48 insertions, 0 deletions
diff --git a/testdata/later.ignore/DemoUtils.lc b/testdata/later.ignore/DemoUtils.lc
new file mode 100644
index 00000000..bcde1467
--- /dev/null
+++ b/testdata/later.ignore/DemoUtils.lc
@@ -0,0 +1,48 @@
1module DemoUtils
2 ( module DemoUtils
3 , module Prelude
4 ) where
5
6time = Uniform "Time" :: Float
7
8--v3v4 = PrimV3FToV4F
9
10-- example combinators
11image color = FrameBuffer (DepthImage @1 1000.0, ColorImage @1 color)
12
13triangleRasterCtx = TriangleCtx CullNone PolygonFill NoOffset LastVertex
14colorFragmentCtx = accumulationContext (DepthOp Less True, ColorOp NoBlending (V4 True True True True))
15
16rasterizeWith = Rasterize
17triangles = triangleRasterCtx
18
19cubeVertexStream = fetch "stream4" Triangle (Attribute "position4" :: Vec 4 Float)
20mapFragments s fs bg = accumulate colorFragmentCtx PassAll (FragmentShaderRastDepth $ \a -> fs a) s bg
21transform s f = Transform (\v -> VertexOut (f v) 1.0 () (Smooth v)) s
22
23cube v f bg = (cubeVertexStream -- cube vertices
24 `transform` v -- scale them
25 & rasterizeWith triangles -- rasterize
26 `mapFragments` f) bg
27
28
29
30withCoords f a = f (a%x) (a%y)
31
32fragmentTest f = quadVertexStream
33 `transformQ` id
34 & rasterizeWith triangles
35 `mapFragmentsQ` withCoords f
36 where
37 clearQ = FrameBuffer $ ColorImage @1 $ V4 1 0 0 0.5
38
39 colorFragmentCtxQ = accumulationContext (ColorOp NoBlending (V4 True True True True))
40 mapFragmentsQ s fs = accumulate colorFragmentCtxQ PassAll (FragmentShader $ \a -> fs a) s clearQ
41
42 quadVertexStream = fetch "quad" Triangle (Attribute "position" :: Vec 2 Float)
43
44 tr :: Vec 2 Float -> Vec 4 Float
45 tr a = V4 a%x a%y 1 1
46
47 transformQ s f = Transform (\v -> VertexOut (tr $ f v ) 1 () (Smooth v)) s
48