summaryrefslogtreecommitdiff
path: root/testdata/line01.lc
blob: 0dc014744cf883eab1f77b650c46f2cc7534c668 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
lineVertices :: [Vec 3 Float]
lineVertices = concat [[V3 i 0 0,V3 (i+!1.0) 0 0] | i <- [(-2)..2]]

clear = FrameBuffer (DepthImage @1 1000, ColorImage @1 navy)   -- ...

lines = LineCtx 1.0 LastVertex
colorFragmentCtx = (DepthOp Less True, ColorOp NoBlending (V4 True True True True))

cubeVertexStream = fetchArrays ((lineVertices))

rasterizeWith = rasterizePrimitives

mapFragments2 s fs = accumulate colorFragmentCtx (\((a)) -> ((fs a))) s clear
transform s f =  mapPrimitives (\((p)) -> let v = v3FToV4F p in (f v, v)) s

rotate' v = (Uniform "MVP" :: Mat 4 4 Float) *. v

main =             cubeVertexStream         -- cube vertices
    `transform`    (scale 0.5 . rotate')    -- scale them
     &             rasterizeWith lines ((Smooth))  -- rasterize
    `mapFragments2` id
     &             ScreenOut                --  draw into screen