WebGL2RenderingContext: getUniformBlockIndex() 方法
注意:此功能在 Web Workers 中可用。
WebGL2RenderingContext.getUniformBlockIndex()
方法是 WebGL 2 API 的一部分,用于检索 WebGLProgram
中 uniform 块的索引。
语法
js
getUniformBlockIndex(program, uniformBlockName)
参数
program
-
包含 uniform 块的
WebGLProgram
。 uniformName
-
一个字符串,指定要检索其索引的 uniform 块的名称。
返回值
一个 GLuint
,表示 uniform 块的索引。
示例
js
// Assuming a shader with the following declaration:
// uniform UBOData {
// mat4 foo;
// } instanceName;
// use the block name, not the instance name:
const blockIndex = gl.getUniformBlockIndex(program, "UBOData");
规范
规范 |
---|
WebGL 2.0 规范 # 3.7.16 |
浏览器兼容性
加载中…