gl-vertex-attrib-context-switch.html (1917B)
1 <!-- 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. 5 --> 6 7 <!DOCTYPE html> 8 <html> 9 <head> 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> 15 </head> 16 <body> 17 <canvas id="one" width="50" height="50"> 18 </canvas> 19 <canvas id="two" width="50" height="50"> 20 </canvas> 21 <div id="description"></div> 22 <div id="console"></div> 23 <script> 24 "use strict"; 25 description("tests that vertex attrib value is preserved across context switches"); 26 var wtu = WebGLTestUtils; 27 var positionLocation = 0; 28 var colorLocation = 1; 29 var gridRes = 1; 30 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"); 38 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"); 45 46 wtu.checkCanvas(gl1, [0, 255, 0, 255], "should be green 2"); 47 48 wtu.clearAndDrawIndexedQuad(gl2, gridRes); 49 wtu.checkCanvas(gl2, [0, 0, 0, 255], "should be black 2"); 50 51 wtu.clearAndDrawIndexedQuad(gl1, gridRes); 52 wtu.checkCanvas(gl1, [0, 255, 0, 255], "should be green 3"); 53 54 var successfullyParsed = true; 55 </script> 56 <script src="../../js/js-test-post.js"></script> 57 58 </body> 59 </html>