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.
10 <meta charset=
"utf-8">
11 <title>Check that framebuffers keep contents exiting fullscreen mode.
</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>
19 border:
1px solid black;
31 border:
1px solid black;
32 background-color: red;
50 This test must be run manually.
52 Checks that framebuffers keep their contents going into and out of fullscreen mode.
54 Through the entire test you should see a
<span class=
"redbox">red rectangle
</span>. If it is not
<span class=
"redbox">red
</span> in all cases the test has failed.
58 <div id=
"buttonHolder">
59 <div><input id=
"button" class=
"button" type=
"button" value=
"Click this button to continue the test"/></div>
60 <div id=
"canvasholder">
61 <canvas id='c'
></canvas>
69 <div id=
"description"></div>
70 <div id=
"console"></div>
73 var wtu
= WebGLTestUtils
;
74 var testedFullScreen
= false;
75 var c
= document
.getElementById("c");
76 var button
= document
.getElementById("button");
77 var buttonHolder
= document
.getElementById("buttonHolder");
78 var gl
= wtu
.create3DContext(c
);
80 testFailed("can't init WebGL");
83 var checkState = function() {
85 wtu
.checkCanvasRect(gl
, 0, 0, 1, 1, [0, 255, 0, 255]);
86 shouldBeNonNull("gl.getParameter(gl.FRAMEBUFFER_BINDING)");
87 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "there should be no errors");
90 var checkFramebufferState = function(fullscreen
) {
93 debug("fullscreen:" + fullscreen
);
96 // Not sure if this is needed but need to make sure
97 // we at least went fullscreen once.
98 testedFullScreen
= true;
100 if (testedFullScreen
) {
106 var test = function() {
107 if (!wtu
.setupFullscreen("button", "f", checkFramebufferState
)) {
108 testPassed("Browser does not support fullscreen mode. This is OK");
113 var fb
= gl
.createFramebuffer();
114 var tex
= gl
.createTexture();
116 gl
.clearColor(1,0,0,1);
117 gl
.clear(gl
.COLOR_BUFFER_BIT
);
119 gl
.bindFramebuffer(gl
.FRAMEBUFFER
, fb
);
120 gl
.bindTexture(gl
.TEXTURE_2D
, tex
);
121 gl
.texImage2D(gl
.TEXTURE_2D
, 0, gl
.RGBA
, 1, 1, 0, gl
.RGBA
, gl
.UNSIGNED_BYTE
, null);
122 gl
.framebufferTexture2D(gl
.FRAMEBUFFER
, gl
.COLOR_ATTACHMENT0
, gl
.TEXTURE_2D
, tex
, 0);
123 shouldBe("gl.checkFramebufferStatus(gl.FRAMEBUFFER)", "gl.FRAMEBUFFER_COMPLETE");
125 gl
.clearColor(0, 1, 0, 1);
126 gl
.clear(gl
.COLOR_BUFFER_BIT
);