diff options
author | Csaba Hruska <csaba.hruska@gmail.com> | 2016-07-10 15:06:54 +0200 |
---|---|---|
committer | Csaba Hruska <csaba.hruska@gmail.com> | 2016-07-10 15:06:54 +0200 |
commit | 9a1a4f3fd29d9f329fa62e9e00d5b6804545bdc3 (patch) | |
tree | 868c8238afda8acec2a594d834c7b75c084adfe1 /examples/hello_obj.lc | |
parent | 9d06d5a3b467ddf56147f87531fb56b35375dbd2 (diff) |
add Wavefron OBJ loader example
Diffstat (limited to 'examples/hello_obj.lc')
-rw-r--r-- | examples/hello_obj.lc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/examples/hello_obj.lc b/examples/hello_obj.lc new file mode 100644 index 0000000..e2d7caa --- /dev/null +++ b/examples/hello_obj.lc | |||
@@ -0,0 +1,16 @@ | |||
1 | makeFrame (time :: Float) | ||
2 | (texture :: Texture) | ||
3 | (prims :: PrimitiveStream Triangle (Vec 4 Float, Vec 3 Float, Vec 3 Float)) | ||
4 | |||
5 | = imageFrame (emptyDepthImage 1, emptyColorImage (V4 0 0 0.4 1)) | ||
6 | `overlay` | ||
7 | prims | ||
8 | & 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) )) | ||
9 | & rasterizePrimitives (TriangleCtx CullBack PolygonFill NoOffset LastVertex) ((Smooth)) | ||
10 | & mapFragments (\((uv)) -> ((texture2D (Sampler PointFilter MirroredRepeat texture) uv ))) | ||
11 | & accumulateWith (DepthOp Less True, ColorOp NoBlending (V4 True True True True)) | ||
12 | |||
13 | main = renderFrame $ | ||
14 | makeFrame (Uniform "time") | ||
15 | (Texture2DSlot "diffuseTexture") | ||
16 | (fetch "objects" (Attribute "position", Attribute "normal", Attribute "uvw")) | ||