delayed-drawing.html (1741B)
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 Delayed Drawing 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="4" height="4" style="width: 40px; height: 30px;"></canvas> 18 <div id="description"></div> 19 <div id="console"></div> 20 <script> 21 "use strict"; 22 enableJSTestPreVerboseLogging(); 23 description(document.title); 24 var wtu = WebGLTestUtils; 25 var gl = wtu.create3DContext("example"); 26 var program = wtu.setupTexturedQuad(gl); 27 28 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup."); 29 30 var tex = gl.createTexture(); 31 wtu.fillTexture(gl, tex, 5, 3, [0, 192, 128, 255]); 32 33 var loc = gl.getUniformLocation(program, "tex"); 34 gl.uniform1i(loc, 0); 35 36 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); 37 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); 38 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); 39 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); 40 41 42 drawAndCheck(); 43 44 setTimeout(step2, 1000); 45 46 function step2() { 47 drawAndCheck(); 48 finishTest(); 49 } 50 51 function drawAndCheck() { 52 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors before drawing."); 53 wtu.clearAndDrawUnitQuad(gl); 54 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from drawing."); 55 wtu.checkCanvas( 56 gl, [0, 192, 128, 255], 57 "draw should be 0, 192, 128, 255"); 58 } 59 60 var successfullyParsed = true; 61 </script> 62 </body> 63 </html>