2 Copyright (c) 2019 The Khronos Group Inc.
3 Use of this source code is governed by an MIT-style license that can be
4 found in the LICENSE.txt file.
10 <meta charset=
"utf-8">
11 <link rel=
"stylesheet" href=
"../../resources/js-test-style.css"/>
12 <script src=
"../../js/js-test-pre.js"></script>
13 <script src=
"../../js/webgl-test-utils.js"></script>
16 <div id=
"description"></div>
17 <div id=
"console"></div>
21 description("Tests calling the various uniform[Matrix]* APIs with a null uniform location");
23 var wtu
= WebGLTestUtils
;
24 var gl
= wtu
.create3DContext();
25 var program
= wtu
.loadStandardProgram(gl
);
27 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
);
28 shouldBeUndefined("gl.useProgram(program)");
29 var floatArray
= new Float32Array([1, 2, 3, 4]);
30 var intArray
= new Int32Array([1, 2, 3, 4]);
32 function callUniformFunction(name
) {
33 var isArrayVariant
= (name
.charAt(name
.length
- 1) == 'v');
34 var isMatrix
= (name
.indexOf("Matrix") != -1);
36 (name
.charAt(name
.length
- 1) == 'f' ||
37 name
.charAt(name
.length
- 2) == 'f');
38 var sizeIndex
= (isArrayVariant
? name
.length
- 3 : name
.length
- 2);
39 var size
= parseInt(name
.substring(sizeIndex
, sizeIndex
+ 1));
40 // Initialize argument list with null uniform location
43 // Call variant which takes values as array
48 var array
= (isFloat
? new Float32Array(size
) : new Int32Array(size
));
49 for (var i
= 0; i
< size
; i
++) {
54 // Call variant which takes values as parameters
55 for (var i
= 0; i
< size
; i
++) {
60 return func
.apply(gl
, args
);
63 var funcs
= [ "uniform1f", "uniform1fv", "uniform1i", "uniform1iv",
64 "uniform2f", "uniform2fv", "uniform2i", "uniform2iv",
65 "uniform3f", "uniform3fv", "uniform3i", "uniform3iv",
66 "uniform4f", "uniform4fv", "uniform4i", "uniform4iv",
67 "uniformMatrix2fv", "uniformMatrix3fv", "uniformMatrix4fv" ];
70 for (var i
= 0; i
< funcs
.length
; i
++) {
71 callString
= "callUniformFunction('" + funcs
[i
] + "')";
72 shouldBeUndefined(callString
);
73 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
);
76 var successfullyParsed
= true;
78 <script src=
"../../js/js-test-post.js"></script>