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