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 <title>WebGL Vertex Attrib Context Switch Test
</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 <canvas id=
"one" width=
"50" height=
"50">
19 <canvas id=
"two" width=
"50" height=
"50">
21 <div id=
"description"></div>
22 <div id=
"console"></div>
25 description("tests that vertex attrib value is preserved across context switches");
26 var wtu
= WebGLTestUtils
;
27 var positionLocation
= 0;
28 var colorLocation
= 1;
31 var canvas1
= document
.getElementById("one");
32 var gl1
= wtu
.create3DContext(canvas1
);
33 var program1
= wtu
.setupSimpleVertexColorProgram(gl1
, positionLocation
, colorLocation
);
34 gl1
.vertexAttrib4f(colorLocation
, 0.0, 1.0, 0.0, 1.0);
35 wtu
.setupIndexedQuad(gl1
, gridRes
, positionLocation
);
36 wtu
.clearAndDrawIndexedQuad(gl1
, gridRes
);
37 wtu
.checkCanvas(gl1
, [0, 255, 0, 255], "should be green 1");
39 var canvas2
= document
.getElementById("two");
40 var gl2
= wtu
.create3DContext(canvas2
);
41 var program2
= wtu
.setupSimpleVertexColorProgram(gl2
, positionLocation
, colorLocation
);
42 wtu
.setupIndexedQuad(gl2
, gridRes
, positionLocation
);
43 wtu
.clearAndDrawIndexedQuad(gl2
, gridRes
);
44 wtu
.checkCanvas(gl2
, [0, 0, 0, 255], "should be black 1");
46 wtu
.checkCanvas(gl1
, [0, 255, 0, 255], "should be green 2");
48 wtu
.clearAndDrawIndexedQuad(gl2
, gridRes
);
49 wtu
.checkCanvas(gl2
, [0, 0, 0, 255], "should be black 2");
51 wtu
.clearAndDrawIndexedQuad(gl1
, gridRes
);
52 wtu
.checkCanvas(gl1
, [0, 255, 0, 255], "should be green 3");
54 var successfullyParsed
= true;
56 <script src=
"../../js/js-test-post.js"></script>