tor-browser

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

texture-upload-cube-maps.html (1848B)


      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 <link rel="stylesheet" href="../../../resources/js-test-style.css"/>
     12 <script src="../../../js/js-test-pre.js"></script>
     13 <script src="../../../js/webgl-test-utils.js"></script>
     14 </head>
     15 <body>
     16 <canvas id="example" width="2" height="2"></canvas>
     17 <div id="description"></div>
     18 <div id="console"></div>
     19 <script>
     20 "use strict";
     21 description('Tests texImage2D and texSubImage2D upload path for TEXTURE_CUBE_MAP');
     22 
     23 var wtu = WebGLTestUtils;
     24 var canvas = document.getElementById("example");
     25 var gl = wtu.create3DContext(canvas);
     26 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
     27 
     28 function testOneTarget(target, width, height) {
     29  var tex = gl.createTexture();
     30  gl.bindTexture(gl.TEXTURE_CUBE_MAP, tex);
     31  wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from bindTexture(TEXTURE_CUBE_MAP).");
     32 
     33  gl.texImage2D(target, 0, gl.RGB, width, height, 0, gl.RGB, gl.UNSIGNED_BYTE, null);
     34  wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from texImage2D.");
     35 
     36  var buf = new Uint8Array(width * height * 3);
     37  gl.texSubImage2D(target, 0, 0, 0, width, height, gl.RGB, gl.UNSIGNED_BYTE, buf);
     38  wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from texSubImage2D.");
     39 }
     40 
     41 testOneTarget(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 16, 16);
     42 testOneTarget(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 16, 16);
     43 testOneTarget(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 16, 16);
     44 testOneTarget(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 16, 16);
     45 testOneTarget(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 16, 16);
     46 testOneTarget(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 16, 16);
     47 
     48 var successfullyParsed = true;
     49 </script>
     50 <script src="../../../js/js-test-post.js"></script>
     51 </body>
     52 </html>