WebGL2RenderingContext: createVertexArray() 方法

Baseline 已广泛支持

此功能已成熟,并可在多种设备和浏览器版本上运行。自 2021 年 9 月起,所有浏览器均已支持此功能。

注意:此功能在 Web Workers 中可用。

WebGL2RenderingContext.createVertexArray() 方法是 WebGL 2 API 的一部分,用于创建并初始化一个 WebGLVertexArrayObject 对象。该对象代表一个顶点数组对象(VAO),它指向顶点数组数据,并为不同的顶点数据集提供名称。

语法

js
createVertexArray()

参数

无。

返回值

一个代表顶点数组对象(VAO)的 WebGLVertexArrayObject,它指向顶点数组数据。

示例

js
const vao = gl.createVertexArray();
gl.bindVertexArray(vao);

// …

// calls to bindBuffer or vertexAttribPointer
// which will be "recorded" in the VAO

// …

规范

规范
WebGL 2.0 规范
# 3.7.17

浏览器兼容性

另见