summaryrefslogtreecommitdiff
path: root/hello_obj.lc
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2019-04-09 17:29:40 -0400
committerJoe Crayne <joe@jerkface.net>2019-04-09 17:32:41 -0400
commit21ea6a154e3765b16f6ba6b48773d83e18933881 (patch)
tree298261b8f61235268e21ccf7e0cf3b3f261251d4 /hello_obj.lc
parent776f107087941b071bb2227fabdbb45f6c625d32 (diff)
Added HelloOBJ example.
Diffstat (limited to 'hello_obj.lc')
-rw-r--r--hello_obj.lc24
1 files changed, 24 insertions, 0 deletions
diff --git a/hello_obj.lc b/hello_obj.lc
new file mode 100644
index 0000000..baf0edd
--- /dev/null
+++ b/hello_obj.lc
@@ -0,0 +1,24 @@
1makeFrame (time :: Float)
2 (color :: Vec 4 Float)
3 (texture :: Texture)
4 (prims :: PrimitiveStream Triangle (Vec 4 Float, Vec 3 Float, Vec 3 Float))
5
6 = imageFrame (emptyDepthImage 1, emptyColorImage (V4 0 0 0.4 1))
7 `overlay`
8 prims
9 & mapPrimitives (\(p,n,uvw) ->
10 ( perspective 0.1 100 45 1
11 *. lookat (V3 0 0 5) (V3 0 0 0) (V3 0 1 0)
12 *. rotMatrixX time
13 *. rotMatrixZ time
14 *. p
15 , V2 uvw%x (1 - uvw%y) ))
16 & rasterizePrimitives (TriangleCtx CullBack PolygonFill NoOffset LastVertex) ((Smooth))
17 & mapFragments (\((uv)) -> ((color * texture2D (Sampler PointFilter MirroredRepeat texture) uv )))
18 & accumulateWith (DepthOp Less True, ColorOp NoBlending (V4 True True True True))
19
20main = renderFrame $
21 makeFrame (Uniform "time")
22 (Uniform "diffuseColor")
23 (Texture2DSlot "diffuseTexture")
24 (fetch "objects" (Attribute "position", Attribute "normal", Attribute "uvw"))