--- title: WebGL2RenderingContext.beginQuery() slug: Web/API/WebGL2RenderingContext/beginQuery translation_of: Web/API/WebGL2RenderingContext/beginQuery ---
WebGL 2 API 的WebGL2RenderingContext.beginQuery()
方法启动一个异步查询,target
参数表明是哪种类型的查询。
void gl.beginQuery(target, query);
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
None.
var query = gl.createQuery(); gl.beginQuery(gl.ANY_SAMPLES_PASSED, query); // ...
Specification | Status | Comment |
---|---|---|
{{SpecName('WebGL2', "#3.7.12", "beginQuery")}} | {{Spec2('WebGL2')}} | Initial definition. |
{{SpecName('OpenGL ES 3.0', "glBeginQuery.xhtml", "glBeginQuery")}} | {{Spec2('OpenGL ES 3.0')}} | Man page of the (similar) OpenGL API. |
{{Compat("api.WebGL2RenderingContext.beginQuery")}}