gl-clear.html (1971B)
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 clear conformance 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="example" width="1" height="1" style="width: 256px; height: 48px;"></canvas> 18 <div id="description"></div><div id="console"></div> 19 <script> 20 "use strict"; 21 description("Test clear."); 22 var wtu = WebGLTestUtils; 23 var gl = wtu.create3DContext("example"); 24 var program = wtu.setupTexturedQuad(gl); 25 26 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup."); 27 wtu.checkCanvas(gl, [0,0,0,0], "should be 0,0,0,0"); 28 29 gl.clearColor(1,1,1,1); 30 gl.clear(gl.COLOR_BUFFER_BIT); 31 wtu.checkCanvas(gl, [255,255,255,255], "should be 255,255,255,255"); 32 33 gl.clearColor(0,0,0,0); 34 gl.clear(gl.COLOR_BUFFER_BIT); 35 wtu.checkCanvas(gl, [0,0,0,0], "should be 0,0,0,0"); 36 37 gl.colorMask(false, false, false, true); 38 gl.clearColor(1,1,1,1); 39 gl.clear(gl.COLOR_BUFFER_BIT); 40 wtu.checkCanvas(gl, [0,0,0,255], "should be 0,0,0,255"); 41 42 var tex = gl.createTexture(); 43 gl.bindTexture(gl.TEXTURE_2D, tex); 44 gl.texImage2D( 45 gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, 46 new Uint8Array([128, 128, 128, 192])); 47 48 gl.disable(gl.DEPTH_TEST); 49 gl.disable(gl.BLEND); 50 gl.colorMask(true, true, true, true); 51 gl.drawArrays(gl.TRIANGLES, 0, 6); 52 wtu.checkCanvas(gl, [128,128,128,192], "should be 128,128,128,192"); 53 54 gl.colorMask(false, false, false, true); 55 gl.clearColor(1,1,1,1); 56 gl.clear(gl.COLOR_BUFFER_BIT); 57 wtu.checkCanvas(gl, [128,128,128,255], "should be 128,128,128,255"); 58 59 // TODO: Test depth and stencil clearing. 60 61 debug(""); 62 var successfullyParsed = true; 63 </script> 64 <script src="../../js/js-test-post.js"></script> 65 </body> 66 </html>