WebGLRenderingContext: getVertexAttrib() method
Baseline Widely available
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 inWeb Workers.
TheWebGLRenderingContext.getVertexAttrib() method of theWebGL API returns information about a vertexattribute at a given position.
In this article
Syntax
getVertexAttrib(index, pname)Parameters
indexA
GLuintspecifying the index of the vertex attribute.pnameA
GLenumspecifying the information to query. Possible values:gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDINGReturns the currently bound
WebGLBuffer.gl.VERTEX_ATTRIB_ARRAY_ENABLEDReturns a
GLbooleanthat istrueif the vertex attribute is enabled at thisindex. Otherwisefalse.gl.VERTEX_ATTRIB_ARRAY_SIZEReturns a
GLintindicating the size of an element of the vertex array.gl.VERTEX_ATTRIB_ARRAY_STRIDEReturns a
GLintindicating the number of bytes between successive elements in the array. 0 meansthat the elements are sequential.gl.VERTEX_ATTRIB_ARRAY_TYPEReturns a
GLenumrepresenting the array type. One ofgl.BYTEgl.UNSIGNED_BYTEgl.SHORT,gl.UNSIGNED_SHORTgl.FLOAT
gl.VERTEX_ATTRIB_ARRAY_NORMALIZEDReturns a
GLbooleanthat is true if fixed-point data types are normalized forthe vertex attribute array at the givenindex.gl.CURRENT_VERTEX_ATTRIBReturns a
Float32Array(with 4 elements) representing the current value of the vertex attribute at thegivenindex.
When using aWebGL 2 context,the following values are available additionally:
gl.VERTEX_ATTRIB_ARRAY_INTEGERReturns a
GLbooleanindicating whether an integer data type is inthe vertex attribute array at the givenindex.gl.VERTEX_ATTRIB_ARRAY_DIVISORReturns a
GLintdescribing the frequency divisor used for instanced rendering.
When using the
ANGLE_instanced_arraysextension:ext.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLEReturns a
GLintdescribing the frequency divisor used for instancedrendering.
Return value
Returns the requested vertex attribute information (as specified withpname).
Examples
gl.getVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING);Specifications
| Specification |
|---|
| WebGL Specification> # 5.14.10> |
| WebGL 2.0 Specification> # 3.7.8> |