WebGL2RenderingContext.beginQuery()

实验性: 这是一项实验性技术
在将其用于生产之前,请仔细检查浏览器兼容性表格

WebGL 2 API 的**WebGL2RenderingContext.beginQuery()** 方法启动一个异步查询,target 参数表明是哪种类型的查询。

语法

void gl.beginQuery(target, query);

参数

target

GLenum (en-US) 指定查询个的 target,可能的值有:

  • gl.ANY_SAMPLES_PASSED: Specifies an occlusion query: these queries detect whether an object is visible (whether the scoped drawing commands pass the depth test and if so, how many samples pass).
  • gl.ANY_SAMPLES_PASSED_CONSERVATIVE: 和以上一样,但是是一个不精确和更快的版本。
  • gl.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN: Number of primitives that are written to transform feedback buffers.
query

一个WebGLQuery 对象用于查询。

返回值

None.

例子

js
var query = gl.createQuery();
gl.beginQuery(gl.ANY_SAMPLES_PASSED, query);

// ...

规范

Specification
WebGL 2.0 Specification
# 3.7.12

浏览器兼容性

BCD tables only load in the browser

参考