Context this is of type 'any' for now, since WebGL2RenderingContext not available but supported. This
constructor is protected to enforce context creation using request
. It queries extension support and
configures context specifics for convenience, e.g., HALF_FLOAT format.
Cached attributes of the context.
Created context. The actual type depends on the created context.
Cached extension supported by the context.
Context creation attribute defaults. The defaults are taken directly from the spec.
The context's GPU allocation register for use of tracking memory allocations.
The created rendering backend (webgl context type), either 'webgl' or 'webgl2' based on which one was created successfully. If no context could be created undefined is returned.
Provides a human-readable string of the backend.
Provides an array of all extensions supported by the used WebGL1/2 context.
Access to either the WebGLRenderingContext or WebGL2RenderingContext.
WebGL2 facade for WebGL2 API like access to features mandatory to this engine.
True if the context is a WebGL1 context, otherwise false.
True if the context is a WebGL2 context, otherwise false.
Masquerade object applied to a context instance.
True if WebGL2 blitFramebuffer is supported, false otherwise. This is experimental technology.
True if WebGL2 readBuffer is supported, false otherwise. This is experimental technology.
True if WebGL2 texImage3D draft is supported, false otherwise. This is experimental technology.
Queries various parameters (depending on the type of context and support of extensions) and returns them as formatted string.
Creates a well formated about string, e.g., for logging.
Provides the size in bytes of certain WebGL format enumerator. Please note that some byte sizes might vary based on context attributes or the bound render, thus, DEPTH_COMPONENT and DEPTH_STENCIL are not covered by this function. @see byteSizeOfFormat
Enable provided extensions. Each extension is only enabled if it is supported. Alternatively the extension can be queried for support and accessed (thereby enabled) directly. Thus, this function only acts as convenience interface for something like a mandatory extension configuration etc. Also, some extensions only effect GLSL capabilities and must be enabled explicitly without accessing the extension object.
Array of extensions identifier that are to be enabled.
Returns the cached extensions object for the given extension identifier. If no extensions is cached, it is queried. Asserts if the extension is provided by default in the current backend, not supported in general, or unknown to the specification. Please not that the availability of an extension might be concealed by the context's mask.
Member the extension object is cached into.
Extension identifier to query.
Provides the context's extension hash. The hash can be used for context masquerade.
Logs a well formated list of all queried about params (names and associated values).
Log verbosity that is to be used for logging.
Queries all extensions for the current context and stores the result (supported or not supported). This is relevant to avoid continuous searches or regexp matching or substring queries in the complete extension string. Instead, the support is queried once and can be explicitly request in the public interface using properties.
This function should get called only once per Context instance.
Checks if the given extension is supported. Please note that a 'supports' call asserts whether or not the extension is related to the WebGL version. For example, the following code would lead to an Error:
this.supports('ANGLE_instanced_arrays'); // asserts in WebGL2 since the extension is incorporated by default
If the context is masked by a ContextMasquerade the support of an extension might be concealed.
Extension identifier to query support for.
Creates a masquerade object that can be used for debugging. This is intended to be called when requesting a context, i.e., before actually requesting it. For creation of a masquerade object, the following masquerade specifiers are evaluated in the following order:
Dataset of the canvas element that might provide a data-msqrd-{h,p} attribute.
Create a WebGL context. Note: this should only be called once in constructor, because the second and subsequent calls to getContext of an element will return null.
Canvas element to request context from.
Overrides the internal default attributes @see{Context.DEFAULT_ATTRIBUTES}.
Helper that tries to create a WebGL 1 context (requests to 'webgl' and 'experimental-webgl' are made).
Canvas element to request context from.
Overrides the internal default attributes @see{Context.CONTEXT_ATTRIBUTES}.
Helper that tries to create a WebGL 2 context (requests to 'webgl2' and 'experimental-webgl2' are made).
Canvas element to request context from.
Overrides the internal default attributes @see{Context.CONTEXT_ATTRIBUTES}.
A controller for either a WebGLRenderingContext or WebGL2RenderingContext. It requests a context, tracks context attributes, extensions as well as multi frame specific rendering information and a (gpu)allocation registry.
An instance of
Context
can be created only implicitly by requesting a context given a canvas element and its dataset:The context supports the following data-attributes:
At run-time, cached context features can be queried without a performance impact, e.g., frequent extension-based branching:
For convenience, protected extension names such as
EXT_frag_depth
are not prefixed by an underscore.