3 <script src=
"../../../resources/js-test.js"></script>
4 <script src=
"resources/webgl-test.js"></script>
7 <div id=
"description"></div>
8 <div id=
"console"></div>
11 description("Tests calling the various uniform[Matrix]* APIs with a null uniform location");
13 var gl
= create3DContext();
14 var program
= loadStandardProgram(gl
);
16 shouldBe("gl.getError()", "gl.NO_ERROR");
17 shouldBeUndefined("gl.useProgram(program)");
18 var floatArray
= new Float32Array([1, 2, 3, 4]);
19 var intArray
= new Int32Array([1, 2, 3, 4]);
21 function callUniformFunction(name
) {
22 var isArrayVariant
= (name
.charAt(name
.length
- 1) == 'v');
23 var isMatrix
= (name
.indexOf("Matrix") != -1);
25 (name
.charAt(name
.length
- 1) == 'f' ||
26 name
.charAt(name
.length
- 2) == 'f');
27 var sizeIndex
= (isArrayVariant
? name
.length
- 3 : name
.length
- 2);
28 var size
= parseInt(name
.substring(sizeIndex
, sizeIndex
+ 1));
29 // Initialize argument list with null uniform location
32 // Call variant which takes values as array
37 var array
= (isFloat
? new Float32Array(size
) : new Int32Array(size
));
38 for (var i
= 0; i
< size
; i
++) {
43 // Call variant which takes values as parameters
44 for (var i
= 0; i
< size
; i
++) {
49 return func
.apply(gl
, args
);
52 var funcs
= [ "uniform1f", "uniform1fv", "uniform1i", "uniform1iv",
53 "uniform2f", "uniform2fv", "uniform2i", "uniform2iv",
54 "uniform3f", "uniform3fv", "uniform3i", "uniform3iv",
55 "uniform4f", "uniform4fv", "uniform4i", "uniform4iv",
56 "uniformMatrix2fv", "uniformMatrix3fv", "uniformMatrix4fv" ];
57 for (var i
= 0; i
< funcs
.length
; i
++) {
58 callString
= "callUniformFunction('" + funcs
[i
] + "')";
59 shouldBeUndefined(callString
);
60 shouldBe("gl.getError()", "gl.NO_ERROR");