WebGLRenderingContext.uniformMatrix[234]fv()
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.
WebGL API 的 WebGLRenderingContext.uniformMatrix[234]fv() 方法为 uniform 变量指定了矩阵值。
该方法的 3 个版本(uniformMatrix2fv()、uniformMatrix3fv() 和 unifomMatrix4fv()),分别以二阶、三阶和四阶方阵作为输入值,它们应是分别具有 4、9、16 个浮点数的数组。
语法
WebGLRenderingContext.uniformMatrix2fv(location, transpose, value); WebGLRenderingContext.uniformMatrix3fv(location, transpose, value); WebGLRenderingContext.uniformMatrix4fv(location, transpose, value);
参数
location-
WebGLUniformLocation对象包含了要修改的 uniform attribute 位置。位置使用getUniformLocation()获得。 transpose-
GLboolean指定是否转置矩阵。必须为false。 value-
Float32Array型或者是GLfloat序列值。这些值被假定按列主序(column major order)的方式提供。
返回值
undefined
示例
js
gl.uniformMatrix2fv(loc, false, [2, 1, 2, 2]);
规范
| Specification |
|---|
| WebGL Specification> # 5.14.10> |
浏览器兼容性
Loading…
参见
WebGLRenderingContext.uniform()WebGL2RenderingContext.uniformMatrix()– WebGL 2 versions of these methods.