tor-browser

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

gl-get-uniform-non-current-program.html (2410B)


      1 <!--
      2 Copyright (c) 2022 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 getUniform from non-current program</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 <div id="description"></div>
     18 <div id="console"></div>
     19 <canvas id="example" width="2" height="2"> </canvas>
     20    <script id="vshader" type="x-shader/x-vertex">
     21        attribute vec4 vPosition;
     22        void main()
     23        {
     24            gl_Position = vPosition;
     25        }
     26    </script>
     27 
     28    <script id="fshader" type="x-shader/x-fragment">
     29        precision mediump float;
     30        uniform float color;
     31        void main()
     32        {
     33            gl_FragColor = vec4(color);
     34        }
     35    </script>
     36 <script>
     37 "use strict";
     38 description("This test ensures WebGL implementations handle getUniform when the program is not the current program");
     39 
     40 debug("");
     41 
     42 var wtu = WebGLTestUtils;
     43 var gl = wtu.create3DContext("example");
     44 var program1 = wtu.setupProgram(gl, ["vshader", "fshader"], ["vPosition"]);
     45 var program2 = wtu.setupProgram(gl, ["vshader", "fshader"], ["vPosition"]);
     46 var loc = gl.getUniformLocation(program1, "color");
     47 
     48 debug("check we can call getUniform when the program is current")
     49 gl.useProgram(program1);
     50 shouldBe("gl.getUniform(program1, loc)", "0");
     51 debug("check we can call getUniform when a different program is current")
     52 gl.useProgram(program2);
     53 shouldBe("gl.getUniform(program1, loc)", "0");
     54 debug("check we can call getUniform when no program is current")
     55 gl.useProgram(null);
     56 shouldBe("gl.getUniform(program1, loc)", "0");
     57 
     58 debug("check we can call getUniform when the program is current")
     59 gl.useProgram(program1);
     60 gl.uniform1f(loc, 123)
     61 shouldBe("gl.getUniform(program1, loc)", "123");
     62 debug("check we can call getUniform when a different program is current")
     63 gl.useProgram(program2);
     64 shouldBe("gl.getUniform(program1, loc)", "123");
     65 debug("check we can call getUniform when no program is current")
     66 gl.useProgram(null);
     67 shouldBe("gl.getUniform(program1, loc)", "123");
     68 
     69 
     70 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should no errors");
     71 
     72 debug("");
     73 var successfullyParsed = true;
     74 
     75 </script>
     76 <script src="../../js/js-test-post.js"></script>
     77 
     78 </body>
     79 </html>