blob: 3c387d5141cd86a33b96ec888aae5e91fd55dd51 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
clear = FrameBuffer ((ColorImage @1 red)) -- ...
triangleRasterCtx = TriangleCtx CullNone PolygonFill NoOffset LastVertex
colorFragmentCtx = accumulationContext ((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 (\() -> ((fs))) s clear
transform s f = mapPrimitives (\((v)) -> ((f v))) s
rotate :: Float -> Vec 4 Float -> Vec 4 Float
rotate a v = M44F (V4 c (-s) 0 0) (V4 s c 0 0) (V4 0 0 1 0) (V4 0 0 0 1) `PrimMulMatVec` v
where
c = PrimCos a
s = PrimSin a
main = cubeVertexStream -- cube vertices
`transform` (scale 0.1 . rotate 3) -- scale them
& rasterizeWith triangles () -- rasterize
`mapFragments2` blue -- set every pixel blue
& ScreenOut -- draw into screen
|