This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The WebGL2RenderingContext.getUniformBlockIndex() method of the WebGL 2 API retrieves the index of a uniform block within a WebGLProgram.


GLuint gl.getUniformBlockIndex(program, uniformBlockName);


A WebGLProgram containing the uniform block.
A DOMString specifying the name of the uniform block to whose index to retrieve.

Return value

A GLuint indicating the uniform block index.


// Assuming a shader with the following declaration:
// uniform UBOData {
//   mat4 foo;
// } instanceName;

// use the block name, not the instance name:
var blockIndex = gl.getUniformBlockIndex(program, 'UBOData');


Specification Status Comment
WebGL 2.0
The definition of 'getUniformBlockIndex' in that specification.
Editor's Draft Initial definition for WebGL.
OpenGL ES 3.0
The definition of 'glGetUniformBlockIndex' in that specification.
Standard Man page of the (similar) OpenGL API.

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support56 No51 No43 No
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support5858 No5143 No7.0

See also

Document Tags and Contributors

Contributors to this page: aleonhard, fscholz, nmve, teoli
Last updated by: aleonhard,