docs.rodeo

MDN Web Docs mirror

WebGLRenderingContext

{{APIRef("WebGL")}} {{AvailableInWorkers}} 

The WebGLRenderingContext interface provides an interface to the OpenGL ES 2.0 graphics rendering context for the drawing surface of an HTML {{HTMLElement("canvas")}}  element.

To get an access to a WebGL context for 2D and/or 3D graphics rendering, call {{domxref("HTMLCanvasElement.getContext()", "getContext()")}}  on a <canvas> element, supplying “webgl” as the argument:

const canvas = document.getElementById("myCanvas");
const gl = canvas.getContext("webgl");

Once you have the WebGL rendering context for a canvas, you can render within it. The WebGL tutorial has more information, examples, and resources on how to get started with WebGL.

If you require a WebGL 2.0 context, see {{domxref("WebGL2RenderingContext")}} ; this supplies access to an implementation of OpenGL ES 3.0 graphics.

Constants

See the WebGL constants page.

The WebGL context

The following properties and methods provide general information and functionality to deal with the WebGL context:

Viewing and clipping

State information

Buffers

Framebuffers

Renderbuffers

Textures

Programs and shaders

Uniforms and attributes

Drawing buffers

Color spaces

Working with extensions

These methods manage WebGL extensions:

Specifications

{{Specifications}} 

Browser compatibility

{{Compat}} 

See also

In this article

View on MDN