dom/canvas/test/webgl-mochitest/test_vertexattrib4f_update.html
author Cristian Tuns <ctuns@mozilla.com>
Thu, 18 Aug 2022 19:20:24 -0400
changeset 627646 6502583dede75c65b3fdc922388b1560ac422909
parent 396975 b22b826e89dcee1f63042b02e463933b568e93da
permissions -rw-r--r--
Backed out 5 changesets (bug 1785253, bug 1781088, bug 1781155, bug 1781084, bug 1781158) temporarily to test if is the cause of bug 1784591 a=backout Backed out changeset 881e2bf93676 (bug 1785253) Backed out changeset 2e07ab0665e6 (bug 1781088) Backed out changeset 7319135c251a (bug 1781158) Backed out changeset c6e64b003a17 (bug 1781155) Backed out changeset 33e06b95b4e7 (bug 1781084)

<!DOCTYPE html>
<html>
  <head>
    <meta charset='utf-8'>
    <title>Bug 1426289 - vertexAttrib4f should actually update.</title>
    <script src='/tests/SimpleTest/SimpleTest.js'></script>
    <link rel='stylesheet' href='/tests/SimpleTest/test.css'>
    <script src='webgl-util.js'></script>
  </head>
  <body>
    <script id='eVertSource' type='none'>
attribute vec4 aColor;
varying vec4 vColor;

void main() {
  gl_PointSize = 64.0;
  gl_Position = vec4(vec3(0.0), 1.0);
  vColor = aColor;
}
    </script>
    <script id='eFragSource' type='none'>
precision mediump float;
varying vec4 vColor;

void main() {
  gl_FragColor = vColor;
}
    </script>
    <script>
const canvas = document.createElement('canvas');
canvas.width = 1;
canvas.height = 1;
const gl = canvas.getContext('webgl');

const prog = WebGLUtil.linkProgramByIds(gl, eVertSource, eFragSource);
gl.useProgram(prog);

function getRgb() {
  const data = new Uint32Array(1);
  gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, new Uint8Array(data.buffer));
  return data[0] & 0xffffff;
}

gl.clearColor(0.0, 0.0, 0.0, 1.0);
gl.clear(gl.COLOR_BUFFER_BIT);
let was = getRgb();
ok(was == 0x000000, '0x'+was.toString(16));

gl.disableVertexAttribArray(prog.aColor);

gl.vertexAttrib4f(prog.aColor, 1, 0, 0, 1);
gl.drawArrays(gl.POINTS, 0, 1);
was = getRgb();
ok(was == 0x0000ff, '0x'+was.toString(16));

gl.vertexAttrib4f(prog.aColor, 0, 1, 0, 1);
gl.drawArrays(gl.POINTS, 0, 1);
was = getRgb();
ok(was == 0x00ff00, '0x'+was.toString(16));
    </script>
  </body>
</html>