diff options
author | Csaba Hruska <csaba.hruska@gmail.com> | 2016-01-16 19:19:53 +0100 |
---|---|---|
committer | Csaba Hruska <csaba.hruska@gmail.com> | 2016-01-16 19:19:53 +0100 |
commit | 69e227e723f46920b75274d14cfd09da9abad288 (patch) | |
tree | 1cead01a021874499d0664bd7a3a814299a28218 /examples | |
parent | e3780f65e84234ce8b8aa3569a0963a1637681af (diff) |
update sample
Diffstat (limited to 'examples')
-rw-r--r-- | examples/hello.json | 2 | ||||
-rw-r--r-- | examples/hello.lc | 29 |
2 files changed, 17 insertions, 14 deletions
diff --git a/examples/hello.json b/examples/hello.json index 797bfd0..56de247 100644 --- a/examples/hello.json +++ b/examples/hello.json | |||
@@ -1 +1 @@ | |||
{"textures":[],"commands":[{"tag":"SetRenderTarget","arg0":0},{"tag":"ClearRenderTarget","arg0":[{"tag":"ClearImage","clearValue":{"tag":"VV4F","arg0":{"w":1,"z":0.4,"x":0.0,"y":0.0}},"imageSemantic":{"tag":"Color"}}]},{"tag":"SetProgram","arg0":0},{"tag":"SetSamplerUniform","arg0":"diffuseTexture","arg1":0},{"tag":"SetRasterContext","arg0":{"arg3":{"tag":"LastVertex"},"tag":"TriangleCtx","arg0":{"tag":"CullNone"},"arg1":{"tag":"PolygonFill"},"arg2":{"tag":"NoOffset"}}},{"tag":"SetAccumulationContext","arg0":{"accViewportName":null,"tag":"AccumulationContext","accOperations":[{"tag":"ColorOp","arg0":{"tag":"NoBlending"},"arg1":{"tag":"VV4B","arg0":{"w":true,"z":true,"x":true,"y":true}}}]}},{"tag":"RenderSlot","arg0":0}],"slots":[{"tag":"Slot","slotPrimitive":{"tag":"Triangles"},"slotStreams":{"uv":{"tag":"V2F"},"position":{"tag":"V2F"}},"slotName":"objects","slotUniforms":{"time":{"tag":"Float"},"diffuseTexture":{"tag":"FTexture2D"}},"slotPrograms":[0]}],"programs":[{"programInTextures":{"diffuseTexture":{"tag":"FTexture2D"}},"tag":"Program","programOutput":[{"tag":"Parameter","ty":{"tag":"V4F"},"name":"f0"}],"programStreams":{"q1":{"tag":"Parameter","ty":{"tag":"V2F"},"name":"position"},"r1":{"tag":"Parameter","ty":{"tag":"V2F"},"name":"uv"}},"fragmentShader":"#version 330 core\nvec4 texture2D(sampler2D s, vec2 uv){return texture(s,uv);}\nuniform sampler2D diffuseTexture ;\nsmooth in vec2 v0 ;\nout vec4 f0 ;\nvoid main() {\nf0 = texture2D ( diffuseTexture,v0 );\n}\n","vertexShader":"#version 330 core\nvec4 texture2D(sampler2D s, vec2 uv){return texture(s,uv);}\nuniform float time ;\nin vec2 q1 ;\nin vec2 r1 ;\nsmooth out vec2 v0 ;\nvoid main() {\nv0 = r1;\ngl_Position = ( mat4 ( vec4 ( cos ( time ),sin ( time ),0.0,0.0 ),vec4 ( ( 0.0 ) - ( sin ( time ) ),cos ( time ),0.0,0.0 ),vec4 ( 0.0,0.0,1.0,0.0 ),vec4 ( 0.0,0.0,0.0,1.0 ) ) ) * ( vec4 ( ( q1 ).x,( q1 ).y,-1.0,1.0 ) );\ngl_PointSize = 1.0;\n}\n","geometryShader":null,"programUniforms":{"time":{"tag":"Float"},"diffuseTexture":{"tag":"FTexture2D"}}}],"samplers":[],"tag":"Pipeline","backend":{"tag":"OpenGL33"},"streams":[],"targets":[{"tag":"RenderTarget","renderTargets":[{"tag":"TargetItem","targetSemantic":{"tag":"Color"},"targetRef":{"tag":"Framebuffer","arg0":{"tag":"Color"}}}]}]} \ No newline at end of file | {"textures":[],"commands":[{"tag":"SetRenderTarget","arg0":0},{"tag":"ClearRenderTarget","arg0":[{"tag":"ClearImage","clearValue":{"tag":"VV4F","arg0":{"w":1,"z":0.4,"x":0.0,"y":0.0}},"imageSemantic":{"tag":"Color"}}]},{"tag":"SetProgram","arg0":0},{"tag":"SetSamplerUniform","arg0":"diffuseTexture","arg1":0},{"tag":"SetRasterContext","arg0":{"arg3":{"tag":"LastVertex"},"tag":"TriangleCtx","arg0":{"tag":"CullNone"},"arg1":{"tag":"PolygonFill"},"arg2":{"tag":"NoOffset"}}},{"tag":"SetAccumulationContext","arg0":{"accViewportName":null,"tag":"AccumulationContext","accOperations":[{"tag":"ColorOp","arg0":{"tag":"NoBlending"},"arg1":{"tag":"VV4B","arg0":{"w":true,"z":true,"x":true,"y":true}}}]}},{"tag":"RenderSlot","arg0":0}],"slots":[{"tag":"Slot","slotPrimitive":{"tag":"Triangles"},"slotStreams":{"uv":{"tag":"V2F"},"position":{"tag":"V2F"}},"slotName":"objects","slotUniforms":{"time":{"tag":"Float"},"diffuseTexture":{"tag":"FTexture2D"}},"slotPrograms":[0]}],"programs":[{"programInTextures":{"diffuseTexture":{"tag":"FTexture2D"}},"tag":"Program","programOutput":[{"tag":"Parameter","ty":{"tag":"V4F"},"name":"f0"}],"programStreams":{"z1":{"tag":"Parameter","ty":{"tag":"V2F"},"name":"position"},"a2":{"tag":"Parameter","ty":{"tag":"V2F"},"name":"uv"}},"fragmentShader":"#version 330 core\nvec4 texture2D(sampler2D s, vec2 uv){return texture(s,uv);}\nuniform sampler2D diffuseTexture ;\nsmooth in vec2 v0 ;\nout vec4 f0 ;\nvoid main() {\nf0 = texture2D ( diffuseTexture,v0 );\n}\n","vertexShader":"#version 330 core\nvec4 texture2D(sampler2D s, vec2 uv){return texture(s,uv);}\nuniform float time ;\nin vec2 z1 ;\nin vec2 a2 ;\nsmooth out vec2 v0 ;\nvoid main() {\nv0 = a2;\ngl_Position = ( mat4 ( vec4 ( cos ( time ),sin ( time ),0.0,0.0 ),vec4 ( ( 0.0 ) - ( sin ( time ) ),cos ( time ),0.0,0.0 ),vec4 ( 0.0,0.0,1.0,0.0 ),vec4 ( 0.0,0.0,0.0,1.0 ) ) ) * ( vec4 ( ( z1 ).x,( z1 ).y,-1.0,1.0 ) );\ngl_PointSize = 1.0;\n}\n","geometryShader":null,"programUniforms":{"time":{"tag":"Float"},"diffuseTexture":{"tag":"FTexture2D"}}}],"samplers":[],"tag":"Pipeline","backend":{"tag":"OpenGL33"},"streams":[],"targets":[{"tag":"RenderTarget","renderTargets":[{"tag":"TargetItem","targetSemantic":{"tag":"Color"},"targetRef":{"tag":"Framebuffer","arg0":{"tag":"Color"}}}]}]} \ No newline at end of file | ||
diff --git a/examples/hello.lc b/examples/hello.lc index 20f8292..55e7c73 100644 --- a/examples/hello.lc +++ b/examples/hello.lc | |||
@@ -1,13 +1,16 @@ | |||
1 | time = Uniform "time" :: Float | 1 | makeFrame (time :: Float) |
2 | sampler = Sampler PointFilter MirroredRepeat (Texture2DSlot "diffuseTexture") | 2 | (texture :: Texture) |
3 | main = let | 3 | (prims :: Stream (Primitive Triangle (Vec 2 Float, Vec 2 Float))) |
4 | emptyFB = FrameBuffer (colorImage1 (V4 0.0 0.0 0.4 1.0)) | 4 | |
5 | rasterCtx = TriangleCtx CullNone PolygonFill NoOffset LastVertex | 5 | = imageFrame (emptyColorImage (V4 0 0 0.4 1)) |
6 | fragmentCtx = (ColorOp NoBlending (V4 True True True True)) | 6 | `overlay` |
7 | vertexShader (p,uv) = VertexOut (rotMatrixZ time *. (V4 p%x p%y (-1) 1)) 1.0 () (Smooth uv) | 7 | prims |
8 | vertexStream = Fetch @Triangle "objects" (Attribute "position" :: Vec 2 Float, Attribute "uv" :: Vec 2 Float) | 8 | & mapPrimitives (\(p,uv) -> (rotMatrixZ time *. (V4 p%x p%y (-1) 1), uv)) |
9 | primitiveStream = Transform vertexShader vertexStream | 9 | & rasterizePrimitives (TriangleCtx CullNone PolygonFill NoOffset LastVertex) Smooth |
10 | fragmentStream = Rasterize rasterCtx primitiveStream | 10 | & mapFragments (\uv -> texture2D (Sampler PointFilter MirroredRepeat texture) uv) |
11 | fragmentShader = FragmentShader $ \uv -> texture2D sampler uv | 11 | & accumulateWith (ColorOp NoBlending (V4 True True True True)) |
12 | frame = accumulate fragmentCtx PassAll fragmentShader fragmentStream emptyFB | 12 | |
13 | in ScreenOut frame | 13 | main = renderFrame $ |
14 | makeFrame (Uniform "time") | ||
15 | (Texture2DSlot "diffuseTexture") | ||
16 | (fetch_ "objects" (Attribute "position", Attribute "uv")) | ||