WebGL2RenderingContext.beginQuery()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2021.

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

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

语法

void gl.beginQuery(target, query);

参数

target

GLenum 指定查询个的 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

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
beginQuery

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

参考