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.
WebGL2RenderingContext.getIndexedParameter()
target
.WebGL2RenderingContext.bufferData()
WebGL2RenderingContext.bufferSubData()
WebGL2RenderingContext.copyBufferSubData()
WebGL2RenderingContext.getBufferSubData()
ArrayBuffer
or SharedArrayBuffer
.WebGL2RenderingContext.blitFramebuffer()
WebGL2RenderingContext.framebufferTextureLayer()
WebGL2RenderingContext.invalidateFramebuffer()
WebGL2RenderingContext.invalidateSubFramebuffer()
WebGL2RenderingContext.readBuffer()
WebGL2RenderingContext.getInternalformatParameter()
WebGL2RenderingContext.renderbufferStorageMultisample()
WebGL2RenderingContext.texStorage2D()
WebGL2RenderingContext.texStorage3D()
WebGL2RenderingContext.texImage3D()
WebGL2RenderingContext.texSubImage3D()
WebGL2RenderingContext.copyTexSubImage3D()
WebGLFramebuffer
into an existing 3D texture sub-image.WebGL2RenderingContext.compressedTexImage3D()
WebGL2RenderingContext.compressedTexSubImage3D()
WebGL2RenderingContext.getFragDataLocation()
WebGL2RenderingContext.uniform[1234][uif][v]()
WebGL2RenderingContext.uniformMatrix[234]x[234]fv()
WebGL2RenderingContext.vertexAttribI4[u]i[v]()
WebGL2RenderingContext.vertexAttribIPointer()
WebGL2RenderingContext.vertexAttribDivisor()
gl.drawArraysInstanced()
and gl.drawElementsInstanced()
.WebGL2RenderingContext.drawArraysInstanced()
WebGL2RenderingContext.drawElementsInstanced()
WebGL2RenderingContext.drawRangeElements()
WebGL2RenderingContext.drawBuffers()
WebGL2RenderingContext.clearBuffer[fiuv]()
Methods for working with WebGLQuery
objects.
WebGL2RenderingContext.createQuery()
WebGLQuery
object.WebGL2RenderingContext.deleteQuery()
WebGLQuery
object.WebGL2RenderingContext.isQuery()
true
if a given object is a valid WebGLQuery
object.WebGL2RenderingContext.beginQuery()
WebGL2RenderingContext.endQuery()
WebGL2RenderingContext.getQuery()
WebGLQuery
object for a given target.WebGL2RenderingContext.getQueryParameter()
WebGL2RenderingContext.createSampler()
WebGLSampler
object.WebGL2RenderingContext.deleteSampler()
WebGLSampler
object.WebGL2RenderingContext.bindSampler()
WebGLSampler
to a texture unit.WebGL2RenderingContext.isSampler()
true
if a given object is a valid WebGLSampler
object.WebGL2RenderingContext.samplerParameter[if]()
WebGL2RenderingContext.getSamplerParameter()
WebGL2RenderingContext.fenceSync()
WebGLSync
object and inserts it into the GL command stream.WebGL2RenderingContext.isSync()
true
if the passed object is a valid WebGLSync
object.WebGL2RenderingContext.deleteSync()
WebGLSync
object.WebGL2RenderingContext.clientWaitSync()
Blocks and waits for a WebGLSync
object to become signaled or a given timeout to be passed.
WebGL2RenderingContext.waitSync()
WebGLSync
object is signaled.WebGL2RenderingContext.getSyncParameter()
WebGLSync
object.WebGL2RenderingContext.createTransformFeedback()
WebGLTransformFeedback
objects.WebGL2RenderingContext.deleteTransformFeedback()
WebGLTransformFeedback
object.WebGL2RenderingContext.isTransformFeedback()
true
if the passed object is a valid WebGLTransformFeedback
object.WebGL2RenderingContext.bindTransformFeedback()
WebGLTransformFeedback
object to the current GL state.WebGL2RenderingContext.beginTransformFeedback()
WebGL2RenderingContext.endTransformFeedback()
WebGL2RenderingContext.transformFeedbackVaryings()
WebGLTransformFeedback
buffers.WebGL2RenderingContext.getTransformFeedbackVarying()
WebGLTransformFeedback
buffers.WebGL2RenderingContext.pauseTransformFeedback()
WebGL2RenderingContext.resumeTransformFeedback()
WebGL2RenderingContext.bindBufferBase()
WebGLBuffer
to a given binding point (target
) at a given index
.WebGL2RenderingContext.bindBufferRange()
WebGLBuffer
to a given binding point (target
) at a given index
.WebGL2RenderingContext.getUniformIndices()
Retrieves the indices of a number of uniforms within a WebGLProgram
.
WebGL2RenderingContext.getActiveUniforms()
WebGLProgram
.WebGL2RenderingContext.getUniformBlockIndex()
WebGLProgram
.WebGL2RenderingContext.getActiveUniformBlockParameter()
WebGLProgram
.WebGL2RenderingContext.getActiveUniformBlockName()
WebGLProgram
.WebGL2RenderingContext.uniformBlockBinding()
Methods for working with WebGLVertexArrayObject
(VAO) objects.
WebGL2RenderingContext.createVertexArray()
WebGLVertexArrayObject
.WebGL2RenderingContext.deleteVertexArray()
WebGLVertexArrayObject
.WebGL2RenderingContext.isVertexArray()
true
if a given object is a valid WebGLVertexArrayObject
.WebGL2RenderingContext.bindVertexArray()
WebGLVertexArrayObject
to the buffer.Specification | Status | Comment |
---|---|---|
WebGL 2.0 The definition of 'WebGL2RenderingContext' in that specification. | Editor's Draft | Initial definition. |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | 56 | No | 51 | No | 43 | No |
beginQuery |
56 | No | 51 | No | 43 | No |
beginTransformFeedback |
56 | No | 51 | No | 43 | No |
bindBufferBase |
56 | No | 51 | No | 43 | No |
bindBufferRange |
56 | No | 51 | No | 43 | No |
bindSampler |
56 | No | 51 | No | 43 | No |
bindTransformFeedback |
56 | No | 51 | No | 43 | No |
bindVertexArray |
56 | No | 51 | No | 43 | No |
blitFramebuffer |
56 | No | 51 | No | 43 | No |
bufferSubData |
Yes | No | 51 | No | Yes | No |
clearBufferfi |
56 | No | 51 | No | 43 | No |
clearBufferfv |
56 | No | 51 | No | 43 | No |
clearBufferiv |
56 | No | 51 | No | 43 | No |
clearBufferuiv |
56 | No | 51 | No | 43 | No |
clientWaitSync |
56 | No | 51 | No | 43 | No |
compressedTexImage3D |
56 | No | 51 | No | 43 | No |
compressedTexSubImage3D |
56 | No | 51 | No | 43 | No |
copyBufferSubData |
56 | No | 51 | No | 43 | No |
copyTexSubImage3D |
56 | No | 51 | No | 43 | No |
createQuery |
56 | No | 51 | No | 43 | No |
createSampler |
56 | No | 51 | No | 43 | No |
createTransformFeedback |
56 | No | 51 | No | 43 | No |
createVertexArray |
56 | No | 51 | No | 43 | No |
deleteQuery |
56 | No | 51 | No | 43 | No |
deleteSampler |
56 | No | 51 | No | 43 | No |
deleteSync |
56 | No | 51 | No | 43 | No |
deleteTransformFeedback |
56 | No | 51 | No | 43 | No |
deleteVertexArray |
56 | No | 51 | No | 43 | No |
drawArraysInstanced |
56 | No | 51 | No | 43 | No |
drawBuffers |
56 | No | 51 | No | 43 | No |
drawElementsInstanced |
56 | No | 51 | No | 43 | No |
drawRangeElements |
56 | No | 51 | No | 43 | No |
endQuery |
56 | No | 51 | No | 43 | No |
endTransformFeedback |
56 | No | 51 | No | 43 | No |
fenceSync |
56 | No | 51 | No | 43 | No |
framebufferTextureLayer |
56 | No | 51 | No | 43 | No |
getActiveUniformBlockName |
56 | No | 51 | No | 43 | No |
getActiveUniformBlockParameter |
56 | No | 51 | No | 43 | No |
getActiveUniforms |
56 | No | 51 | No | 43 | No |
getBufferSubData |
56 | No | 51 | No | Yes | No |
getFragDataLocation |
56 | No | 51 | No | 43 | No |
getInternalformatParameter |
56 | No | 51 | No | 43 | No |
getQuery |
56 | No | 51 | No | 43 | No |
getQueryParameter |
56 | No | 51 | No | 43 | No |
getSamplerParameter |
56 | No | 51 | No | 43 | No |
getSyncParameter |
56 | No | 51 | No | 43 | No |
getTransformFeedbackVarying |
56 | No | 51 | No | 43 | No |
getUniformBlockIndex |
56 | No | 51 | No | 43 | No |
getUniformIndices |
56 | No | 51 | No | 43 | No |
getIndexedParameter |
56 | No | 51 | No | 43 | No |
invalidateFramebuffer |
56 | No | 51 | No | 43 | No |
invalidateSubFramebuffer |
56 | No | 51 | No | 43 | No |
isQuery |
56 | No | 51 | No | 43 | No |
isSampler |
56 | No | 51 | No | 43 | No |
isSync |
56 | No | 51 | No | 43 | No |
isTransformFeedback |
56 | No | 51 | No | 43 | No |
isVertexArray |
56 | No | 51 | No | 43 | No |
pauseTransformFeedback |
56 | No | 51 | No | 43 | No |
readBuffer |
56 | No | 51 | No | 43 | No |
renderbufferStorageMultisample |
56 | No | 51 | No | 43 | No |
resumeTransformFeedback |
56 | No | 51 | No | 43 | No |
samplerParameteri |
56 | No | 51 | No | 43 | No |
samplerParameterf |
56 | No | 51 | No | 43 | No |
texImage3D |
56 | No | 51 | No | 43 | No |
texStorage2D |
56 | No | 51 | No | 43 | No |
texStorage3D |
56 | No | 51 | No | 43 | No |
texSubImage3D |
56 | No | 51 | No | 43 | No |
transformFeedbackVaryings |
56 | No | 51 | No | 43 | No |
uniform1uiv |
56 | No | 51 | No | 43 | No |
uniform1ui |
56 | No | 51 | No | 43 | No |
uniform1i |
56 | No | 51 | No | 43 | No |
uniform1f |
56 | No | 51 | No | 43 | No |
uniform2uiv |
56 | No | 51 | No | 43 | No |
uniform2ui |
56 | No | 51 | No | 43 | No |
uniform2i |
56 | No | 51 | No | 43 | No |
uniform2f |
56 | No | 51 | No | 43 | No |
uniform3uiv |
56 | No | 51 | No | 43 | No |
uniform3ui |
56 | No | 51 | No | 43 | No |
uniform3i |
56 | No | 51 | No | 43 | No |
uniform3f |
56 | No | 51 | No | 43 | No |
uniform4uiv |
56 | No | 51 | No | 43 | No |
uniform4ui |
56 | No | 51 | No | 43 | No |
uniform4i |
56 | No | 51 | No | 43 | No |
uniform4f |
56 | No | 51 | No | 43 | No |
uniformBlockBinding |
56 | No | 51 | No | 43 | No |
uniformMatrix2fv |
56 | No | 51 | No | 43 | No |
uniformMatrix2x3fv |
56 | No | 51 | No | 43 | No |
uniformMatrix2x4fv |
56 | No | 51 | No | 43 | No |
uniformMatrix3fv |
56 | No | 51 | No | 43 | No |
uniformMatrix3x2fv |
56 | No | 51 | No | 43 | No |
uniformMatrix3x4fv |
56 | No | 51 | No | 43 | No |
uniformMatrix4fv |
56 | No | 51 | No | 43 | No |
uniformMatrix4x2fv |
56 | No | 51 | No | 43 | No |
uniformMatrix4x3fv |
56 | No | 51 | No | 43 | No |
vertexAttribDivisor |
56 | No | 51 | No | 43 | No |
vertexAttribI4i |
56 | No | 51 | No | 43 | No |
vertexAttribI4iv |
56 | No | 51 | No | 43 | No |
vertexAttribI4ui |
56 | No | 51 | No | 43 | No |
vertexAttribI4uiv |
56 | No | 51 | No | 43 | No |
vertexAttribIPointer |
56 | No | 51 | No | 43 | No |
waitSync |
56 | No | 51 | No | 43 | No |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | 58 | 58 | No | 51 | 43 | No | 7.0 |
beginQuery |
58 | 58 | No | 51 | 43 | No | 7.0 |
beginTransformFeedback |
58 | 58 | No | 51 | 43 | No | 7.0 |
bindBufferBase |
58 | 58 | No | 51 | 43 | No | 7.0 |
bindBufferRange |
58 | 58 | No | 51 | 43 | No | 7.0 |
bindSampler |
58 | 58 | No | 51 | 43 | No | 7.0 |
bindTransformFeedback |
58 | 58 | No | 51 | 43 | No | 7.0 |
bindVertexArray |
58 | 58 | No | 51 | 43 | No | 7.0 |
blitFramebuffer |
58 | 58 | No | 51 | 43 | No | 7.0 |
bufferSubData |
Yes | Yes | No | 51 | Yes | No | Yes |
clearBufferfi |
58 | 58 | No | 51 | 43 | No | 7.0 |
clearBufferfv |
58 | 58 | No | 51 | 43 | No | 7.0 |
clearBufferiv |
58 | 58 | No | 51 | 43 | No | 7.0 |
clearBufferuiv |
58 | 58 | No | 51 | 43 | No | 7.0 |
clientWaitSync |
58 | 58 | No | 51 | 43 | No | 7.0 |
compressedTexImage3D |
58 | 58 | No | 51 | 43 | No | 7.0 |
compressedTexSubImage3D |
58 | 58 | No | 51 | 43 | No | 7.0 |
copyBufferSubData |
58 | 58 | No | 51 | 43 | No | 7.0 |
copyTexSubImage3D |
58 | 58 | No | 51 | 43 | No | 7.0 |
createQuery |
58 | 58 | No | 51 | 43 | No | 7.0 |
createSampler |
58 | 58 | No | 51 | 43 | No | 7.0 |
createTransformFeedback |
58 | 58 | No | 51 | 43 | No | 7.0 |
createVertexArray |
58 | 58 | No | 51 | 43 | No | 7.0 |
deleteQuery |
58 | 58 | No | 51 | 43 | No | 7.0 |
deleteSampler |
58 | 58 | No | 51 | 43 | No | 7.0 |
deleteSync |
58 | 58 | No | 51 | 43 | No | 7.0 |
deleteTransformFeedback |
58 | 58 | No | 51 | 43 | No | 7.0 |
deleteVertexArray |
58 | 58 | No | 51 | 43 | No | 7.0 |
drawArraysInstanced |
58 | 58 | No | 51 | 43 | No | 7.0 |
drawBuffers |
58 | 58 | No | 51 | 43 | No | 7.0 |
drawElementsInstanced |
58 | 58 | No | 51 | 43 | No | 7.0 |
drawRangeElements |
58 | 58 | No | 51 | 43 | No | 7.0 |
endQuery |
58 | 58 | No | 51 | 43 | No | 7.0 |
endTransformFeedback |
58 | 58 | No | 51 | 43 | No | 7.0 |
fenceSync |
58 | 58 | No | 51 | 43 | No | 7.0 |
framebufferTextureLayer |
58 | 58 | No | 51 | 43 | No | 7.0 |
getActiveUniformBlockName |
58 | 58 | No | 51 | 43 | No | 7.0 |
getActiveUniformBlockParameter |
58 | 58 | No | 51 | 43 | No | 7.0 |
getActiveUniforms |
58 | 58 | No | 51 | 43 | No | 7.0 |
getBufferSubData |
58 | 58 | No | 51 | Yes | No | 7.0 |
getFragDataLocation |
58 | 58 | No | 51 | 43 | No | 7.0 |
getInternalformatParameter |
58 | 58 | No | 51 | 43 | No | 7.0 |
getQuery |
58 | 58 | No | 51 | 43 | No | 7.0 |
getQueryParameter |
58 | 58 | No | 51 | 43 | No | 7.0 |
getSamplerParameter |
58 | 58 | No | 51 | 43 | No | 7.0 |
getSyncParameter |
58 | 58 | No | 51 | 43 | No | 7.0 |
getTransformFeedbackVarying |
58 | 58 | No | 51 | 43 | No | 7.0 |
getUniformBlockIndex |
58 | 58 | No | 51 | 43 | No | 7.0 |
getUniformIndices |
58 | 58 | No | 51 | 43 | No | 7.0 |
getIndexedParameter |
58 | 58 | No | 51 | 43 | No | 7.0 |
invalidateFramebuffer |
58 | 58 | No | 51 | 43 | No | 7.0 |
invalidateSubFramebuffer |
58 | 58 | No | 51 | 43 | No | 7.0 |
isQuery |
58 | 58 | No | 51 | 43 | No | 7.0 |
isSampler |
58 | 58 | No | 51 | 43 | No | 7.0 |
isSync |
58 | 58 | No | 51 | 43 | No | 7.0 |
isTransformFeedback |
58 | 58 | No | 51 | 43 | No | 7.0 |
isVertexArray |
58 | 58 | No | 51 | 43 | No | 7.0 |
pauseTransformFeedback |
58 | 58 | No | 51 | 43 | No | 7.0 |
readBuffer |
58 | 58 | No | 51 | 43 | No | 7.0 |
renderbufferStorageMultisample |
58 | 58 | No | 51 | 43 | No | 7.0 |
resumeTransformFeedback |
58 | 58 | No | 51 | 43 | No | 7.0 |
samplerParameteri |
58 | 58 | No | 51 | 43 | No | 7.0 |
samplerParameterf |
58 | 58 | No | 51 | 43 | No | 7.0 |
texImage3D |
58 | 58 | No | 51 | 43 | No | 7.0 |
texStorage2D |
58 | 58 | No | 51 | 43 | No | 7.0 |
texStorage3D |
58 | 58 | No | 51 | 43 | No | 7.0 |
texSubImage3D |
58 | 58 | No | 51 | 43 | No | 7.0 |
transformFeedbackVaryings |
58 | 58 | No | 51 | 43 | No | 7.0 |
uniform1uiv |
58 | 58 | No | 51 | 43 | No | 7.0 |
uniform1ui |
58 | 58 | No | 51 | 43 | No | 7.0 |
uniform1i |
58 | 58 | No | 51 | 43 | No | 7.0 |
uniform1f |
58 | 58 | No | 51 | 43 | No | 7.0 |
uniform2uiv |
58 | 58 | No | 51 | 43 | No | 7.0 |
uniform2ui |
58 | 58 | No | 51 | 43 | No | 7.0 |
uniform2i |
58 | 58 | No | 51 | 43 | No | 7.0 |
uniform2f |
58 | 58 | No | 51 | 43 | No | 7.0 |
uniform3uiv |
58 | 58 | No | 51 | 43 | No | 7.0 |
uniform3ui |
58 | 58 | No | 51 | 43 | No | 7.0 |
uniform3i |
58 | 58 | No | 51 | 43 | No | 7.0 |
uniform3f |
58 | 58 | No | 51 | 43 | No | 7.0 |
uniform4uiv |
58 | 58 | No | 51 | 43 | No | 7.0 |
uniform4ui |
58 | 58 | No | 51 | 43 | No | 7.0 |
uniform4i |
58 | 58 | No | 51 | 43 | No | 7.0 |
uniform4f |
58 | 58 | No | 51 | 43 | No | 7.0 |
uniformBlockBinding |
58 | 58 | No | 51 | 43 | No | 7.0 |
uniformMatrix2fv |
58 | 58 | No | 51 | 43 | No | 7.0 |
uniformMatrix2x3fv |
58 | 58 | No | 51 | 43 | No | 7.0 |
uniformMatrix2x4fv |
58 | 58 | No | 51 | 43 | No | 7.0 |
uniformMatrix3fv |
58 | 58 | No | 51 | 43 | No | 7.0 |
uniformMatrix3x2fv |
58 | 58 | No | 51 | 43 | No | 7.0 |
uniformMatrix3x4fv |
58 | 58 | No | 51 | 43 | No | 7.0 |
uniformMatrix4fv |
58 | 58 | No | 51 | 43 | No | 7.0 |
uniformMatrix4x2fv |
58 | 58 | No | 51 | 43 | No | 7.0 |
uniformMatrix4x3fv |
58 | 58 | No | 51 | 43 | No | 7.0 |
vertexAttribDivisor |
58 | 58 | No | 51 | 43 | No | 7.0 |
vertexAttribI4i |
58 | 58 | No | 51 | 43 | No | 7.0 |
vertexAttribI4iv |
58 | 58 | No | 51 | 43 | No | 7.0 |
vertexAttribI4ui |
58 | 58 | No | 51 | 43 | No | 7.0 |
vertexAttribI4uiv |
58 | 58 | No | 51 | 43 | No | 7.0 |
vertexAttribIPointer |
58 | 58 | No | 51 | 43 | No | 7.0 |
waitSync |
58 | 58 | No | 51 | 43 | No | 7.0 |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext