WebGL2RenderingContext.beginQuery()

Experimental: 这是一个实验中的功能
此功能某些浏览器尚在开发中,请参考浏览器兼容性表格以得到在不同浏览器中适合使用的前缀。由于该功能对应的标准文档可能被重新修订,所以在未来版本的浏览器中该功能的语法和行为可能随之改变。

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.

例子

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

参考