5 <title>WebGL OES_fbo_render_mipmap Conformance Tests
</title>
6 <link rel=
"stylesheet" href=
"../../resources/js-test-style.css"/>
7 <script src=
"../../js/js-test-pre.js"></script>
8 <script src=
"../../js/webgl-test-utils.js"></script>
11 <canvas id=
"canvas" width=
"128" height=
"128"></canvas>
12 <div id=
"description"></div>
13 <div id=
"console"></div>
16 description("This test verifies the functionality of the OES_fbo_render_mipmap extension, if it is available.");
18 var wtu
= WebGLTestUtils
;
19 var canvas
= document
.getElementById("canvas");
20 var gl
= wtu
.create3DContext(canvas
);
25 const oesFboRenderMipmap
= gl
.getExtension("OES_fbo_render_mipmap");
26 if (!oesFboRenderMipmap
) {
27 testPassed("OES_fbo_render_mipmap is allowed to be missing.");
31 let texture
= gl
.createTexture();
32 gl
.bindTexture(gl
.TEXTURE_2D
, texture
);
33 gl
.texParameteri(gl
.TEXTURE_2D
, gl
.TEXTURE_MAG_FILTER
, gl
.NEAREST
);
34 gl
.texParameteri(gl
.TEXTURE_2D
, gl
.TEXTURE_MIN_FILTER
, gl
.NEAREST_MIPMAP_NEAREST
);
49 for (let level
= 0; level
<= maxLevel
; level
++) {
50 let size
= Math
.pow(2, maxLevel
- level
);
51 gl
.texImage2D(gl
.TEXTURE_2D
, level
, gl
.RGBA
, size
, size
, 0, gl
.RGBA
, gl
.UNSIGNED_BYTE
, null);
52 let fbo
= gl
.createFramebuffer();
53 gl
.bindFramebuffer(gl
.FRAMEBUFFER
, fbo
);
54 gl
.framebufferTexture2D(gl
.FRAMEBUFFER
, gl
.COLOR_ATTACHMENT0
, gl
.TEXTURE_2D
, texture
, level
);
57 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "Any level of a texture can be attached to a framebuffer object.");
60 for (let level
= 0; level
<= maxLevel
; level
++) {
61 gl
.bindFramebuffer(gl
.FRAMEBUFFER
, fbos
[level
]);
62 shouldBe("gl.checkFramebufferStatus(gl.FRAMEBUFFER)", "gl.FRAMEBUFFER_COMPLETE");
63 gl
.clearColor(colors
[level
][0] / 255, colors
[level
][1] / 255, colors
[level
][2] / 255, colors
[level
][3] / 255);
64 gl
.clear(gl
.COLOR_BUFFER_BIT
);
67 gl
.bindFramebuffer(gl
.FRAMEBUFFER
, null);
69 let program
= wtu
.setupTexturedQuad(gl
);
71 for (let level
= 0; level
<= maxLevel
; level
++) {
72 let size
= Math
.pow(2, maxLevel
- level
);
73 // We use differrent viewport sizes to affect which miplevel is fetched from the texture.
74 gl
.viewport(0, 0, size
, size
);
75 gl
.drawArrays(gl
.TRIANGLES
, 0, 6);
76 wtu
.checkCanvasRect(gl
, 0, 0, 1, 1, colors
[level
]);
82 var successfullyParsed
= true;
84 <script src=
"../../js/js-test-post.js"></script>
89 Copyright (c) 2019 The Khronos Group Inc.
90 Use of this source code is governed by an MIT-style license that can be
91 found in the LICENSE.txt file.