summaryrefslogtreecommitdiff
path: root/examples/hello_obj.lc
blob: 3edb6ebfeec5dea55f094cc60d75cbe7e812f230 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
makeFrame (time :: Float)
          (color :: Vec 4 Float)
          (texture :: Texture)
          (prims :: PrimitiveStream Triangle (Vec 4 Float, Vec 3 Float, Vec 3 Float))

    = imageFrame (emptyDepthImage 1, emptyColorImage (V4 0 0 0.4 1))
  `overlay`
      prims
    & mapPrimitives (\(p,n,uvw) -> (perspective 0.1 100 45 1 *. lookat (V3 0 0 5) (V3 0 0 0) (V3 0 1 0) *. rotMatrixX time *. rotMatrixZ time *. p, V2 uvw%x (1 - uvw%y) ))
    & rasterizePrimitives (TriangleCtx CullBack PolygonFill NoOffset LastVertex) ((Smooth))
    & mapFragments (\((uv)) -> ((color * texture2D (Sampler PointFilter MirroredRepeat texture) uv )))
    & accumulateWith (DepthOp Less True, ColorOp NoBlending (V4 True True True True))

main = renderFrame $
   makeFrame (Uniform "time")
             (Uniform "diffuseColor")
             (Texture2DSlot "diffuseTexture")
             (fetch "objects" (Attribute "position", Attribute "normal", Attribute "uvw"))