summaryrefslogtreecommitdiff
path: root/testdata/Hyperboloid.lc
blob: e6ae104a7d5cff9ac0372f8afbd471c33421c315 (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
25
26
27
28
29
lineVertexStream = fetchArrays Line $ concat $
              [[V3 i (-3.0) 0.0, V3 i 3.0 0.0]  | i <- [(-5.0)..5.0] ]

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

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

m = Uniform "Mouse" :: Vec 2 Float

rasterizeWith = rasterizePrimitives

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

trans :: Vec 4 Float -> Vec 4 Float
trans (V4 x y _ _) = V4 (k * sin (s * x + r * y)) y (k * cos (s * x + r * y)) 1.0
    where 
          k = 2 * m%y
          s = 0.7
          r = m%x

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

main =             lineVertexStream
    `transform`    ((scale 0.1 . rotate') . trans)
     &             rasterizeWith lines Smooth
    `mapFragments22` id
     &             ScreenOut