tor-browser

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

texture-cube-as-fbo-attachment.html (2166B)


      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>WebGL texture cube as FBO color attachment</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="2" height="2" style="width: 40px; height: 40px;"></canvas>
     18 <div id="description"></div>
     19 <div id="console"></div>
     20 <script>
     21 "use strict";
     22 var gl;
     23 
     24 function run()
     25 {
     26  description(
     27      "Tests using a cube map face as the color attachment of a framebuffer object. " +
     28      "This test covers an ANGLE validation bug. See https://code.google.com/p/angleproject/issues/detail?id=849 .");
     29 
     30  var wtu = WebGLTestUtils;
     31  gl = wtu.create3DContext("example");
     32  var textureCube = gl.createTexture();
     33  gl.bindTexture(gl.TEXTURE_CUBE_MAP, textureCube);
     34  var faces = [
     35    gl.TEXTURE_CUBE_MAP_POSITIVE_X,
     36    gl.TEXTURE_CUBE_MAP_NEGATIVE_X,
     37    gl.TEXTURE_CUBE_MAP_POSITIVE_Y,
     38    gl.TEXTURE_CUBE_MAP_NEGATIVE_Y,
     39    gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
     40    gl.TEXTURE_CUBE_MAP_NEGATIVE_Z
     41  ];
     42  gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
     43  gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
     44  for (var ii = 0; ii < faces.length; ++ii) {
     45    gl.texImage2D(faces[ii], 0, gl.RGBA, 2, 2, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
     46  }
     47  wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup");
     48 
     49  var fbo = gl.createFramebuffer();
     50  gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
     51 
     52  for (var ii = 0; ii < faces.length; ++ii) {
     53    gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, faces[ii], textureCube, 0);
     54    shouldBe('gl.checkFramebufferStatus(gl.FRAMEBUFFER)', 'gl.FRAMEBUFFER_COMPLETE');
     55    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors for face " + wtu.glEnumToString(gl, faces[ii]));
     56  }
     57 }
     58 
     59 run();
     60 var successfullyParsed = true;
     61 </script>
     62 <script src="../../../js/js-test-post.js"></script>
     63 
     64 </body>
     65 </html>