summaryrefslogtreecommitdiff
path: root/examples/pickIntDraw.lc
blob: fd1a58772b0563b0c536a50802f18932de2de885 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
type FB = FrameBuffer 1 '[ 'Color (Vec 4 Float)]

scene :: String -> FB -> FB
scene name prevFB =
  Accumulate    ((ColorOp NoBlending (one :: Vec 4 Bool)))
  (mapFragments (\(uv, rgba) -> ((rgba)))
   $ rasterizePrimitives (TriangleCtx CullFront PolygonFill NoOffset LastVertex) (Flat, Flat)
   $ mapPrimitives
    (\(pos, color, id)->
      ( (Uniform "viewProj" :: Mat 4 4 Float) *. (V4 pos%x pos%y 0 1)
      , V2 0.0 0.0
      , color))
    $ fetch name ( Attribute "position"   :: Vec 3 Float
                 , Attribute "color"      :: Vec 4 Float
                 , Attribute "id"         :: Int))
  prevFB

main :: Output
main = ScreenOut $
       scene "objects" $
       FrameBuffer ((colorImage1 (V4 0 0 0 0)))