Get to know MDN better
This example demonstrates how to detect a WebGL rendering context and reports the result to the user.
In this first example we are going to check whether the browser supports WebGL. To that end we will try to obtain the WebGL rendering context from a canvas element. The WebGL rendering context is an interface, through which you can set and query the state of the graphics machine, send data to the WebGL, and execute draw commands.
Saving the state of the graphics machine within a single context interface is not unique to WebGL. This is also done in other graphics API, such as the canvas 2D rendering context. However, the properties and variables you can tweak are different for each API.
The source code of this example is also available on GitHub.
This page was last modified on Sep 21, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.