6 <title>Verifies that GL framebuffer bindings do not change when canvas is resized
</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>
12 <canvas id=
"example" width=
"4px" height=
"4px"></canvas>
13 <div id=
"description"></div>
14 <div id=
"console"></div>
16 description("Verifies that GL framebuffer bindings do not change when canvas is resized");
18 if (window
.initNonKhronosFramework
) {
19 window
.initNonKhronosFramework(true);
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];
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
, fboTex
, 0);
36 gl
.texImage2D(gl
.TEXTURE_2D
, 0, gl
.RGBA
, fboSize
, fboSize
, 0, gl
.RGBA
, gl
.UNSIGNED_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");
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], "area outside fbo should be transparent black");
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.
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
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");
65 debug("test before resizing canvas");
67 debug("test after resizing canvas");
70 debug("test after resizing canvas and waiting for compositing");
72 wtu
.waitForComposite(5, function() {
75 glErrorShouldBe(gl
, gl
.NO_ERROR
, "Should be no errors.");
78 successfullyParsed
= true;