WebGLRenderingContext.getExtension()

The WebGLRenderingContext.getExtension() method enables a WebGL extension.

Syntax

JavaScript
<var>gl</var>.getExtension(name);

Parameters

name
A String for the name of the WebGL extension to enable.

Return value

A WebGL extension object, or null if name does not match (case-insensitive) to one of the strings in WebGLRenderingContext.getSupportedExtensions.

Examples

Once a WebGL extension is enabled, you are able to use the methods, properties or constants that this extension object provides.

JavaScript
var canvas = document.getElementById("canvas");
gl = canvas.getContext("webgl");

gl.getExtension('WEBGL_lose_context').loseContext();

WebGL extensions

Extensions for the WebGL API are registered in the WebGL Extension Registry. The current extensions are:

Specifications

Specification Status Comment
WebGL 1.0
The definition of 'WebGLRenderingContext.getExtension' in that specification.
Recommendation Initial definition.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 9 4.0 (2.0) 11 12 5.1
ANGLE_instanced_arrays ? 33.0 (33.0) ? ? ?
EXT_blend_minmax ? 33.0 (33.0) ? ? ?
EXT_color_buffer_float ? 49.0 (49.0) ? ? ?
EXT_color_buffer_half_float ? 30.0 (30.0) ? ? ?
EXT_disjoint_timer_query ? 41.0 (41.0) [1] ? ? ?
EXT_frag_depth ? 30.0 (30.0) ? ? ?
EXT_sRGB ? 28.0 (28.0) ? ? ?
EXT_shader_texture_lod ? 50.0 (50.0) ? ? ?
EXT_texture_filter_anisotropic ? 17.0 (17.0) [2] ? ? ?
OES_element_index_uint ? 24.0 (24.0) ? ? ?
OES_standard_derivatives ? 10.0 (10.0) ? ? ?
OES_texture_float ? 6.0 (6.0) ? ? ?
OES_texture_float_linear ? 24.0 (24.0) ? ? ?
OES_texture_half_float ? 29.0 (29.0) ? ? ?
OES_texture_half_float_linear ? 30.0 (30.0) ? ? ?
OES_vertex_array_object ? 25.0 (25.0) ? ? ?
WEBGL_color_buffer_float ? 30.0 (30.0) ? ? ?
WEBGL_compressed_texture_atc ? 18.0 (18.0) ? ? ?
WEBGL_compressed_texture_es3 ? 46.0 (46.0) [1] ? ? ?
WEBGL_compressed_texture_etc1 ? 30.0 (30.0) ? ? ?
WEBGL_compressed_texture_pvrtc ? 18.0 (18.0) ? ? ?
WEBGL_compressed_texture_s3tc ? 22.0 (22.0) [2] ? ? ?
WEBGL_debug_renderer_info ? 19.0 (19.0) ? ? ?
WEBGL_debug_shaders ? 30.0 (30.0) ? ? ?
WEBGL_depth_texture ? 22.0 (22.0) [2] ? ? ?
WEBGL_draw_buffers ? 28.0 (28.0) ? ? ?
WEBGL_lose_context ? 22.0 (22.0) [2] ? ? ?
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) 25 4.0 (2.0) (Yes) 12 8.0
ANGLE_instanced_arrays ? ? ? ? ? ?
EXT_blend_minmax ? ? ? ? ? ?
EXT_color_buffer_float ? ? ? ? ? ?
EXT_color_buffer_half_float ? ? ? ? ? ?
EXT_disjoint_timer_query ? ? ? ? ? ?
EXT_frag_depth ? ? ? ? ? ?
EXT_sRGB ? ? ? ? ? ?
EXT_shader_texture_lod ? ? ? ? ? ?
EXT_texture_filter_anisotropic ? ? ? ? ? ?
OES_element_index_uint ? ? ? ? ? ?
OES_standard_derivatives ? ? ? ? ? ?
OES_texture_float ? ? ? ? ? ?
OES_texture_float_linear ? ? ? ? ? ?
OES_texture_half_float ? ? ? ? ? ?
OES_texture_half_float_linear ? ? ? ? ? ?
OES_vertex_array_object ? ? ? ? ? ?
WEBGL_color_buffer_float ? ? ? ? ? ?
WEBGL_compressed_texture_atc ? ? ? ? ? ?
WEBGL_compressed_texture_etc1 ? ? ? ? ? ?
WEBGL_compressed_texture_s3tc ? ? ? ? ? ?
WEBGL_compressed_texture_pvrtc ? ? ? ? ? ?
WEBGL_compressed_texture_s3tc ? ? ? ? ? ?
WEBGL_debug_renderer_info ? ? ? ? ? ?
WEBGL_debug_shaders ? ? ? ? ? ?
WEBGL_depth_texture ? ? ? ? ? ?
WEBGL_draw_buffers ? ? ? ? ? ?
WEBGL_lose_context ? ? ? ? ? ?

[1] Toggling the webgl.enable-draft-extensions preference in about:config is required.

[2] This extension was prefixed with MOZ_ in prior versions.

See also

License

© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-us/docs/web/api/webglrenderingcontext/getextension

API Method Reference WebGL WebGLRenderingContext