大网数据广告活动
Web 标准与前端开发

WebGLRenderingContext: getVertexAttrib() method

· 52CE 我爱测

The **`WebGLRenderingContext.getVertexAttrib()`** method of the WebGL API returns information about a vertex attribute at a given position.

WebGL

The WebGLRenderingContext.getVertexAttrib() method of the WebGL API returns information about a vertex attribute at a given position.

Syntax

getVertexAttrib(index, pname)

Parameters

  • index
    • : A WebGL_API/Types specifying the index of the vertex attribute.
  • pname
    • : A WebGL_API/Types 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 WebGL_API/Types that is true if the vertex attribute is enabled at this index. Otherwise false.
      • gl.VERTEX_ATTRIB_ARRAY_SIZE

        • : Returns a WebGL_API/Types indicating the size of an element of the vertex array.
      • gl.VERTEX_ATTRIB_ARRAY_STRIDE

        • : Returns a WebGL_API/Types 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 WebGL_API/Types 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 WebGL_API/Types 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 WebGL2RenderingContext, the following values are available additionally:

      • gl.VERTEX_ATTRIB_ARRAY_INTEGER
        • : Returns a WebGL_API/Types indicating whether an integer data type is in the vertex attribute array at the given index.
      • gl.VERTEX_ATTRIB_ARRAY_DIVISOR
        • : Returns a WebGL_API/Types describing the frequency divisor used for instanced rendering.

      When using the ANGLE_instanced_arrays extension:

      • ext.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE
        • : Returns a WebGL_API/Types 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

See also

  • WebGLRenderingContext.getVertexAttribOffset()
  • ANGLE_instanced_arrays

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。