gl-initial-state.html (1622B)
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 gl.getParameter initial values Tests</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 <div id="description"></div> 18 <div id="console"></div> 19 <canvas id="canvas" width="2" height="2"> </canvas> 20 <script> 21 "use strict"; 22 description("This test checks the initial value of the OpenGL state"); 23 24 debug(""); 25 debug("Canvas.getContext"); 26 27 var wtu = WebGLTestUtils; 28 var gl = wtu.create3DContext("canvas"); 29 if (!gl) { 30 testFailed("context does not exist"); 31 } else { 32 testPassed("context exists"); 33 34 debug(""); 35 checkParameterInitialValue("ONE", "BLEND_SRC_RGB"); 36 checkParameterInitialValue("ONE", "BLEND_SRC_ALPHA"); 37 checkParameterInitialValue("ZERO", "BLEND_DST_RGB"); 38 checkParameterInitialValue("ZERO", "BLEND_DST_ALPHA"); 39 shouldBe("gl.getError()", "gl.NO_ERROR"); 40 } 41 42 function checkParameterInitialValue(expected, enum_val) { 43 var s = gl.getParameter(gl[enum_val]); 44 if (s === gl[expected]) { 45 testPassed("getParameter(gl." + enum_val + ") returned " + expected + " which is " + gl[expected]); 46 } else { 47 testFailed("getParameter(gl." + enum_val + ") returned " + s + " expected: " + expected + " which is " + gl[expected]); 48 } 49 } 50 51 debug(""); 52 var successfullyParsed = true; 53 54 </script> 55 <script src="../../js/js-test-post.js"></script> 56 57 </body> 58 </html>