files/en-us/web/api/webglrenderingcontext/index.md
{{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.
See the WebGL constants page.
The following properties and methods provide general information and functionality to deal with the WebGL context:
null if it is not associated with a {{HTMLElement("canvas")}} element.WebGLContextAttributes object that contains the actual context parameters. Might return null, if the context is lost.true if the context is lost, otherwise returns false.WebGLBuffer object to a given target.WebGLBuffer object.WebGLBuffer object.WebGLFrameBuffer object to a given target.WebGLFrameBuffer object.WebGLFrameBuffer object.WebGLRenderingBuffer object to a WebGLFrameBuffer object.WebGLFrameBuffer object.WebGLFrameBuffer object is valid.WebGLFrameBuffer.WebGLRenderBuffer object to a given target.WebGLRenderBuffer object.WebGLRenderBuffer object.WebGLRenderingBuffer is valid.WebGLTexture object to a given target.WebGLTexture object.WebGLTexture object.WebGLTexture object.WebGLTexture is valid.WebGLTexture.WebGLShader to a WebGLProgram.WebGLShader.WebGLProgram.WebGLShader.WebGLProgram.WebGLShader.WebGLShader.WebGLShader objects attached to a WebGLProgram.WebGLProgram object.WebGLShaderPrecisionFormat object describing the precision for the numeric format of the shader.WebGLShader object.WebGLShader as a string.WebGLProgram is valid.WebGLShader is valid.WebGLProgram object.WebGLShader.WebGLProgram as part the current rendering state.WebGLProgram.WebGLRenderingContext.uniform[1234][fi][v]()
These methods manage WebGL extensions:
{{Specifications}}
{{Compat}}