WebGLRenderingContext.getVertexAttrib() - Web APIs 编辑
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 ofgl.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
Specification | Status | Comment |
---|---|---|
WebGL 1.0 The definition of 'getVertexAttrib' in that specification. | Recommendation | Initial definition for WebGL. |
OpenGL ES 2.0 The definition of 'glGetVertexAttrib' in that specification. | Standard | Man page of the OpenGL ES 2 API. |
WebGL 2.0 The definition of 'getVertexAttrib' in that specification. | Editor's Draft | Updated definition for WebGL 2. |
OpenGL ES 3.0 The definition of 'glGetVertexAttrib' in that specification. | Standard | Man page of the OpenGL ES 3 API. |
Browser compatibility
BCD tables only load in the browser
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.
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论