Standard WebGL extensions plus custom headless-specific extensions for enhanced functionality and context management.
/**
* Get WebGL extension by name
* @param name - Extension name (case insensitive)
* @returns Extension object or null
*/
getExtension(name: string): any;
/**
* Get list of supported extension names
* @returns Array of extension name strings
*/
getSupportedExtensions(): string[];Provides mechanism to resize the drawing buffer of a WebGL context after creation.
interface STACKGL_resize_drawingbuffer {
/**
* Resize the drawing buffer
* @param width - New width in pixels
* @param height - New height in pixels
*/
resize(width: number, height: number): void;
}Usage Examples:
const ext = context.getExtension('STACKGL_resize_drawingbuffer');
if (ext) {
// Resize context to 1024x768
ext.resize(1024, 768);
console.log('New size:', context.drawingBufferWidth, 'x', context.drawingBufferHeight);
}Immediately destroys the WebGL context and reclaims all associated resources.
interface STACKGL_destroy_context {
/**
* Immediately destroy the context and all resources
*/
destroy(): void;
}Usage Examples:
const ext = context.getExtension('STACKGL_destroy_context');
if (ext) {
// Clean up context immediately
ext.destroy();
// Context is now unusable
}Provides instanced rendering support for drawing multiple instances of geometry.
interface ANGLE_instanced_arrays {
VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE: number;
vertexAttribDivisorANGLE(index: number, divisor: number): void;
drawArraysInstancedANGLE(mode: number, first: number, count: number, primcount: number): void;
drawElementsInstancedANGLE(mode: number, count: number, type: number, offset: number, primcount: number): void;
}Enables 32-bit unsigned integer indices for drawElements.
interface OES_element_index_uint {
// Allows using UNSIGNED_INT with drawElements
}Enables floating-point textures for high-precision rendering.
interface OES_texture_float {
// Allows FLOAT type with texImage2D
}Enables linear filtering for floating-point textures.
interface OES_texture_float_linear {
// Allows LINEAR and LINEAR_MIPMAP_* filtering with FLOAT textures
}Provides access to standard derivative functions in fragment shaders.
interface OES_standard_derivatives {
FRAGMENT_SHADER_DERIVATIVE_HINT_OES: number;
}Enables vertex array objects for encapsulating vertex array state.
interface OES_vertex_array_object {
VERTEX_ARRAY_BINDING_OES: number;
createVertexArrayOES(): WebGLVertexArrayObjectOES | null;
deleteVertexArrayOES(arrayObject: WebGLVertexArrayObjectOES | null): void;
isVertexArrayOES(arrayObject: WebGLVertexArrayObjectOES | null): boolean;
bindVertexArrayOES(arrayObject: WebGLVertexArrayObjectOES | null): void;
}
interface WebGLVertexArrayObjectOES {}Adds MIN and MAX blend equations.
interface EXT_blend_minmax {
MIN_EXT: number;
MAX_EXT: number;
}Enables anisotropic texture filtering for improved texture quality.
interface EXT_texture_filter_anisotropic {
TEXTURE_MAX_ANISOTROPY_EXT: number;
MAX_TEXTURE_MAX_ANISOTROPY_EXT: number;
}Provides explicit texture level-of-detail control in fragment shaders.
interface EXT_shader_texture_lod {
// Enables texture2DLodEXT, texture2DProjLodEXT, textureCubeLodEXT functions in shaders
}Provides multiple render target support for advanced rendering techniques.
interface WEBGL_draw_buffers {
COLOR_ATTACHMENT0_WEBGL: number;
COLOR_ATTACHMENT1_WEBGL: number;
// ... up to MAX_COLOR_ATTACHMENTS_WEBGL
drawBuffersWEBGL(buffers: number[]): void;
}Usage Examples:
// Check for extensions
const supportedExts = context.getSupportedExtensions();
console.log('Supported extensions:', supportedExts);
// Use instanced arrays extension
const instancing = context.getExtension('ANGLE_instanced_arrays');
if (instancing) {
// Set up instanced attribute
instancing.vertexAttribDivisorANGLE(instanceMatrixLocation, 1);
// Draw 100 instances
instancing.drawArraysInstancedANGLE(context.TRIANGLES, 0, 3, 100);
}
// Use multiple render targets
const drawBuffers = context.getExtension('WEBGL_draw_buffers');
if (drawBuffers) {
// Render to multiple color attachments
drawBuffers.drawBuffersWEBGL([
drawBuffers.COLOR_ATTACHMENT0_WEBGL,
drawBuffers.COLOR_ATTACHMENT1_WEBGL
]);
}
// Use float textures
const floatTextures = context.getExtension('OES_texture_float');
if (floatTextures) {
// Create float texture for high precision
context.texImage2D(context.TEXTURE_2D, 0, context.RGBA, 256, 256, 0,
context.RGBA, context.FLOAT, floatData);
}
// Use vertex array objects
const vaoExt = context.getExtension('OES_vertex_array_object');
if (vaoExt) {
// Create and bind vertex array object
const vao = vaoExt.createVertexArrayOES();
vaoExt.bindVertexArrayOES(vao);
// Set up vertex attributes (stored in VAO)
context.bindBuffer(context.ARRAY_BUFFER, vertexBuffer);
context.vertexAttribPointer(0, 3, context.FLOAT, false, 0, 0);
context.enableVertexAttribArray(0);
// Unbind VAO
vaoExt.bindVertexArrayOES(null);
}
// Use anisotropic filtering
const anisoExt = context.getExtension('EXT_texture_filter_anisotropic');
if (anisoExt) {
const maxAniso = context.getParameter(anisoExt.MAX_TEXTURE_MAX_ANISOTROPY_EXT);
context.texParameterf(context.TEXTURE_2D, anisoExt.TEXTURE_MAX_ANISOTROPY_EXT, maxAniso);
}All extensions work consistently across Node.js and browser environments, with automatic fallbacks where appropriate.
Available Extensions: