tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

cube-incomplete-fbo.html (2412B)


      1 <!--
      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.
      5 -->
      6 
      7 <!DOCTYPE html>
      8 <html>
      9 <head>
     10 <meta charset="utf-8">
     11 <title>Test that cube incomplete textures can not be used as FBO attachments</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>
     15 </head>
     16 <body>
     17 <canvas id="example" width="24" height="24"></canvas>
     18 <div id="description"></div>
     19 <div id="console"></div>
     20 <script>
     21 "use strict";
     22 
     23 var wtu = WebGLTestUtils;
     24 description();
     25 
     26 var gl = wtu.create3DContext("example");
     27 
     28 var testIncompleteCubemapFaceInFBO = function() {
     29    // Create a cube map texture that's not cube complete.
     30    var tex2 = gl.createTexture();
     31    gl.bindTexture(gl.TEXTURE_CUBE_MAP, tex2);
     32    gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
     33    gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
     34 
     35    var cube_map_faces = [
     36        gl.TEXTURE_CUBE_MAP_POSITIVE_X,
     37        gl.TEXTURE_CUBE_MAP_NEGATIVE_X,
     38        gl.TEXTURE_CUBE_MAP_POSITIVE_Y,
     39        gl.TEXTURE_CUBE_MAP_NEGATIVE_Y,
     40        gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
     41        gl.TEXTURE_CUBE_MAP_NEGATIVE_Z
     42    ];
     43    // Fill in all but 1 cube map face
     44    for (var i = 0; i < cube_map_faces.length - 1; ++i) {
     45        gl.texImage2D(cube_map_faces[i], 0, gl.RGBA, 32, 32, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
     46    }
     47 
     48    var fb2 = gl.createFramebuffer();
     49    gl.bindFramebuffer(gl.FRAMEBUFFER, fb2);
     50    gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X, tex2, 0);
     51    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors after attaching cube map face.");
     52    debug("Cubemap has 1 missing face, so framebuffer should not be complete.");
     53    shouldBe("gl.checkFramebufferStatus(gl.FRAMEBUFFER)", "gl.FRAMEBUFFER_INCOMPLETE_ATTACHMENT");
     54 
     55    debug("");
     56 
     57    // Fill in missing cube map face
     58    gl.texImage2D(cube_map_faces[5], 0, gl.RGBA, 32, 32, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
     59    debug("Missing face is added, so framebuffer should become complete.");
     60    shouldBe("gl.checkFramebufferStatus(gl.FRAMEBUFFER)", "gl.FRAMEBUFFER_COMPLETE");
     61 }
     62 
     63 testIncompleteCubemapFaceInFBO();
     64 
     65 var successfullyParsed = true;
     66 finishTest();
     67 
     68 </script>
     69 
     70 </body>
     71 </html>