OLD | NEW |
| (Empty) |
1 <!-- | |
2 Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
3 Use of this source code is governed by a BSD-style license that can be | |
4 found in the LICENSE file. | |
5 --> | |
6 <!DOCTYPE html> | |
7 <html> | |
8 <head> | |
9 <meta charset="utf-8"> | |
10 <title>WebGL uniformMatrix Conformance Tests</title> | |
11 <link rel="stylesheet" href="../../resources/js-test-style.css"/> | |
12 <script src="../../resources/js-test-pre.js"></script> | |
13 <script src="../resources/webgl-test.js"></script> | |
14 </head> | |
15 <body> | |
16 <div id="description"></div> | |
17 <div id="console"></div> | |
18 <canvas id="example" width="2" height="2"> </canvas> | |
19 | |
20 <script id="vshader" type="x-shader/x-vertex"> | |
21 attribute vec4 vPosition; | |
22 uniform mat4 world4; | |
23 uniform mat3 world3; | |
24 uniform mat2 world2; | |
25 void main() | |
26 { | |
27 gl_Position = vec4(vPosition.xyz, world3[0].x + world2[0].x) * world4; | |
28 } | |
29 </script> | |
30 | |
31 <script id="fshader" type="x-shader/x-fragment"> | |
32 void main() | |
33 { | |
34 gl_FragColor = vec4(1.0,0.0,0.0,1.0); | |
35 } | |
36 </script> | |
37 | |
38 <script> | |
39 description("This test ensures WebGL implementations handle uniformMatrix in a O
penGL ES 2.0 spec compliant way"); | |
40 | |
41 debug(""); | |
42 debug("Checking gl.uniformMatrix."); | |
43 | |
44 gl = initWebGL("example", "vshader", "fshader", [ "vPosition"], [ 0, 0, 0, 1 ],
1); | |
45 for (var ii = 2; ii <= 4; ++ii) { | |
46 var loc = gl.getUniformLocation(gl.program, "world" + ii); | |
47 var matLess = []; | |
48 for (var jj = 0; jj < ii; ++jj) { | |
49 for (var ll = 0; ll < ii; ++ll) { | |
50 if (jj == ii - 1 && ll == ii - 1) | |
51 continue; | |
52 matLess[jj * ii + ll] = (jj == ll) ? 1 : 0; | |
53 } | |
54 } | |
55 var mat = matLess.concat([1]); | |
56 var matMore = mat.concat([1]); | |
57 name = "uniformMatrix" + ii + "fv"; | |
58 gl[name](loc, false, matLess); | |
59 glErrorShouldBe(gl, gl.INVALID_VALUE, "should fail with insufficient array siz
e for " + name); | |
60 gl[name](loc, false, mat); | |
61 glErrorShouldBe(gl, gl.NO_ERROR, "should succeed with correct array size for "
+ name); | |
62 gl[name](loc, false, matMore); | |
63 glErrorShouldBe(gl, gl.INVALID_VALUE, "should fail with more than 1 array size
for " + name); | |
64 | |
65 mat[ii * ii - 1] = 1; | |
66 gl[name](loc, false, mat); | |
67 glErrorShouldBe(gl, gl.NO_ERROR, "can call " + name + "with transpose = false"
); | |
68 gl[name](loc, true, mat); | |
69 glErrorShouldBe(gl, gl.INVALID_VALUE, name + " should return INVALID_VALUE wit
h transpose = true"); | |
70 } | |
71 | |
72 debug(""); | |
73 successfullyParsed = true; | |
74 | |
75 </script> | |
76 <script src="../../resources/js-test-post.js"></script> | |
77 | |
78 </body> | |
79 </html> | |
OLD | NEW |