OLD | NEW |
| (Empty) |
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" | |
2 "http://www.w3.org/TR/html4/loose.dtd"> | |
3 <html> | |
4 <head> | |
5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
6 <title>WebGL uniformMatrix Conformance Tests</title> | |
7 <script src="../../../resources/js-test.js"></script> | |
8 <script src="resources/webgl-test.js"></script> | |
9 </head> | |
10 <body> | |
11 <div id="description"></div> | |
12 <div id="console"></div> | |
13 <canvas id="example" width="2" height="2"> </canvas> | |
14 | |
15 <script id="vshader" type="x-shader/x-vertex"> | |
16 attribute vec4 vPosition; | |
17 uniform mat4 world4; | |
18 uniform mat3 world3; | |
19 uniform mat2 world2; | |
20 void main() | |
21 { | |
22 gl_Position = vec4(vPosition.xyz, world3[0].x + world2[0].x) * world4; | |
23 } | |
24 </script> | |
25 | |
26 <script id="fshader" type="x-shader/x-fragment"> | |
27 void main() | |
28 { | |
29 gl_FragColor = vec4(1.0,0.0,0.0,1.0); | |
30 } | |
31 </script> | |
32 | |
33 <script> | |
34 description("This test ensures WebGL implementations handle uniformMatrix in a O
penGL ES 2.0 spec compliant way"); | |
35 | |
36 debug(""); | |
37 debug("Checking gl.uniformMatrix."); | |
38 | |
39 if (window.internals) | |
40 window.internals.settings.setWebGLErrorsToConsoleEnabled(false); | |
41 | |
42 gl = initWebGL("example", "vshader", "fshader", [ "vPosition"], [ 0, 0, 0, 1 ],
1); | |
43 for (var ii = 2; ii <= 4; ++ii) { | |
44 var loc = gl.getUniformLocation(gl.program, "world" + ii); | |
45 var matLess = []; | |
46 for (var jj = 0; jj < ii; ++jj) { | |
47 for (var ll = 0; ll < ii; ++ll) { | |
48 if (jj == ii - 1 && ll == ii - 1) | |
49 continue; | |
50 matLess[jj * ii + ll] = (jj == ll) ? 1 : 0; | |
51 } | |
52 } | |
53 var mat = matLess.concat([1]); | |
54 var matMore = mat.concat([1]); | |
55 name = "uniformMatrix" + ii + "fv"; | |
56 gl[name](loc, false, matLess); | |
57 glErrorShouldBe(gl, gl.INVALID_VALUE, "should fail with insufficient array siz
e for " + name); | |
58 gl[name](loc, false, mat); | |
59 glErrorShouldBe(gl, gl.NO_ERROR, "should succeed with correct array size for "
+ name); | |
60 gl[name](loc, false, matMore); | |
61 glErrorShouldBe(gl, gl.INVALID_VALUE, "should fail with more than 1 array size
for " + name); | |
62 | |
63 mat[ii * ii - 1] = 1; | |
64 gl[name](loc, false, mat); | |
65 glErrorShouldBe(gl, gl.NO_ERROR, "can call " + name + "with transpose = false"
); | |
66 gl[name](loc, true, mat); | |
67 glErrorShouldBe(gl, gl.INVALID_VALUE, name + " should return INVALID_VALUE wit
h transpose = true"); | |
68 } | |
69 | |
70 debug(""); | |
71 | |
72 </script> | |
73 | |
74 </body> | |
75 </html> | |
OLD | NEW |