tor-browser

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

texture-draw-with-2d-and-cube.html (3326B)


      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 ActiveTexture BindTexture conformance test.</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 <canvas id="canvas2d" width="1" height="1" style="width: 40px; height: 40px;"></canvas>
     19 <div id="description"></div>
     20 <div id="console"></div>
     21 <script id="vshader" type="x-shader/x-vertex">
     22 attribute vec3 vPosition;
     23 attribute vec2 texCoord0;
     24 varying vec2 texCoord;
     25 void main()
     26 {
     27  gl_Position = vec4(vPosition, 1);
     28  texCoord = texCoord0;
     29 }
     30 </script>
     31 <script id="fshader" type="x-shader/x-fragment">
     32 precision mediump float;
     33 varying vec2 texCoord;
     34 uniform sampler2D tex2D;
     35 uniform samplerCube texCube;
     36 void main()
     37 {
     38  gl_FragColor = texture2D(tex2D, texCoord);
     39  gl_FragColor += textureCube(texCube, vec3(texCoord, 0));
     40 }
     41 </script>
     42 <script>
     43 "use strict";
     44 var gl;
     45 
     46 function init()
     47 {
     48  description(
     49      "Tests drawing with two textures of different type. " +
     50      "This test covers an ANGLE validation bug. See http://crbug.com/390412.");
     51 
     52  var canvas2d = document.getElementById("canvas2d");
     53  var ctx2d = canvas2d.getContext("2d");
     54 
     55  var wtu = WebGLTestUtils;
     56  gl = wtu.create3DContext("example");
     57  var program = wtu.setupProgram(
     58      gl,
     59      ["vshader", "fshader"],
     60      ['vPosition', 'texCoord0']);
     61  wtu.setupUnitQuad(gl);
     62  gl.disable(gl.DEPTH_TEST);
     63  gl.disable(gl.BLEND);
     64  wtu.glErrorShouldBe(gl, gl.NO_ERROR);
     65 
     66  var texture2D = gl.createTexture();
     67  gl.activeTexture(gl.TEXTURE0);
     68  gl.bindTexture(gl.TEXTURE_2D, texture2D);
     69  gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
     70  wtu.glErrorShouldBe(gl, gl.NO_ERROR);
     71 
     72  var textureCube = gl.createTexture();
     73  gl.activeTexture(gl.TEXTURE1);
     74  gl.bindTexture(gl.TEXTURE_CUBE_MAP, textureCube);
     75  gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
     76  gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
     77  gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
     78  gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
     79  gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
     80  gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
     81  wtu.glErrorShouldBe(gl, gl.NO_ERROR);
     82 
     83  var texture2DLoc = gl.getUniformLocation(program, "tex2D");
     84  var textureCubeLoc = gl.getUniformLocation(program, "texCube");
     85  wtu.glErrorShouldBe(gl, gl.NO_ERROR);
     86 
     87  gl.clearColor(1,0,0,1);
     88  gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
     89 
     90  gl.uniform1i(texture2DLoc, 0);
     91  gl.uniform1i(textureCubeLoc, 1);
     92  gl.drawArrays(gl.TRIANGLES, 0, 6);
     93  wtu.glErrorShouldBe(gl, gl.NO_ERROR);
     94 }
     95 
     96 init();
     97 var successfullyParsed = true;
     98 </script>
     99 <script src="../../../js/js-test-post.js"></script>
    100 
    101 </body>
    102 </html>