The WebGLRenderingContext.getVertexAttrib() method of the WebGL API returns information about a vertex attribute at a given position.
Syntax
any gl.getVertexAttrib(index, pname);
Parameters
index- A
GLuintspecifying the index of the vertex attribute. pname- A
GLenumspecifying the information to query. Possible values:gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: Returns the currently boundWebGLBuffer.gl.VERTEX_ATTRIB_ARRAY_ENABLED: Returns aGLbooleanthat istrueif the vertex attribute is enabled at thisindex. Otherwisefalse.gl.VERTEX_ATTRIB_ARRAY_SIZE: Returns aGLintindicating the size of an element of the vertex array.gl.VERTEX_ATTRIB_ARRAY_STRIDE: Returns aGLintindicating the number of bytes between successive elements in the array. 0 means that the elements are sequential.gl.VERTEX_ATTRIB_ARRAY_TYPE: Returns aGLenumrepresenting the array type. One ofgl.BYTE,gl.UNSIGNED_BYTE,gl.SHORT,gl.UNSIGNED_SHORT,gl.FIXED,gl.FLOAT.
gl.VERTEX_ATTRIB_ARRAY_NORMALIZED: Returns aGLbooleanthat is true if fixed-point data types are normalized for the vertex attribute array at the givenindex.gl.CURRENT_VERTEX_ATTRIB: Returns aFloat32Array(with 4 elements) representing the current value of the vertex attribute at the givenindex.- When using a WebGL 2 context, the following values are available additionally:
- When using the
ANGLE_instanced_arraysextension:ext.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE: Returns aGLintdescribing the frequency divisor used for instanced rendering.
Return value
Returns the requested vertex attribute information (as specified with pname).
Examples
gl.getVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING);
Specifications
| Specification | Status | Comment |
|---|---|---|
| WebGL 1.0 The definition of 'getVertexAttrib' in that specification. |
Recommendation | Initial definition for WebGL. |
| OpenGL ES 2.0 The definition of 'glGetVertexAttrib' in that specification. |
Standard | Man page of the OpenGL ES 2 API. |
| WebGL 2.0 The definition of 'getVertexAttrib' in that specification. |
Editor's Draft | Updated definition for WebGL 2. |
| OpenGL ES 3.0 The definition of 'glGetVertexAttrib' in that specification. |
Standard | Man page of the OpenGL ES 3 API. |
Browser compatibility
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
| Feature | Chrome | Firefox | Edge | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|---|
| Basic Support | 9 | 4.0 | 12 | 11 | 12 | 5.1 |
WebGL2 | 56 | 51.0 | (No) | (No) | 43 | (No) |
| Feature | Android | Chrome for Android | Edge mobile | Firefox for Android | IE mobile | Opera Android | iOS Safari |
|---|---|---|---|---|---|---|---|
| Basic Support | (Yes) | 25 | (Yes) | (Yes) | 11 | 12 | 8.1 |
WebGL2 | (No) | (No) | (No) | 51.0 | (No) | (No) | (No) |