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>Test drawBuffers, readBuffer, and fbo completeness
</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 <div id=
"description"></div>
18 <div id=
"console"></div>
19 <canvas id=
"canvas" width=
"20" height=
"20"> </canvas>
21 // In MacOSX, if drawBuffers() and readBuffer() both select an attachment with no image attached,
22 // fbo becomes incomplete. However, drawBuffers() and readBuffer() should not affect fbo completeness.
25 description("This tests drawBuffers, readBuffer, and fbo completeness");
27 var setupRenderbuffer = function(attachment
) {
28 var renderbuffer
= gl
.createRenderbuffer();
29 gl
.bindRenderbuffer(gl
.RENDERBUFFER
, renderbuffer
);
30 gl
.framebufferRenderbuffer(gl
.FRAMEBUFFER
, attachment
, gl
.RENDERBUFFER
, renderbuffer
);
31 gl
.renderbufferStorage(gl
.RENDERBUFFER
, gl
.RGBA8
, canvas
.width
, canvas
.height
);
35 var wtu
= WebGLTestUtils
;
36 var canvas
= document
.getElementById("canvas");
37 var gl
= wtu
.create3DContext(canvas
, undefined, 2);
39 testFailed("context does not exist");
41 testPassed("context exists");
43 var fb
= gl
.createFramebuffer();
44 gl
.bindFramebuffer(gl
.FRAMEBUFFER
, fb
);
46 debug("fbo with two color images attached should be complete");
47 var colorbuffer
= setupRenderbuffer(gl
.COLOR_ATTACHMENT0
);
48 var colorbuffer1
= setupRenderbuffer(gl
.COLOR_ATTACHMENT1
);
49 shouldBe('gl.checkFramebufferStatus(gl.FRAMEBUFFER)', 'gl.FRAMEBUFFER_COMPLETE');
51 debug("drawBuffers selects ATTACHMENT1, fbo should be complete");
52 gl
.drawBuffers([gl
.NONE
, gl
.COLOR_ATTACHMENT1
]);
53 shouldBe('gl.checkFramebufferStatus(gl.FRAMEBUFFER)', 'gl.FRAMEBUFFER_COMPLETE');
55 debug("remove image attached to ATTACHMENT1, fbo should be complete");
56 gl
.framebufferRenderbuffer(gl
.FRAMEBUFFER
, gl
.COLOR_ATTACHMENT1
, gl
.RENDERBUFFER
, null);
57 shouldBe('gl.checkFramebufferStatus(gl.FRAMEBUFFER)', 'gl.FRAMEBUFFER_COMPLETE');
59 debug("set read buffer to ATTACHMENT1, fbo should be complete");
60 gl
.readBuffer(gl
.COLOR_ATTACHMENT1
);
61 shouldBe('gl.checkFramebufferStatus(gl.FRAMEBUFFER)', 'gl.FRAMEBUFFER_COMPLETE');
63 debug("drawBuffers selects ATTACHMENT0, fbo should be complete");
64 gl
.drawBuffers([gl
.COLOR_ATTACHMENT0
]);
65 shouldBe('gl.checkFramebufferStatus(gl.FRAMEBUFFER)', 'gl.FRAMEBUFFER_COMPLETE');
67 debug("drawBuffers selects ATTACHMENT1, fbo should be complete");
68 gl
.drawBuffers([gl
.NONE
, gl
.COLOR_ATTACHMENT1
]);
69 shouldBe('gl.checkFramebufferStatus(gl.FRAMEBUFFER)', 'gl.FRAMEBUFFER_COMPLETE');
71 debug("set read buffer to ATTACHMENT0, fbo should be complete");
72 gl
.readBuffer(gl
.COLOR_ATTACHMENT0
);
73 shouldBe('gl.checkFramebufferStatus(gl.FRAMEBUFFER)', 'gl.FRAMEBUFFER_COMPLETE');
75 gl
.deleteFramebuffer(fb
);
76 gl
.deleteRenderbuffer(colorbuffer
);
77 gl
.deleteRenderbuffer(colorbuffer1
);
79 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "should be no error after setup and clear render buffer");
83 var successfullyParsed
= true;
86 <script src=
"../../js/js-test-post.js"></script>