diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/Hello.hs | 8 | ||||
-rw-r--r-- | examples/HelloEmbedded.hs (renamed from examples/HelloJson.hs) | 8 | ||||
-rw-r--r-- | examples/LICENSE | 30 | ||||
-rw-r--r-- | examples/Setup.hs | 2 | ||||
-rw-r--r-- | examples/hello.json | 2 | ||||
-rw-r--r-- | examples/lambdacube-gl-examples.cabal | 43 |
6 files changed, 84 insertions, 9 deletions
diff --git a/examples/Hello.hs b/examples/Hello.hs index 89553d0..081fd93 100644 --- a/examples/Hello.hs +++ b/examples/Hello.hs | |||
@@ -8,14 +8,12 @@ import LambdaCube.GL.Mesh as LambdaCubeGL | |||
8 | 8 | ||
9 | import Codec.Picture as Juicy | 9 | import Codec.Picture as Juicy |
10 | 10 | ||
11 | import LambdaCube.Compiler.Driver as LambdaCube -- compiler | 11 | import Data.Aeson |
12 | import qualified Data.ByteString as SB | ||
12 | 13 | ||
13 | main :: IO () | 14 | main :: IO () |
14 | main = do | 15 | main = do |
15 | -- compile hello.lc to graphics pipeline description | 16 | Just pipelineDesc <- decodeStrict <$> SB.readFile "hello.json" |
16 | pipelineDesc <- LambdaCube.compileMain ["."] OpenGL33 "hello" >>= \case | ||
17 | Left err -> fail $ "compile error:\n" ++ err | ||
18 | Right pd -> return pd | ||
19 | 17 | ||
20 | win <- initWindow "LambdaCube 3D DSL Hello World" 640 640 | 18 | win <- initWindow "LambdaCube 3D DSL Hello World" 640 640 |
21 | 19 | ||
diff --git a/examples/HelloJson.hs b/examples/HelloEmbedded.hs index 081fd93..fbddb20 100644 --- a/examples/HelloJson.hs +++ b/examples/HelloEmbedded.hs | |||
@@ -8,12 +8,14 @@ import LambdaCube.GL.Mesh as LambdaCubeGL | |||
8 | 8 | ||
9 | import Codec.Picture as Juicy | 9 | import Codec.Picture as Juicy |
10 | 10 | ||
11 | import Data.Aeson | 11 | import LambdaCube.Compiler as LambdaCube -- compiler |
12 | import qualified Data.ByteString as SB | ||
13 | 12 | ||
14 | main :: IO () | 13 | main :: IO () |
15 | main = do | 14 | main = do |
16 | Just pipelineDesc <- decodeStrict <$> SB.readFile "hello.json" | 15 | -- compile hello.lc to graphics pipeline description |
16 | pipelineDesc <- LambdaCube.compileMain ["."] OpenGL33 "hello" >>= \case | ||
17 | Left err -> fail $ "compile error:\n" ++ err | ||
18 | Right pd -> return pd | ||
17 | 19 | ||
18 | win <- initWindow "LambdaCube 3D DSL Hello World" 640 640 | 20 | win <- initWindow "LambdaCube 3D DSL Hello World" 640 640 |
19 | 21 | ||
diff --git a/examples/LICENSE b/examples/LICENSE new file mode 100644 index 0000000..a4fcec0 --- /dev/null +++ b/examples/LICENSE | |||
@@ -0,0 +1,30 @@ | |||
1 | Copyright (c) 2016, Csaba Hruska | ||
2 | |||
3 | All rights reserved. | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without | ||
6 | modification, are permitted provided that the following conditions are met: | ||
7 | |||
8 | * Redistributions of source code must retain the above copyright | ||
9 | notice, this list of conditions and the following disclaimer. | ||
10 | |||
11 | * Redistributions in binary form must reproduce the above | ||
12 | copyright notice, this list of conditions and the following | ||
13 | disclaimer in the documentation and/or other materials provided | ||
14 | with the distribution. | ||
15 | |||
16 | * Neither the name of Csaba Hruska nor the names of other | ||
17 | contributors may be used to endorse or promote products derived | ||
18 | from this software without specific prior written permission. | ||
19 | |||
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
24 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
diff --git a/examples/Setup.hs b/examples/Setup.hs new file mode 100644 index 0000000..9a994af --- /dev/null +++ b/examples/Setup.hs | |||
@@ -0,0 +1,2 @@ | |||
1 | import Distribution.Simple | ||
2 | main = defaultMain | ||
diff --git a/examples/hello.json b/examples/hello.json index 56de247..813ae8d 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":{"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 | {"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":{"v1":{"tag":"Parameter","ty":{"tag":"V2F"},"name":"position"},"w1":{"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 vv0 ;\nout vec4 f0 ;\nvoid main() {\nf0 = texture2D ( diffuseTexture,vv0 );\n}\n","vertexShader":"#version 330 core\nvec4 texture2D(sampler2D s, vec2 uv){return texture(s,uv);}\nuniform float time ;\nin vec2 v1 ;\nin vec2 w1 ;\nsmooth out vec2 vv0 ;\nvoid main() {\nvv0 = w1;\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 ( ( v1 ).x,( v1 ).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/lambdacube-gl-examples.cabal b/examples/lambdacube-gl-examples.cabal new file mode 100644 index 0000000..dc5f998 --- /dev/null +++ b/examples/lambdacube-gl-examples.cabal | |||
@@ -0,0 +1,43 @@ | |||
1 | name: lambdacube-gl-examples | ||
2 | version: 0.1.0.0 | ||
3 | synopsis: Basic example for LambdaCube 3D Haskell OpenGL backend | ||
4 | -- description: | ||
5 | homepage: http://lambdacube3d.com/getting-started | ||
6 | license: BSD3 | ||
7 | license-file: LICENSE | ||
8 | author: Csaba Hruska | ||
9 | maintainer: csaba.hruska@gmail.com | ||
10 | -- copyright: | ||
11 | category: Graphics | ||
12 | build-type: Simple | ||
13 | extra-source-files: hello.lc | ||
14 | hello.json | ||
15 | cabal-version: >=1.10 | ||
16 | |||
17 | executable hello-gl | ||
18 | main-is: Hello.hs | ||
19 | build-depends: base >=4.8 && <4.9, | ||
20 | containers >=0.5 && <0.6, | ||
21 | vector >=0.11 && <0.12, | ||
22 | JuicyPixels >=3.2 && <3.3, | ||
23 | aeson >=0.9 && <0.11, | ||
24 | bytestring >=0.10 && <0.11, | ||
25 | GLFW-b >=1.4 && <1.5, | ||
26 | lambdacube-gl >=0.4 && <0.5 | ||
27 | -- hs-source-dirs: | ||
28 | default-language: Haskell2010 | ||
29 | |||
30 | executable hello-gl-embedded | ||
31 | main-is: HelloEmbedded.hs | ||
32 | build-depends: base >=4.8 && <4.9, | ||
33 | containers >=0.5 && <0.6, | ||
34 | vector >=0.11 && <0.12, | ||
35 | JuicyPixels >=3.2 && <3.3, | ||
36 | aeson >=0.9 && <0.11, | ||
37 | bytestring >=0.10 && <0.11, | ||
38 | GLFW-b >=1.4 && <1.5, | ||
39 | lambdacube-gl >=0.4 && <0.5, | ||
40 | lambdacube-compiler >=0.4 && <0.5 | ||
41 | -- hs-source-dirs: | ||
42 | default-language: Haskell2010 | ||
43 | |||