WebGLRenderingContext.getVertexAttrib()
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 boundWebGLBuffer
. -
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-
gl.BYTE
, -
gl.UNSIGNED_BYTE
, -
gl.SHORT
, -
gl.UNSIGNED_SHORT
, -
gl.FLOAT
.
-
-
gl.VERTEX_ATTRIB_ARRAY_NORMALIZED
: Returns aGLboolean
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:
- When using the
ANGLE_instanced_arrays
extension:-
ext.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE
: Returns aGLint
describing 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
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 |
≤37 |
25 |
Yes |
12 |
8 |
1.5 |
WebGL2 |
56 |
79 |
51 |
No |
43 |
No |
58 |
58 |
51 |
43 |
No |
7.0 |
See also
© 2005–2021 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