on master help sign in
Remove WebGL tests because they need an external library
commit223b4dfab00f32341eba84ec7e16106647792e1d authorEvan Czaplicki <info@elm-lang.org> dateFri 13 Jun 2014, 12:23 (12 years ago) parent39053a5
3 files changed−174
tests/compiler/test-files/good/Box.elm−89 tests/compiler/test-files/good/Crate.elm−85 tests/compiler/test-files/good/woodCrate.JPG
tests/compiler/test-files/good/Box.elmdeleted−89
@@ -1,89 +0,0 @@
1−
2−module Box where
3−
4−import Math.Vector3 (..)
5−import Math.Matrix4 (..)
6−import Graphics.WebGL (Triangle, zipTriangle, Shader, Model, model, webgl)
7−import Window(dimensions)
8−
9−-- Create a cube in which each point has a color
10−
11−type ColorPoint = { color:Vec3, point:Vec3 }
12−
13−face : Color -> Vec3 -> Vec3 -> Vec3 -> Vec3 -> [Triangle ColorPoint]
14−face color a b c d =
15− let toV3 color =
16− let c = toRgb color
17− in v3 (toFloat c.red / 255) (toFloat c.green / 255) (toFloat c.blue / 255)
18− p = ColorPoint (toV3 color)
19− in
20− [ (p a, p b, p c), (p c, p d, p a) ]
21−
22−cube : [Triangle ColorPoint]
23−cube =
24− let rft = v3 1 1 1 -- right, front, top
25− lft = v3 -1 1 1 -- left, front, top
26− lbt = v3 -1 -1 1
27− rbt = v3 1 -1 1
28− rbb = v3 1 -1 -1
29− rfb = v3 1 1 -1
30− lfb = v3 -1 1 -1
31− lbb = v3 -1 -1 -1
32− in
33− concat [ face green rft rfb rbb rbt -- right
34− , face blue rft rfb lfb lft -- front
35− , face purple lft lfb lbb lbt -- left
36− , face orange rbt rbb lbb lbt -- back
37− ]
38−
39−-- Create the scene
40−
41−main : Signal Element
42−main = webgl (400,400) <~ lift scene angle
43−
44−angle : Signal Float
45−angle = foldp (\dt theta -> theta + dt / 5000) 0 (fps 25)
46−
47−scene : Float -> [Model]
48−scene angle =
49− [ model vertexShader fragmentShader cube (uniforms angle) ]
50−
51−uniforms : Float -> { rotation:Mat4, perspective:Mat4, camera:Mat4, shade:Float }
52−uniforms t =
53− { rotation = mul (makeRotate (3*t) (v3 0 1 0)) (makeRotate (2*t) (v3 1 0 0))
54− , perspective = makePerspective 45 1 0.01 100
55− , camera = makeLookAt (v3 0 0 5) (v3 0 0 0) (v3 0 1 0)
56− , shade = 0.8
57− }
58−
59−-- Shaders
60−
61−vertexShader : Shader { attr | point:Vec3, color:Vec3 }
62− { unif | rotation:Mat4, perspective:Mat4, camera:Mat4 }
63− { vcolor:Vec3 }
64−vertexShader = [glShader|
65−
66−attribute vec3 point;
67−attribute vec3 color;
68−uniform mat4 perspective;
69−uniform mat4 camera;
70−uniform mat4 rotation;
71−varying vec3 vcolor;
72−void main () {
73− gl_Position = perspective * camera * rotation * vec4(point, 1.0);
74− vcolor = color;
75−}
76−
77−|]
78−
79−fragmentShader : Shader {} { u | shade:Float } { vcolor:Vec3 }
80−fragmentShader = [glShader|
81−
82−precision mediump float;
83−uniform float shade;
84−varying vec3 vcolor;
85−void main () {
86− gl_FragColor = shade * vec4(vcolor, 1.0);
87−}
88−
89−|]
tests/compiler/test-files/good/Crate.elmdeleted−85
@@ -1,85 +0,0 @@
1−
2−module Crate where
3−
4−import Http (..)
5−import Math.Vector2 (Vec2)
6−import Math.Vector3 (..)
7−import Math.Matrix4 (..)
8−import Graphics.WebGL (..)
9−
10−-- Define the mesh for a crate
11−crate : [Triangle { pos:Vec3, coord:Vec3 }]
12−crate = concatMap rotatedFace [ (0,0), (90,0), (180,0), (270,0), (0,90), (0,-90) ]
13−
14−rotatedFace : (Float,Float) -> [Triangle { pos:Vec3, coord:Vec3 }]
15−rotatedFace (angleX,angleY) =
16− let x = makeRotate (degrees angleX) (v3 1 0 0)
17− y = makeRotate (degrees angleY) (v3 0 1 0)
18− t = x `mul` y `mul` makeTranslate (v3 0 0 1)
19− in
20− map (mapTriangle (\x -> {x | pos <- mulVec3 t x.pos })) face
21−
22−face : [Triangle { pos:Vec3, coord:Vec3 }]
23−face =
24− let topLeft = { pos = v3 -1 1 0, coord = v3 0 1 0 }
25− topRight = { pos = v3 1 1 0, coord = v3 1 1 0 }
26− bottomLeft = { pos = v3 -1 -1 0, coord = v3 0 0 0 }
27− bottomRight = { pos = v3 1 -1 0, coord = v3 1 0 0 }
28− in
29− [ (topLeft,topRight,bottomLeft), (bottomLeft,topRight,bottomRight) ]
30−
31−-- View
32−view : Float -> Mat4
33−view angle =
34− foldr1 mul [ perspective
35− , camera
36− , makeRotate (3*angle) (v3 0 1 0)
37− , makeRotate (2*angle) (v3 1 0 0)
38− ]
39−
40−perspective : Mat4
41−perspective = makePerspective 45 1 0.01 100
42−
43−camera : Mat4
44−camera = makeLookAt (v3 0 0 5) (v3 0 0 0) (v3 0 1 0)
45−
46−-- Putting it together
47−main : Signal Element
48−main = webgl (400,400) <~ lift2 scene (loadTex "woodCrate.jpg") (view <~ angle)
49−
50−angle : Signal Float
51−angle = foldp (\dt theta -> theta + dt / 10000) 0 (fps 25)
52−
53−scene : Response Texture -> Mat4 -> [Model]
54−scene response view =
55− case response of
56− Waiting -> []
57− Failure _ _ -> []
58− Success tex -> [model vertexShader fragmentShader crate { crate = tex, view = view }]
59−
60−-- Shaders
61−vertexShader : Shader { pos:Vec3, coord:Vec3 } { u | view:Mat4 } { vcoord:Vec2 }
62−vertexShader = [glShader|
63−
64−attribute vec3 pos;
65−attribute vec3 coord;
66−uniform mat4 view;
67−varying vec2 vcoord;
68−void main () {
69− gl_Position = view * vec4(pos, 1.0);
70− vcoord = coord.xy;
71−}
72−
73−|]
74−
75−fragmentShader : Shader {} { u | crate:Texture } { vcoord:Vec2 }
76−fragmentShader = [glShader|
77−
78−precision mediump float;
79−uniform sampler2D crate;
80−varying vec2 vcoord;
81−void main () {
82− gl_FragColor = texture2D(crate, vcoord);
83−}
84−
85−|]
tests/compiler/test-files/good/woodCrate.JPGdeleted

Binary file not shown.