This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

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:

var canvas = document.getElementById('myCanvas');
var gl = canvas.getContext('webgl2');

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.


See the WebGL constants page.

State information

Returns the indexed value for the given target.


Initializes and creates the buffer object's data store.
Updates a subset of a buffer object's data store.
Copies part of the data of a buffer to another buffer.
Reads data from a buffer and writes them to an ArrayBuffer or SharedArrayBuffer.


Transfers a block of pixels from the read framebuffer to the draw framebuffer.
Attaches a single layer of a texture to a framebuffer.
Invalidates the contents of attachments in a framebuffer.
Invalidates portions of the contents of attachments in a framebuffer
Selects a color buffer as the source for pixels.


Returns information about implementation-dependent support for internal formats.
Creates and initializes a renderbuffer object's data store and allows specifying the number of samples to be used.


Specifies all levels of two-dimensional texture storage.
Specifies all levels of a three-dimensional texture or two-dimensional array texture.
Specifies a three-dimensional texture image.
Specifies a sub-rectangle of the current 3D texture.
Copies pixels from the current WebGLFramebuffer into an existing 3D texture sub-image.
Specifies a three-dimensional texture image in a compressed format.
Specifies a three-dimensional sub-rectangle for a texture image in a compressed format.

Programs and shaders

Returns the binding of color numbers to user-defined varying out variables.

Uniforms and attributes

Methods specifying values of uniform variables.
Methods specifying matrix values for uniform variables.
Methods specifying integer values for generic vertex attributes.
Specifies integer data formats and locations of vertex attributes in a vertex attributes array.

Drawing buffers

Modifies the rate at which generic vertex attributes advance when rendering multiple instances of primitives with gl.drawArraysInstanced() and gl.drawElementsInstanced().
Renders primitives from array data. In addition, it can execute multiple instances of the range of elements.
Renders primitives from array data. In addition, it can execute multiple instances of a set of elements.
Renders primitives from array data in a given range.
Specifies a list of color buffers to be drawn into.
Clears buffers from the currently bound framebuffer.

Query objects

Methods for working with WebGLQuery objects.

Creates a new WebGLQuery object.
Deletes a given WebGLQuery object.
Returns true if a given object is a valid WebGLQuery object.
Begins an asynchronous query.
Marks the end of an asynchronous query.
Returns a WebGLQuery object for a given target.
Returns information about a query.

Sampler objects

Creates a new WebGLSampler object.
Deletes a given WebGLSampler object.
Binds a given WebGLSampler to a texture unit.
Returns true if a given object is a valid WebGLSampler object.
Sets sampler parameters.
Returns sampler parameter information.

Sync objects

Creates a new WebGLSync object and inserts it into the GL command stream.
Returns true if the passed object is a valid WebGLSync object.
Deletes a given WebGLSync object.

Blocks and waits for a WebGLSync object to become signaled or a given timeout to be passed.

Returns immediately, but waits on the GL server until the given WebGLSync object is signaled.
Returns parameter information of a WebGLSync object.

Transform feedback

Creates and initializes WebGLTransformFeedback objects.
Deletes a given WebGLTransformFeedback object.
Returns true if the passed object is a valid WebGLTransformFeedback object.
Binds a passed WebGLTransformFeedback object to the current GL state.
Starts a transform feedback operation.
Ends a transform feedback operation.
Specifies values to record in WebGLTransformFeedback buffers.
Returns information about varying variables from WebGLTransformFeedback buffers.
Pauses a transform feedback operation.
Resumes a transform feedback operation.

Uniform buffer objects

Binds a given WebGLBuffer to a given binding point (target) at a given index.
Binds a range of a given WebGLBuffer to a given binding point (target) at a given index.

Retrieves the indices of a number of uniforms within a WebGLProgram.

Retrieves information about active uniforms within a WebGLProgram.
Retrieves the index of a uniform block within a WebGLProgram.
Retrieves information about an active uniform block within a WebGLProgram.
Retrieves the name of the active uniform block at a given index within a WebGLProgram.
Assigns binding points for active uniform blocks.

Vertex array objects

Methods for working with WebGLVertexArrayObject (VAO) objects.

Creates a new WebGLVertexArrayObject.
Deletes a given WebGLVertexArrayObject.
Returns true if a given object is a valid WebGLVertexArrayObject.
Binds a given WebGLVertexArrayObject to the buffer.


