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 bound WebGLBuffer.
  • gl.VERTEX_ATTRIB_ARRAY_ENABLED: Returns a GLboolean that is true if the vertex attribute is enabled at this index. Otherwise false.
  • gl.VERTEX_ATTRIB_ARRAY_SIZE: Returns a GLint indicating the size of an element of the vertex array.
  • gl.VERTEX_ATTRIB_ARRAY_STRIDE: Returns a GLint indicating the number of bytes between successive elements in the array. 0 means that the elements are sequential.
  • gl.VERTEX_ATTRIB_ARRAY_TYPE: Returns a GLenum representing the array type. One of
    • 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 given index.
  • gl.CURRENT_VERTEX_ATTRIB: Returns a Float32Array (with 4 elements) representing the current value of the vertex attribute at the given index.
  • When using a WebGL 2 context, the following values are available additionally:
    • gl.VERTEX_ATTRIB_ARRAY_INTEGER: Returns a GLboolean indicating whether or not an integer data type is in the vertex attribute array at the given index.
    • gl.VERTEX_ATTRIB_ARRAY_DIVISOR: Returns a GLint describing the frequency divisor used for instanced rendering.
  • When using the ANGLE_instanced_arrays extension:
    • ext.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE: Returns a GLint 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

SpecificationStatusComment
WebGL 1.0
The definition of 'getVertexAttrib' in that specification.
RecommendationInitial definition for WebGL.
OpenGL ES 2.0
The definition of 'glGetVertexAttrib' in that specification.
StandardMan page of the OpenGL ES 2 API.
WebGL 2.0
The definition of 'getVertexAttrib' in that specification.
Editor's DraftUpdated definition for WebGL 2.
OpenGL ES 3.0
The definition of 'glGetVertexAttrib' in that specification.
StandardMan page of the OpenGL ES 3 API.

Browser compatibility

BCD tables only load in the browser

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:100 次

字数:6982

最后编辑:7 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文