| <!DOCTYPE html> |
| <meta charset=utf-8> |
| <title>WebGL2RenderingContext: support for sequences and typed arrays</title> |
| <script src="../../../../resources/testharness.js"></script> |
| <script src="../../../../resources/testharnessreport.js"></script> |
| <div id="log"></div> |
| <script> |
| function create_typed_array(type) { |
| switch (type) { |
| case "i": |
| return new Int32Array(); |
| case "ui": |
| return new Uint32Array(); |
| case "f": |
| return new Float32Array(); |
| default: |
| throw new Error(`Unexpected type: ${type}`); |
| } |
| } |
| |
| let context, methods = []; |
| setup(function() { |
| window.internals.settings.setWebGL2Enabled(true); |
| |
| context = document.createElement("canvas").getContext("webgl2"); |
| if (!context) { |
| throw new Error("Could not create webgl2 context"); |
| } |
| |
| for (let i = 1; i <= 4; ++i) { |
| methods.push([`uniform${i}uiv`, "ui", [null], `uniform${i}uiv data`]); |
| } |
| for (let dim of ["2x3", "3x2", "2x4", "4x2", "3x4", "4x3"]) { |
| methods.push([`uniformMatrix${dim}fv`, "f", [null, false], `uniformMatrix${dim}fv data`]); |
| } |
| for (let type of ["i", "ui"]) { |
| methods.push([`vertexAttribI4${type}v`, type, [0], `vertexAttribI4${type}v values`]); |
| } |
| for (let type of ["i", "ui", "f"]) { |
| methods.push([`clearBuffer${type}v`, type, [context.COLOR, 0], `clearBuffer${type}v values`]); |
| } |
| }); |
| |
| for (var [method, type, args, name] of methods) { |
| test(function() { |
| context[method](...args, create_typed_array(type)); |
| }, `${name} with typed array of type ${type}`); |
| |
| test(function() { |
| context[method](...args, [0]); |
| }, `${name} with sequence of type ${type}`); |
| } |
| </script> |