This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Note: This feature is available in Web Workers.
The WebGLRenderingContext.getVertexAttrib() method of the WebGL API returns information about a vertex attribute at a given position.
getVertexAttrib(index, pname)
indexA GLuint specifying the index of the vertex attribute.
pnameA GLenum specifying the information to query. Possible values:
gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDINGReturns the currently bound WebGLBuffer.
gl.VERTEX_ATTRIB_ARRAY_ENABLEDReturns a GLboolean that is true if the vertex attribute is enabled at this index. Otherwise false.
gl.VERTEX_ATTRIB_ARRAY_SIZEReturns a GLint indicating the size of an element of the vertex array.
gl.VERTEX_ATTRIB_ARRAY_STRIDEReturns a GLint indicating the number of bytes between successive elements in the array. 0 means that the elements are sequential.
gl.VERTEX_ATTRIB_ARRAY_TYPEReturns a GLenum representing the array type. One of
gl.BYTEgl.UNSIGNED_BYTEgl.SHORT,gl.UNSIGNED_SHORTgl.FLOATgl.VERTEX_ATTRIB_ARRAY_NORMALIZEDReturns a GLboolean that is true if fixed-point data types are normalized for the vertex attribute array at the given index.
gl.CURRENT_VERTEX_ATTRIBReturns a Float32Array (with 4 elements) representing the current value of the vertex attribute at the given index.
When using a WebGL 2 context, the following values are available additionally:
gl.VERTEX_ATTRIB_ARRAY_INTEGERReturns a GLboolean indicating whether an integer data type is in the vertex attribute array at the given index.
gl.VERTEX_ATTRIB_ARRAY_DIVISORReturns a GLint describing the frequency divisor used for instanced rendering.
When using the ANGLE_instanced_arrays extension:
ext.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLEReturns a GLint describing the frequency divisor used for instanced rendering.
Returns the requested vertex attribute information (as specified with pname).
gl.getVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING);
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
getVertexAttrib |
9 | 12 | 4 | 12 | 5.1 | 25 | 4 | 12 | 8 | 1.5 | 4.4.3 | 8 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getVertexAttrib