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
GLuint
specifying the index of the vertex attribute. pname
- A
GLenum
specifying the information to query. Possible values:
gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING
- Returns the currently bound
WebGLBuffer
. gl.VERTEX_ATTRIB_ARRAY_ENABLED
: Returns aGLboolean
that istrue
if the vertex attribute is enabled at thisindex
. Otherwisefalse
.gl.VERTEX_ATTRIB_ARRAY_SIZE
: Returns aGLint
indicating the size of an element of the vertex array.gl.VERTEX_ATTRIB_ARRAY_STRIDE
: Returns aGLint
indicating the number of bytes between successive elements in the array. 0 means that the elements are sequential.gl.VERTEX_ATTRIB_ARRAY_TYPE
: Returns aGLenum
representing the array type. One of
- Returns the currently bound
gl.BYTE
,gl.UNSIGNED_BYTE
,gl.SHORT
,gl.UNSIGNED_SHORT
,gl.FLOAT
.
gl.VERTEX_ATTRIB_ARRAY_NORMALIZED
- Returns a
GLboolean
that 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:
- Returns a
gl.VERTEX_ATTRIB_ARRAY_INTEGER
- When using the
ANGLE_instanced_arrays
extension
ext.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE
- Returns a
GLint
describing the frequency divisor used for instanced rendering.
- Returns a
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.0The definition of 'getVertexAttrib' in that specification. | Recommendation | Initial definition for WebGL. |
OpenGL ES 2.0The definition of 'glGetVertexAttrib' in that specification. | Standard | Man page of the OpenGL ES 2 API. |
WebGL 2.0The definition of 'getVertexAttrib' in that specification. | Editor's Draft | Updated definition for WebGL 2. |
OpenGL ES 3.0The 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.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
getVertexAttrib
|
Chrome
Full support 9 |
Edge
Full support 12 |
Firefox
Full support 4 |
IE
Full support 11 |
Opera
Full support 12 |
Safari
Full support 5.1 |
WebView Android
Full support Yes |
Chrome Android
Full support 25 |
Firefox Android
Full support Yes |
Opera Android
Full support 12 |
Safari iOS
Full support 8 |
Samsung Internet Android
Full support 1.5 |
WebGL2
|
Chrome
Full support 56 |
Edge
Full support 79 |
Firefox
Full support 51 |
IE
No support No |
Opera
Full support 43 |
Safari
No support No |
WebView Android
Full support 58 |
Chrome Android
Full support 58 |
Firefox Android
Full support 51 |
Opera Android
Full support 43 |
Safari iOS
No support No |
Samsung Internet Android
Full support 7.0 |
Legend
- Full support
- Full support
- No support
- No support
See also
WebGLRenderingContext.getVertexAttrib() by Mozilla Contributors is licensed under CC-BY-SA 2.5.