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>WebGL: Check that state is not lost by compositing
</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>
17 <canvas id=
"testbed" width=
"16" height=
"16" style=
"width:50px; height:50px"></canvas>
18 <div id=
"description"></div>
19 <div id=
"console"></div>
23 var wtu
= WebGLTestUtils
;
27 var gl
= wtu
.create3DContext('testbed', { antialias
: false });
29 testFailed('could not create context');
33 var program
= wtu
.setupTexturedQuad(gl
);
34 var tex
= gl
.createTexture();
35 var fb
= gl
.createFramebuffer();
37 var step1 = function() {
38 wtu
.fillTexture(gl
, tex
, 1, 1, [0, 255, 0, 255]);
39 wtu
.clearAndDrawUnitQuad(gl
);
40 wtu
.checkCanvas(gl
, [0, 255, 0, 255], "drawing with texture should be green");
43 var step2 = function() {
44 wtu
.clearAndDrawUnitQuad(gl
);
45 wtu
.checkCanvas(gl
, [0, 255, 0, 255], "drawing with texture after composite without rebinding should be green");
47 // Clear background to red
48 gl
.clearColor(1, 0, 0, 1);
49 gl
.clear(gl
.COLOR_BUFFER_BIT
);
51 // Bind framebuffer with green texture.
52 gl
.bindFramebuffer(gl
.FRAMEBUFFER
, fb
);
53 gl
.framebufferTexture2D(gl
.FRAMEBUFFER
, gl
.COLOR_ATTACHMENT0
, gl
.TEXTURE_2D
, tex
, 0);
54 wtu
.checkCanvasRect(gl
, 0, 0, 1, 1, [0, 255, 0, 255], "reading from fbo with attached texture should be green");
57 var step3 = function() {
58 // Should still have fb bound and reading should be green
59 wtu
.checkCanvasRect(gl
, 0, 0, 1, 1, [0, 255, 0, 255], "reading from fbo after composite without rebinding should be green");
69 var runNextStep = function() {
71 if (stepIndex
== steps
.length
) {
72 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "there should be no errors");
76 wtu
.waitForComposite(runNextStep
);
82 var successfullyParsed
= true;