Specification Status Comment
WebGL 2.0
The definition of 'WebGL2RenderingContext' in that specification.
Editor's Draft Initial definition.

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support56 No51 No43 No
beginQuery56 No51 No43 No
beginTransformFeedback56 No51 No43 No
bindBufferBase56 No51 No43 No
bindBufferRange56 No51 No43 No
bindSampler56 No51 No43 No
bindTransformFeedback56 No51 No43 No
bindVertexArray56 No51 No43 No
blitFramebuffer56 No51 No43 No
bufferSubData Yes No51 No Yes No
clearBufferfi56 No51 No43 No
clearBufferfv56 No51 No43 No
clearBufferiv56 No51 No43 No
clearBufferuiv56 No51 No43 No
clientWaitSync56 No51 No43 No
compressedTexImage3D56 No51 No43 No
compressedTexSubImage3D56 No51 No43 No
copyBufferSubData56 No51 No43 No
copyTexSubImage3D56 No51 No43 No
createQuery56 No51 No43 No
createSampler56 No51 No43 No
createTransformFeedback56 No51 No43 No
createVertexArray56 No51 No43 No
deleteQuery56 No51 No43 No
deleteSampler56 No51 No43 No
deleteSync56 No51 No43 No
deleteTransformFeedback56 No51 No43 No
deleteVertexArray56 No51 No43 No
drawArraysInstanced56 No51 No43 No
drawBuffers56 No51 No43 No
drawElementsInstanced56 No51 No43 No
drawRangeElements56 No51 No43 No
endQuery56 No51 No43 No
endTransformFeedback56 No51 No43 No
fenceSync56 No51 No43 No
framebufferTextureLayer56 No51 No43 No
getActiveUniformBlockName56 No51 No43 No
getActiveUniformBlockParameter56 No51 No43 No
getActiveUniforms56 No51 No43 No
getBufferSubData56 No51 No Yes No
getFragDataLocation56 No51 No43 No
getInternalformatParameter56 No51 No43 No
getQuery56 No51 No43 No
getQueryParameter56 No51 No43 No
getSamplerParameter56 No51 No43 No
getSyncParameter56 No51 No43 No
getTransformFeedbackVarying56 No51 No43 No
getUniformBlockIndex56 No51 No43 No
getUniformIndices56 No51 No43 No
getIndexedParameter56 No51 No43 No
invalidateFramebuffer56 No51 No43 No
invalidateSubFramebuffer56 No51 No43 No
isQuery56 No51 No43 No
isSampler56 No51 No43 No
isSync56 No51 No43 No
isTransformFeedback56 No51 No43 No
isVertexArray56 No51 No43 No
pauseTransformFeedback56 No51 No43 No
readBuffer56 No51 No43 No
renderbufferStorageMultisample56 No51 No43 No
resumeTransformFeedback56 No51 No43 No
samplerParameteri56 No51 No43 No
samplerParameterf56 No51 No43 No
texImage3D56 No51 No43 No
texStorage2D56 No51 No43 No
texStorage3D56 No51 No43 No
texSubImage3D56 No51 No43 No
transformFeedbackVaryings56 No51 No43 No
uniform1uiv56 No51 No43 No
uniform1ui56 No51 No43 No
uniform1i56 No51 No43 No
uniform1f56 No51 No43 No
uniform2uiv56 No51 No43 No
uniform2ui56 No51 No43 No
uniform2i56 No51 No43 No
uniform2f56 No51 No43 No
uniform3uiv56 No51 No43 No
uniform3ui56 No51 No43 No
uniform3i56 No51 No43 No
uniform3f56 No51 No43 No
uniform4uiv56 No51 No43 No
uniform4ui56 No51 No43 No
uniform4i56 No51 No43 No
uniform4f56 No51 No43 No
uniformBlockBinding56 No51 No43 No
uniformMatrix2fv56 No51 No43 No
uniformMatrix2x3fv56 No51 No43 No
uniformMatrix2x4fv56 No51 No43 No
uniformMatrix3fv56 No51 No43 No
uniformMatrix3x2fv56 No51 No43 No
uniformMatrix3x4fv56 No51 No43 No
uniformMatrix4fv56 No51 No43 No
uniformMatrix4x2fv56 No51 No43 No
uniformMatrix4x3fv56 No51 No43 No
vertexAttribDivisor56 No51 No43 No
vertexAttribI4i56 No51 No43 No
vertexAttribI4iv56 No51 No43 No
vertexAttribI4ui56 No51 No43 No
vertexAttribI4uiv56 No51 No43 No
vertexAttribIPointer56 No51 No43 No
waitSync56 No51 No43 No
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidIE mobileOpera AndroidiOS Safari
Basic support5858 No51 No43 No
beginQuery5858 No51 No43 No
beginTransformFeedback5858 No51 No43 No
bindBufferBase5858 No51 No43 No
bindBufferRange5858 No51 No43 No
bindSampler5858 No51 No43 No
bindTransformFeedback5858 No51 No43 No
bindVertexArray5858 No51 No43 No
blitFramebuffer5858 No51 No43 No
bufferSubData Yes Yes No51 No Yes No
clearBufferfi5858 No51 No43 No
clearBufferfv5858 No51 No43 No
clearBufferiv5858 No51 No43 No
clearBufferuiv5858 No51 No43 No
clientWaitSync5858 No51 No43 No
compressedTexImage3D5858 No51 No43 No
compressedTexSubImage3D5858 No51 No43 No
copyBufferSubData5858 No51 No43 No
copyTexSubImage3D5858 No51 No43 No
createQuery5858 No51 No43 No
createSampler5858 No51 No43 No
createTransformFeedback5858 No51 No43 No
createVertexArray5858 No51 No43 No
deleteQuery5858 No51 No43 No
deleteSampler5858 No51 No43 No
deleteSync5858 No51 No43 No
deleteTransformFeedback5858 No51 No43 No
deleteVertexArray5858 No51 No43 No
drawArraysInstanced5858 No51 No43 No
drawBuffers5858 No51 No43 No
drawElementsInstanced5858 No51 No43 No
drawRangeElements5858 No51 No43 No
endQuery5858 No51 No43 No
endTransformFeedback5858 No51 No43 No
fenceSync5858 No51 No43 No
framebufferTextureLayer5858 No51 No43 No
getActiveUniformBlockName5858 No51 No43 No
getActiveUniformBlockParameter5858 No51 No43 No
getActiveUniforms5858 No51 No43 No
getBufferSubData5858 No51 No Yes No
getFragDataLocation5858 No51 No43 No
getInternalformatParameter5858 No51 No43 No
getQuery5858 No51 No43 No
getQueryParameter5858 No51 No43 No
getSamplerParameter5858 No51 No43 No
getSyncParameter5858 No51 No43 No
getTransformFeedbackVarying5858 No51 No43 No
getUniformBlockIndex5858 No51 No43 No
getUniformIndices5858 No51 No43 No
getIndexedParameter5858 No51 No43 No
invalidateFramebuffer5858 No51 No43 No
invalidateSubFramebuffer5858 No51 No43 No
isQuery5858 No51 No43 No
isSampler5858 No51 No43 No
isSync5858 No51 No43 No
isTransformFeedback5858 No51 No43 No
isVertexArray5858 No51 No43 No
pauseTransformFeedback5858 No51 No43 No
readBuffer5858 No51 No43 No
renderbufferStorageMultisample5858 No51 No43 No
resumeTransformFeedback5858 No51 No43 No
samplerParameteri5858 No51 No43 No
samplerParameterf5858 No51 No43 No
texImage3D5858 No51 No43 No
texStorage2D5858 No51 No43 No
texStorage3D5858 No51 No43 No
texSubImage3D5858 No51 No43 No
transformFeedbackVaryings5858 No51 No43 No
uniform1uiv5858 No51 No43 No
uniform1ui5858 No51 No43 No
uniform1i5858 No51 No43 No
uniform1f5858 No51 No43 No
uniform2uiv5858 No51 No43 No
uniform2ui5858 No51 No43 No
uniform2i5858 No51 No43 No
uniform2f5858 No51 No43 No
uniform3uiv5858 No51 No43 No
uniform3ui5858 No51 No43 No
uniform3i5858 No51 No43 No
uniform3f5858 No51 No43 No
uniform4uiv5858 No51 No43 No
uniform4ui5858 No51 No43 No
uniform4i5858 No51 No43 No
uniform4f5858 No51 No43 No
uniformBlockBinding5858 No51 No43 No
uniformMatrix2fv5858 No51 No43 No
uniformMatrix2x3fv5858 No51 No43 No
uniformMatrix2x4fv5858 No51 No43 No
uniformMatrix3fv5858 No51 No43 No
uniformMatrix3x2fv5858 No51 No43 No
uniformMatrix3x4fv5858 No51 No43 No
uniformMatrix4fv5858 No51 No43 No
uniformMatrix4x2fv5858 No51 No43 No
uniformMatrix4x3fv5858 No51 No43 No
vertexAttribDivisor5858 No51 No43 No
vertexAttribI4i5858 No51 No43 No
vertexAttribI4iv5858 No51 No43 No
vertexAttribI4ui5858 No51 No43 No
vertexAttribI4uiv5858 No51 No43 No
vertexAttribIPointer5858 No51 No43 No
waitSync5858 No51 No43 No

See also

Document Tags and Contributors

 Contributors to this page: fscholz, jpmedley, teoli
 Last updated by: fscholz,