Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 1031652 of WebGLQuery

  • Revision slug: Web/API/WebGLQuery
  • Revision title: WebGLQuery
  • Revision id: 1031652
  • Created:
  • Creator: fscholz
  • Is current revision? Yes
  • Comment

Revision Content

{{APIRef("WebGL")}} {{SeeCompatTable}}

The WebGLQuery interface is part of the WebGL 2 API and provides ways to asynchronously query for information. By default, occlusion queries and primitive queries are available.

Another kind of queries are disjoint timer queries, which allow you to measure performance and profiling of your GPU. Disjoint timer queries are available with the {{domxref("EXT_disjoint_timer_query")}} extension only.

When working with WebGLQuery objects, the following methods of the {{domxref("WebGL2RenderingContext")}} are useful:

  • {{domxref("WebGL2RenderingContext.createQuery()")}}
  • {{domxref("WebGL2RenderingContext.deleteQuery()")}}
  • {{domxref("WebGL2RenderingContext.isQuery()")}}
  • {{domxref("WebGL2RenderingContext.beginQuery()")}}
  • {{domxref("WebGL2RenderingContext.endQuery()")}}
  • {{domxref("WebGL2RenderingContext.getQuery()")}}
  • {{domxref("WebGL2RenderingContext.getQueryParameter()")}}

Examples

Creating a WebGLQuery object

in this example, gl must be a {{domxref("WebGL2RenderingContext")}}. WebGLQuery objects are not available in WebGL 1.

var query = gl.createQuery();

Specifications

Specification Status Comment
{{SpecName('WebGL2', "#3.2", "WebGLQuery")}} {{Spec2('WebGL2')}} Initial definition.

Browser compatibility

{{CompatibilityTable}}
Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{CompatNo}} [2] {{CompatNightly}} [1] {{CompatNo}} {{CompatNo}} {{CompatNo}}
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{CompatNo}} {{CompatNo}} {{CompatNo}} {{CompatNo}} {{CompatNo}} {{CompatNo}}

[1] WebGL 2 is enabled by default in Firefox Nightly. To enable it in a release version of Firefox, set the preference webgl.enable-prototype-webgl2 to true in about:config.

[2] To use an experimental implementation of WebGL 2 in Chrome, you have to start Chrome with the runtime flag --enable-unsafe-es3-apis.

See also

  • {{domxref("EXT_disjoint_timer_query")}}

Revision Source

<div>{{APIRef("WebGL")}} {{SeeCompatTable}}</div>

<p>The <strong><code>WebGLQuery</code></strong> interface is part of the <a href="/en-US/docs/Web/API/WebGL_API">WebGL 2</a> API and provides ways to asynchronously query for information. By default, occlusion queries and primitive queries are available.</p>

<p>Another kind of queries are disjoint timer queries, which allow you to measure performance and profiling of your GPU. Disjoint timer queries are available with the {{domxref("EXT_disjoint_timer_query")}} extension only.</p>

<p>When working with <code>WebGLQuery</code> objects, the following methods of the {{domxref("WebGL2RenderingContext")}} are useful:</p>

<ul>
 <li>{{domxref("WebGL2RenderingContext.createQuery()")}}</li>
 <li>{{domxref("WebGL2RenderingContext.deleteQuery()")}}</li>
 <li>{{domxref("WebGL2RenderingContext.isQuery()")}}</li>
 <li>{{domxref("WebGL2RenderingContext.beginQuery()")}}</li>
 <li>{{domxref("WebGL2RenderingContext.endQuery()")}}</li>
 <li>{{domxref("WebGL2RenderingContext.getQuery()")}}</li>
 <li>{{domxref("WebGL2RenderingContext.getQueryParameter()")}}</li>
</ul>

<h2 id="Examples">Examples</h2>

<h3>Creating a <code>WebGLQuery</code> object</h3>

<p>in this example, <code>gl</code> must be a {{domxref("WebGL2RenderingContext")}}. <code>WebGLQuery</code> objects are not available in WebGL 1.</p>

<pre class="brush: js">
var query = gl.createQuery();
</pre>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('WebGL2', "#3.2", "WebGLQuery")}}</td>
   <td>{{Spec2('WebGL2')}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<div>{{CompatibilityTable}}</div>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatNo}} [2]</td>
   <td>{{CompatNightly}} [1]</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Chrome for Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
  </tr>
 </tbody>
</table>
</div>

<p>[1] WebGL 2 is enabled by default in Firefox Nightly. To enable it in a release version of Firefox, set the preference <code>webgl.enable-prototype-webgl2</code> to <code>true</code> in about:config.</p>

<p>[2] To use an experimental implementation of WebGL 2 in Chrome, you have to start Chrome with the runtime flag <code>--enable-unsafe-es3-apis</code>.</p>

<h2 id="See_also">See also</h2>

<ul>
 <li>{{domxref("EXT_disjoint_timer_query")}}</li>
</ul>
Revert to this revision