summaryrefslogtreecommitdiff
path: root/testdata/line01.lc
blob: afa8591fb746d67c92e965f039ff3f2d45aa8649 (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 Line (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