True if the back buffer should use anti-aliasing.
Readonly
canvasThe canvas DOM element that provides the underlying WebGL context used by the graphics device.
The GPU profiler.
True if the back-buffer is using HDR format, which means that the browser will display the rendered images in high dynamic range mode. This is true if the options.displayFormat is set to DISPLAYFORMAT_HDR when creating the graphics device using createGraphicsDevice, and HDR is supported by the device.
Readonly
isTrue if the deviceType is WebGL2
Readonly
isTrue if the deviceType is WebGPU
Readonly
maxThe maximum supported texture anisotropy setting.
Readonly
maxThe maximum supported number of color buffers attached to a render target.
Readonly
maxThe maximum supported dimension of a cube map.
Readonly
maxThe maximum supported number of hardware anti-aliasing samples.
Readonly
maxThe maximum supported dimension of a texture.
Readonly
maxThe maximum supported dimension of a 3D texture (any axis).
Readonly
precisionThe highest shader precision supported by this graphics device. Can be 'hiphp', 'mediump' or 'lowp'.
Readonly
samplesThe number of hardware anti-aliasing samples used by the frame buffer.
Readonly
scopeThe scope namespace for shader attributes and variables.
True if the device supports clip distances (WebGPU only). Clip distances allow you to restrict primitives' clip volume with user-defined half-spaces in the output of vertex stage.
Readonly
supportsTrue if the device supports compute shaders.
Readonly
supportsTrue if the device can read from StorageTexture in the compute shader. By default, the
storage texture can be only used with the write operation.
When a shader uses this feature, it's recommended to use a requires
directive to signal the
potential for non-portability at the top of the WGSL shader code:
requires readonly_and_readwrite_storage_textures;
Readonly
textureTrue if filtering can be applied when sampling float textures.
Readonly
textureTrue if 32-bit floating-point textures can be used as a frame buffer.
Readonly
textureTrue if 16-bit floating-point textures can be used as a frame buffer.
Readonly
textureRG11True if small-float textures with format PIXELFORMAT_111110F can be used as a frame buffer. This is always true on WebGL2, but optional on WebGPU device.
Gets the type of the device. Can be:
Gets whether the device is currently in fullscreen mode.
Sets whether the device is currently in fullscreen mode.
Height of the back buffer in pixels.
Gets the maximum pixel ratio.
Sets the maximum pixel ratio.
Width of the back buffer in pixels.
Dispatch multiple compute shaders inside a single compute shader pass.
An array of compute shaders to dispatch.
Optional
name: string = 'Unnamed'The name of the dispatch, used for debugging and reporting only.
Destroy the graphics device.
Fire an event, all additional arguments are passed on to the event listener.
Name of event to fire.
Optional
arg1: anyFirst argument that is passed to the event handler.
Optional
arg2: anySecond argument that is passed to the event handler.
Optional
arg3: anyThird argument that is passed to the event handler.
Optional
arg4: anyFourth argument that is passed to the event handler.
Optional
arg5: anyFifth argument that is passed to the event handler.
Optional
arg6: anySixth argument that is passed to the event handler.
Optional
arg7: anySeventh argument that is passed to the event handler.
Optional
arg8: anyEighth argument that is passed to the event handler.
Self for chaining.
Get a renderable HDR pixel format supported by the graphics device.
Note:
filterable
parameter is set to false, this function returns one of the supported
formats on the majority of devices apart from some very old iOS and Android devices (99%).filterable
parameter is set to true, the function returns a format on a
considerably lower number of devices (70%).Optional
formats: number[] = ...An array of pixel formats to check for support. Can contain:
Optional
filterable: boolean = trueIf true, the format also needs to be filterable. Defaults to true.
Optional
samples: number = 1The number of samples to check for. Some formats are not compatible with multi-sampling, for example PIXELFORMAT_RGBA32F on WebGPU platform. Defaults to 1.
The first supported renderable HDR format or undefined if none is supported.
Test if there are any handlers bound to an event name.
The name of the event to test.
True if the object has handlers bound to the specified event name.
Detach an event handler from an event. If callback is not provided then all callbacks are unbound from the event, if scope is not provided then all events with the callback will be unbound.
Optional
name: stringName of the event to unbind.
Optional
callback: HandleEventCallbackFunction to be unbound.
Optional
scope: anyScope that was used as the this when the event is fired.
Self for chaining.
const handler = () => {};
obj.on('test', handler);
obj.off(); // Removes all events
obj.off('test'); // Removes all events called 'test'
obj.off('test', handler); // Removes all handler functions, called 'test'
obj.off('test', handler, this); // Removes all handler functions, called 'test' with scope this
Attach an event handler to an event.
Name of the event to bind the callback to.
Function that is called when event is fired. Note the callback is limited to 8 arguments.
Optional
scope: any = ...Object to use as 'this' when the event is fired, defaults to current this.
Can be used for removing event in the future.
Attach an event handler to an event. This handler will be removed after being fired once.
Name of the event to bind the callback to.
Function that is called when event is fired. Note the callback is limited to 8 arguments.
Optional
scope: any = ...Object to use as 'this' when the event is fired, defaults to current this.
Function that executes after the device has been created.
Sets the constant blend color and alpha values used with BLENDMODE_CONSTANT and BLENDMODE_ONE_MINUS_CONSTANT factors specified in BlendState. Defaults to [0, 0, 0, 0].
The value for red.
The value for green.
The value for blue.
The value for alpha.
Controls how triangles are culled based on their face direction. The default cull mode is CULLFACE_BACK.
The cull mode to set. Can be:
Sets the current index buffer on the graphics device. On subsequent calls to GraphicsDevice#draw, the specified index buffer will be used to provide index data for any indexed primitives.
The index buffer to assign to the device.
Sets the specified render target on the device. If null is passed as a parameter, the back buffer becomes the current target for all rendering operations.
The render target to activate.
Sets the specified stencil state. If both stencilFront and stencilBack are null, stencil operation is disabled.
Optional
stencilFront: StencilParametersThe front stencil parameters. Defaults to StencilParameters.DEFAULT if not specified.
Optional
stencilBack: StencilParametersThe back stencil parameters. Defaults to StencilParameters.DEFAULT if not specified.
Sets the current vertex buffer on the graphics device. On subsequent calls to GraphicsDevice#draw, the specified vertex buffer(s) will be used to provide vertex data for any primitives.
The vertex buffer to assign to the device.
The graphics device manages the underlying graphics context. It is responsible for submitting render state changes and graphics primitives to the hardware. A graphics device is tied to a specific canvas HTML element. It is valid to have more than one canvas element per page and create a new graphics device against each.