2 Copyright (c) 2022 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 <title>WebGL getUniform from non-current program
</title>
12 <link rel=
"stylesheet" href=
"../../resources/js-test-style.css"/>
13 <script src=
"../../js/js-test-pre.js"></script>
14 <script src=
"../../js/webgl-test-utils.js"></script>
17 <div id=
"description"></div>
18 <div id=
"console"></div>
19 <canvas id=
"example" width=
"2" height=
"2"> </canvas>
20 <script id=
"vshader" type=
"x-shader/x-vertex">
21 attribute vec4 vPosition;
24 gl_Position = vPosition;
28 <script id=
"fshader" type=
"x-shader/x-fragment">
29 precision mediump float;
33 gl_FragColor = vec4(color);
38 description("This test ensures WebGL implementations handle getUniform when the program is not the current program");
42 var wtu
= WebGLTestUtils
;
43 var gl
= wtu
.create3DContext("example");
44 var program1
= wtu
.setupProgram(gl
, ["vshader", "fshader"], ["vPosition"]);
45 var program2
= wtu
.setupProgram(gl
, ["vshader", "fshader"], ["vPosition"]);
46 var loc
= gl
.getUniformLocation(program1
, "color");
48 debug("check we can call getUniform when the program is current")
49 gl
.useProgram(program1
);
50 shouldBe("gl.getUniform(program1, loc)", "0");
51 debug("check we can call getUniform when a different program is current")
52 gl
.useProgram(program2
);
53 shouldBe("gl.getUniform(program1, loc)", "0");
54 debug("check we can call getUniform when no program is current")
56 shouldBe("gl.getUniform(program1, loc)", "0");
58 debug("check we can call getUniform when the program is current")
59 gl
.useProgram(program1
);
60 gl
.uniform1f(loc
, 123)
61 shouldBe("gl.getUniform(program1, loc)", "123");
62 debug("check we can call getUniform when a different program is current")
63 gl
.useProgram(program2
);
64 shouldBe("gl.getUniform(program1, loc)", "123");
65 debug("check we can call getUniform when no program is current")
67 shouldBe("gl.getUniform(program1, loc)", "123");
70 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "should no errors");
73 var successfullyParsed
= true;
76 <script src=
"../../js/js-test-post.js"></script>