WebGLRenderingContext.uniformMatrix[234]fv()
WebGL API 的WebGLRenderingContext.uniformMatrix[234]fv()
方法为 uniform variables 指定了矩阵值 .
该方法的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()
(en-US)获得.transpose
GLboolean
(en-US) 指定是否转置矩阵。必须为false
.value
-
Float32Array
型或者是GLfloat
序列值.假定值以列主要顺序提供.
返回值
undefined
示例
gl.uniformMatrix2fv(loc, false, [2,1, 2,2]);
说明
Specification | Status | Comment |
---|---|---|
WebGL 1.0 uniformMatrix |
Recommendation | Initial definition. |
OpenGL ES 2.0 glUniform |
Standard | Man page of the OpenGL API. |
浏览器兼容性
BCD tables only load in the browser
另见
WebGLRenderingContext.uniform()
WebGL2RenderingContext.uniformMatrix()
– WebGL 2 versions of these methods.