Querying Extensions
Always check for extension availability before using it. Unsupported
extensions return null.
| API |
Description |
| gl.getSupportedExtensions() |
Returns array of all available extension strings for this
context
|
| gl.getExtension('NAME') |
Returns extension object or null. Must be
called once; subsequent calls return same object
|
Texture Extensions
| Extension |
Context |
Enables |
| OES_texture_float |
WebGL 1 |
32-bit float textures (gl.FLOAT as type in
texImage2D)
|
| OES_texture_half_float |
WebGL 1 |
16-bit half-float textures. Use
ext.HALF_FLOAT_OES as type
|
| OES_texture_float_linear |
WebGL 1 |
Bilinear filtering of float textures (plain float textures
only support NEAREST without this)
|
| OES_texture_half_float_linear |
WebGL 1 |
Bilinear filtering of half-float textures |
| EXT_color_buffer_float |
WebGL 2 |
Render to float / half-float textures (required for HDR
render targets)
|
| EXT_texture_filter_anisotropic |
WebGL 1 |
Anisotropic filtering. Query max with
gl.getParameter(ext.MAX_TEXTURE_MAX_ANISOTROPY_EXT)
|
| WEBGL_compressed_texture_s3tc |
WebGL 1 |
DXT1/3/5 compressed textures (desktop GPUs) |
| WEBGL_compressed_texture_etc |
WebGL 1 |
ETC1/2 compressed textures (mobile GPUs) |
| WEBGL_compressed_texture_astc |
WebGL 1 |
ASTC compressed textures (ARM Mali, Apple GPU) |
In Three.js, set
renderer.anisotropy =
renderer.capabilities.getMaxAnisotropy()
on textures for sharper ground planes at grazing angles.
Rendering Extensions
| Extension |
Context |
Enables |
| ANGLE_instanced_arrays |
WebGL 1 |
Instanced drawing. Promoted to core in WebGL 2 as
gl.drawArraysInstanced
|
| OES_vertex_array_object |
WebGL 1 |
VAOs for encapsulating attribute state. Core in WebGL 2
|
| WEBGL_draw_buffers |
WebGL 1 |
Multiple render targets (MRT). Core in WebGL 2 |
| EXT_blend_minmax |
WebGL 1 |
MIN/MAX blend equations. Core in WebGL 2 |
| EXT_frag_depth |
WebGL 1 |
Write gl_FragDepthEXT from fragment shader. Core in WebGL 2
|
| OES_standard_derivatives |
WebGL 1 |
dFdx(), dFdy(), fwidth() in fragment shader. Core in WebGL 2
#version 300 es
|
| WEBGL_depth_texture |
WebGL 1 |
Depth textures for shadow mapping. Core in WebGL 2 |
| EXT_shader_texture_lod |
WebGL 1 |
texture2DLodEXT() / texture2DGradEXT(). Core in WebGL 2
|
Timing & Debug Extensions
| Extension |
Context |
Enables |
| EXT_disjoint_timer_query |
WebGL 1 |
Async GPU timing queries. Returns elapsed nanoseconds for
draw calls
|
| EXT_disjoint_timer_query_webgl2 |
WebGL 2 |
Same for WebGL 2. Use gl.TIME_ELAPSED_EXT query
target
|
| WEBGL_debug_renderer_info |
WebGL 1 |
Exposes UNMASKED_VENDOR_WEBGL and UNMASKED_RENDERER_WEBGL
GPU strings
|
| WEBGL_debug_shaders |
WebGL 1 |
ext.getTranslatedShaderSource(shader) — see the
driver-translated shader GLSL
|
| KHR_parallel_shader_compile |
WebGL 1 |
Non-blocking shader compilation check. Poll
COMPLETION_STATUS_KHR instead of blocking
|
Promoted to WebGL 2 Core
These were extensions in WebGL 1 and are now part of the WebGL 2
core — no extension query needed.
| Feature |
WebGL 1 Extension |
WebGL 2 equivalent |
| Multiple render targets |
WEBGL_draw_buffers |
gl.drawBuffers() |
| Instanced drawing |
ANGLE_instanced_arrays |
gl.drawArraysInstanced(),
gl.vertexAttribDivisor()
|
| Vertex array objects |
OES_vertex_array_object |
gl.createVertexArray() |
| Depth textures |
WEBGL_depth_texture |
gl.DEPTH_COMPONENT24 internal format |
| Fragment depth write |
EXT_frag_depth |
gl_FragDepth in #version 300 es shaders |
| Standard derivatives |
OES_standard_derivatives |
dFdx(), dFdy(), fwidth() in #version 300 es
|