tor-browser

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

test_vertexattrib4f_update.html (1538B)


      1 <!DOCTYPE html>
      2 <html>
      3  <head>
      4    <meta charset='utf-8'>
      5    <title>Bug 1426289 - vertexAttrib4f should actually update.</title>
      6    <script src='/tests/SimpleTest/SimpleTest.js'></script>
      7    <link rel='stylesheet' href='/tests/SimpleTest/test.css'>
      8    <script src='webgl-util.js'></script>
      9  </head>
     10  <body>
     11    <script id='eVertSource' type='none'>
     12 attribute vec4 aColor;
     13 varying vec4 vColor;
     14 
     15 void main() {
     16  gl_PointSize = 64.0;
     17  gl_Position = vec4(vec3(0.0), 1.0);
     18  vColor = aColor;
     19 }
     20    </script>
     21    <script id='eFragSource' type='none'>
     22 precision mediump float;
     23 varying vec4 vColor;
     24 
     25 void main() {
     26  gl_FragColor = vColor;
     27 }
     28    </script>
     29    <script>
     30 const canvas = document.createElement('canvas');
     31 canvas.width = 1;
     32 canvas.height = 1;
     33 const gl = canvas.getContext('webgl');
     34 
     35 const prog = WebGLUtil.linkProgramByIds(gl, eVertSource, eFragSource);
     36 gl.useProgram(prog);
     37 
     38 function getRgb() {
     39  const data = new Uint32Array(1);
     40  gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, new Uint8Array(data.buffer));
     41  return data[0] & 0xffffff;
     42 }
     43 
     44 gl.clearColor(0.0, 0.0, 0.0, 1.0);
     45 gl.clear(gl.COLOR_BUFFER_BIT);
     46 let was = getRgb();
     47 ok(was == 0x000000, '0x'+was.toString(16));
     48 
     49 gl.disableVertexAttribArray(prog.aColor);
     50 
     51 gl.vertexAttrib4f(prog.aColor, 1, 0, 0, 1);
     52 gl.drawArrays(gl.POINTS, 0, 1);
     53 was = getRgb();
     54 ok(was == 0x0000ff, '0x'+was.toString(16));
     55 
     56 gl.vertexAttrib4f(prog.aColor, 0, 1, 0, 1);
     57 gl.drawArrays(gl.POINTS, 0, 1);
     58 was = getRgb();
     59 ok(was == 0x00ff00, '0x'+was.toString(16));
     60    </script>
     61  </body>
     62 </html>