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 attributes of this rendering context, or null
if this rendering context is lost.
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.
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 adding an offset to depth values of polygon fragments is enabled.
Whether or not primitives are discarded immediately before the rasterization stage.
Whether or not to compute the computation of a temporary coverage value determined by the alpha value.
Whether or not to AND the fragment's coverage with the temporary coverage value.
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 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 packing pixel data into memory.
The multiplier with which an implementation-specific value is multiplied to create a constant depth offset.
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 canvas' drawing buffer to match its physical size.
Whether or not the drawing buffer was resized.
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
.
Read pixels from a framebuffer.
Optional
framebuffer: null | FramebufferThe framebuffer to read pixels from, or null
for the default framebuffer. Defaults to the default framebuffer.
Optional
rectangle: RectangleThe rectangle of pixels to read. Defaults to the entire read buffer.
Optional
rgba: booleanWhether to output RGBA data (as opposed to using the format of the read buffer). Defaults to false
.
Optional
packAlignment: 1 | 2 | 4 | 8The alignment to use when packing the data, or undefined
to let this be automatically determined.
Optional
out: undefinedThe buffer or typed array to store the pixel data in.
Optional
offset: numberThe offset at which to start storing pixel data in the buffer or typed array.
A typed array of pixel data.
Read pixels from a framebuffer.
The framebuffer to read pixels from, or null
for the default framebuffer. Defaults to the default framebuffer.
The rectangle of pixels to read. Defaults to the entire read buffer.
Whether to output RGBA data (as opposed to using the format of the read buffer). Defaults to false
.
The alignment to use when packing the data, or undefined
to let this be automatically determined.
The buffer or typed array to store the pixel data in.
Optional
offset: numberThe offset at which to start storing pixel data in the buffer or typed array.
The buffer or typed array to store the pixel data in.
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