Firefox Tomorrow

web api interface

WebGL2RenderingContext

View on MDN ↗

Available in workers

The WebGL2RenderingContext interface provides the OpenGL ES 3.0 rendering context for the drawing surface of an HTML <canvas> element.

To get an object of this interface, call getContext() on a <canvas> element, supplying “webgl2” as the argument:

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

[!NOTE] WebGL 2 is an extension to WebGL 1. The WebGL2RenderingContext interface implements all members of the WebGLRenderingContext interface. Some methods of the WebGL 1 context can accept additional values when used in a WebGL 2 context. You will find this info noted on the WebGL 1 reference pages.

The WebGL tutorial has more information, examples, and resources on how to get started with WebGL.

Constants

See the WebGL constants page.

State information

Buffers

Framebuffers

Renderbuffers

Textures

Programs and shaders

Uniforms and attributes

Color spaces

Drawing buffers

Query objects

Methods for working with WebGLQuery objects.

Sampler objects

Sync objects

Transform feedback

Uniform buffer objects

Vertex array objects

Methods for working with WebGLVertexArrayObject (VAO) objects.

Specifications

SpecificationsStandards references are available on the canonical MDN page.

Browser compatibility

Browser compatibilityCompatibility data is available on the canonical MDN page.

See also