Create a wrapper for a WebGL2 rendering context.
The rendering context.
DuplicateContextError if a Context
already exists for gl
.
Create a WebGL2 rendering context.
The canvas of the rendering context.
Optional
options: WebGLContextAttributesThe options to create the rendering context with if necessary.
Optional
doPrefillCache: booleanWhether or not cached values should be prefilled with their default values. It is recommended that this is set to true
unless the rendering context may have been modified prior to the creation of this object.
UnsupportedOperationError if a WebGL2 context cannot be created.
DuplicateContextError if a Context
already exists for canvas
.
Readonly
canvasThe canvas of this rendering context.
The RGB and alpha blend equations.
The alpha blend equation.
The RGB blend equation.
The source and destination RGB and alpha blend functions.
The destination alpha blend function.
The destination RGB blend function.
The source alpha blend function.
The source RGB blend function.
The value to store in the depth buffer when clearing it.
The value to store in the stencil buffer when clearing it.
The depth comparison function to use.
Whether or not the depth buffer can be written to.
Whether or not blending is enabled.
Whether or not polygon culling is enabled.
Whether or not depth testing is enabled.
Whether or not dithering is enabled.
Whether or not primitives are discarded immediately before the rasterization stage.
Whether or not the scissor test is enabled.
Whether or not stencil testing is enabled.
The color space of the drawing buffer of this rendering context.
The actual height of the drawing buffer of this rendering context.
The actual width of the drawing buffer of this rendering context.
The rotational orientation of front-facing polygons.
The maximum number of texture units that can be used. Effectively all systems support at least 8
.
The maximum number of draw buffers.
The maximum available anisotropy.
UnsupportedOperationError if the anisotropic filtering extension is not available.
The maximum dimensions of the viewport. Effectively all systems support at least [4096, 4096]
.
The alignment to use when unpacking pixel data from memory.
The viewport box, which specifies the affine transformation of coordinates from normalized device coordinates to window coordinates.
BadValueError if set larger than MAX_VIEWPORT_DIMS
.
Clear the specified buffers to the specified values.
The value to clear the color buffer to or a boolean to use the previous clear color.
The value to clear the depth buffer to or a boolean to use the previous clear depth.
The value to clear the stencil buffer to or a boolean to use the previous clear stencil.
The framebuffer to clear, or null
for the default framebuffer (canvas).
Enable the specified extension.
The extension.
The extension's implementation object.
Resize this rendering context's viewport to match the size of a drawing buffer.
Optional
framebuffer: FramebufferThe framebuffer to fit the size of, or undefined
for the default framebuffer (canvas).
BadValueError if the framebuffer is larger than MAX_VIEWPORT_DIMS
.
Resize this rendering context's canvas' drawing buffer to match its physical size and resizes the viewport to match the given framebuffer.
Optional
framebuffer: FramebufferThe framebuffer to fit the size of, or undefined
for the default framebuffer (canvas).
Whether or not the drawing buffer was resized.
BadValueError if the framebuffer is larger than MAX_VIEWPORT_DIMS
.
Resize this rendering context's canvas' drawing buffer to match its physical size and resizes the viewport to match the given size.
The rectangle that represents the viewport.
Whether or not the drawing buffer was resized.
BadValueError if the rectangle is larger than MAX_VIEWPORT_DIMS
.
Throw a JavaScript error if a WebGL error has occurred.
WebglError if a WebGL error has occurred.
Static
getCreate a Context
or get an existing Context
if one already exists for the given rendering context. This is preferable to calling the Context
constructor in cases where multiple Context
s may be created for the same canvas (i.e. in a Next.js page).
The rendering context.
A rendering context.
Create a Context
or get an existing Context
if one already exists for the given canvas. This is preferable to calling the Context
constructor in cases where multiple Context
s may be created for the same canvas (i.e. in a Next.js page).
The canvas of the rendering context.
Optional
options: WebGLContextAttributesThe options to create the rendering context with if necessary.
Optional
doPrefillCache: booleanWhether or not cached values should be prefilled with their default values. It is recommended that this is set to true
unless the rendering context may have been modified prior to the creation of this object.
A rendering context.
A WebGL2 rendering context.
See
WebGL2RenderingContext