The WebGLRenderingContext.getVertexAttrib() method of the WebGL API returns information about a vertex attribute at a given position.
On this page
WebGLRenderingContext: getVertexAttrib() method
Syntax
js
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 bound
WebGLBuffer. -
gl.VERTEX_ATTRIB_ARRAY_ENABLED -
Returns a
GLbooleanthat istrueif the vertex attribute is enabled at thisindex. Otherwisefalse. -
gl.VERTEX_ATTRIB_ARRAY_SIZE -
Returns a
GLintindicating the size of an element of the vertex array. -
gl.VERTEX_ATTRIB_ARRAY_STRIDE -
Returns a
GLintindicating the number of bytes between successive elements in the array. 0 means that the elements are sequential. -
gl.VERTEX_ATTRIB_ARRAY_TYPE -
Returns a
GLenumrepresenting the array type. One ofgl.BYTEgl.UNSIGNED_BYTEgl.SHORT,gl.UNSIGNED_SHORTgl.FLOAT
-
gl.VERTEX_ATTRIB_ARRAY_NORMALIZED -
Returns a
GLbooleanthat is true if fixed-point data types are normalized for the vertex attribute array at the givenindex. -
gl.CURRENT_VERTEX_ATTRIB -
Returns a
Float32Array(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:
-
gl.VERTEX_ATTRIB_ARRAY_INTEGER -
Returns a
GLbooleanindicating whether an integer data type is in the vertex attribute array at the givenindex. -
gl.VERTEX_ATTRIB_ARRAY_DIVISOR -
Returns a
GLintdescribing the frequency divisor used for instanced rendering.
When using the
ANGLE_instanced_arraysextension:-
ext.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE -
Returns a
GLintdescribing the frequency divisor used for instanced rendering.
-
Return value
Returns the requested vertex attribute information (as specified with pname).
Examples
js
gl.getVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING);
Specifications
| Specification |
|---|
| WebGL Specification # 5.14.10 |
| WebGL 2.0 Specification # 3.7.8 |
Browser compatibility
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
getVertexAttrib |
9 | 12 | 4 | 11 | 12 | 5.1 | 4.4.3 | 25 | 4 | 12 | 8 | 1.5 |
See also
© 2005–2023 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