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 framebuffer using texture level
1</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=
"2" height=
"2"> </canvas>
22 var wtu
= WebGLTestUtils
;
25 function testFramebufferTextureWithNonZeroBaseLevel(level
) {
27 throw "This test is incorrect if level < 1";
31 var texture
= gl
.createTexture();
32 gl
.bindTexture(gl
.TEXTURE_2D
, texture
);
33 gl
.texParameteri(gl
.TEXTURE_2D
, gl
.TEXTURE_MIN_FILTER
, gl
.NEAREST
);
34 gl
.texParameteri(gl
.TEXTURE_2D
, gl
.TEXTURE_MAG_FILTER
, gl
.NEAREST
);
35 gl
.texParameteri(gl
.TEXTURE_2D
, gl
.TEXTURE_WRAP_S
, gl
.CLAMP_TO_EDGE
);
36 gl
.texParameteri(gl
.TEXTURE_2D
, gl
.TEXTURE_WRAP_T
, gl
.CLAMP_TO_EDGE
);
37 gl
.texImage2D(gl
.TEXTURE_2D
, level
, gl
.RGBA
, width
, height
, 0, gl
.RGBA
, gl
.UNSIGNED_BYTE
, null);
38 var fbo
= gl
.createFramebuffer();
39 gl
.bindFramebuffer(gl
.FRAMEBUFFER
, fbo
);
40 gl
.framebufferTexture2D(gl
.FRAMEBUFFER
, gl
.COLOR_ATTACHMENT0
, gl
.TEXTURE_2D
, texture
, level
);
41 shouldBe("gl.checkFramebufferStatus(gl.FRAMEBUFFER)", "gl.FRAMEBUFFER_INCOMPLETE_ATTACHMENT");
42 gl
.texParameteri(gl
.TEXTURE_2D
, gl
.TEXTURE_BASE_LEVEL
, level
);
43 shouldBe("gl.checkFramebufferStatus(gl.FRAMEBUFFER)", "gl.FRAMEBUFFER_COMPLETE");
44 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "Setup framebuffer with texture should succeed.");
46 gl
.deleteTexture(texture
);
47 gl
.deleteFramebuffer(fbo
);
50 description("Test fbo completeness when using non level 0 texture images");
52 var canvas
= document
.getElementById("canvas");
53 shouldBeNonNull("gl = wtu.create3DContext(canvas, undefined, 2)");
55 testFramebufferTextureWithNonZeroBaseLevel(1);
58 var successfullyParsed
= true;
61 <script src=
"../../js/js-test-post.js"></script>