| OLD | NEW |
| (Empty) |
| 1 | |
| 2 <!DOCTYPE html> | |
| 3 <html> | |
| 4 <head> | |
| 5 <meta charset="utf-8"> | |
| 6 <title>Verifies that GL framebuffer bindings do not change when canvas is resize
d</title> | |
| 7 <script src="../../../resources/js-test.js"></script> | |
| 8 <script src="resources/webgl-test.js"></script> | |
| 9 <script src="resources/webgl-test-utils.js"></script> | |
| 10 </head> | |
| 11 <body> | |
| 12 <canvas id="example" width="4px" height="4px"></canvas> | |
| 13 <div id="description"></div> | |
| 14 <div id="console"></div> | |
| 15 <script> | |
| 16 description("Verifies that GL framebuffer bindings do not change when canvas is
resized"); | |
| 17 | |
| 18 if (window.initNonKhronosFramework) { | |
| 19 window.initNonKhronosFramework(true); | |
| 20 } | |
| 21 | |
| 22 var err; | |
| 23 var wtu = WebGLTestUtils; | |
| 24 var canvas = document.getElementById("example"); | |
| 25 var gl = wtu.create3DContext(canvas); | |
| 26 var green = [0, 255, 0, 255]; | |
| 27 var blue = [0, 0, 255, 255]; | |
| 28 var fboSize = 2; | |
| 29 shouldBeTrue("fboSize < canvas.width"); | |
| 30 var fbo = gl.createFramebuffer(); | |
| 31 gl.bindFramebuffer(gl.FRAMEBUFFER, fbo); | |
| 32 var fboTex = gl.createTexture(); | |
| 33 gl.activeTexture(gl.TEXTURE1); | |
| 34 gl.bindTexture(gl.TEXTURE_2D, fboTex); | |
| 35 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, fbo
Tex, 0); | |
| 36 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, fboSize, fboSize, 0, gl.RGBA, gl.UNSIGN
ED_BYTE, null); | |
| 37 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); | |
| 38 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); | |
| 39 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); | |
| 40 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); | |
| 41 shouldBe("gl.checkFramebufferStatus(gl.FRAMEBUFFER)", "gl.FRAMEBUFFER_COMPLETE")
; | |
| 42 | |
| 43 function checkFBO(color, msg) { | |
| 44 wtu.checkCanvasRect(gl, 0, 0, fboSize, fboSize, color, msg); | |
| 45 wtu.checkCanvasRect(gl, fboSize, fboSize, fboSize, fboSize, [0, 0, 0, 0], "are
a outside fbo should be transparent black"); | |
| 46 } | |
| 47 | |
| 48 // The FBO is 2x2 and it's bound so clearing should clear a 2x2 area | |
| 49 // and calling read pixels should read the clear color in that 2x2 area | |
| 50 // and 0,0,0,0 outside that area. | |
| 51 // | |
| 52 // If the FBO is no longer bound because of a WebGL implementation error | |
| 53 // then likely the clear will clear the backbuffer and reading outside | |
| 54 // the 2x2 area will not be 0,0,0,0 | |
| 55 | |
| 56 function test() { | |
| 57 gl.clearColor(0, 0, 1, 1); | |
| 58 gl.clear(gl.COLOR_BUFFER_BIT); | |
| 59 checkFBO(blue, "should be blue"); | |
| 60 gl.clearColor(0, 1, 0, 1); | |
| 61 gl.clear(gl.COLOR_BUFFER_BIT); | |
| 62 checkFBO(green, "should be green"); | |
| 63 } | |
| 64 | |
| 65 debug("test before resizing canvas"); | |
| 66 test(); | |
| 67 debug("test after resizing canvas"); | |
| 68 canvas.width = 8; | |
| 69 test(); | |
| 70 debug("test after resizing canvas and waiting for compositing"); | |
| 71 canvas.width = 16; | |
| 72 wtu.waitForComposite(5, function() { | |
| 73 test(); | |
| 74 finishTest(); | |
| 75 glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors."); | |
| 76 }); | |
| 77 | |
| 78 successfullyParsed = true; | |
| 79 </script> | |
| 80 </body> | |
| 81 </html> | |
| 82 | |
| OLD | NEW |