blob: f34eebdd75ee889a1626f2f2fcb51747884d1087 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
dark = V4 0.1 0.0 0.2 1
clear = FrameBuffer $ (DepthImage @1 1000, ColorImage @1 dark) -- ...
triangleRasterCtx = TriangleCtx CullNone PolygonFill NoOffset LastVertex
colorFragmentCtx = (DepthOp Less True, ColorOp NoBlending (V4 True True True True))
rasterizeWith = rasterizePrimitives
triangles = triangleRasterCtx
cubeVertexStream = fetch "stream4" Triangle (Attribute "position4" :: Vec 4 Float)
mapFragments2 s fs = accumulate colorFragmentCtx (\a -> fs a) s clear
transform s f = mapPrimitives (\v -> (f v, v)) s
rotate' v = (Uniform "MVP" :: Mat 4 4 Float) `PrimMulMatVec` v
main = cubeVertexStream -- cube vertices
`transform` (scale 0.5 . rotate') -- scale them
& rasterizeWith triangles Smooth -- rasterize
`mapFragments2` (\a -> if a%r < 0.5 then blue else red)
& ScreenOut -- draw into screen
|