★ wanayoo — archive 1999 https://developer.mozilla.org/ko/docs/Web/API/WebGL_API/Using_ExtensionsNouvelle recherche | Portail wanayoo

Join MDN and developers like you at Mozilla's View Source conference, November 2-4 in Portland, Oregon. Learn more at https://viewsourceconf.org/.

Using WebGL extensions

아직 자원 봉사자들이 한국어로 현재 문서를 번역하지 않았습니다. 가입해서 이 문서가 번역되는 일에 함께 해 주세요!

WebGL, like its sister APIs (OpenGL and OpenGL ES), supports extensions. A complete list of extensions is available in the khronos webgl extension registry.

Note: In WebGL, unlike in other GL APIs, extensions are only available if explicitly requested.

Canonical extension names, vendor prefixes and preferences

Extensions may be supported by browser vendors before being officially ratified (but only when they are in draft stage). In that case, their name can be prefixed by the vendor prefix (MOZ_, WEBKIT_, etc.) or the extension is only available once a browser preference has been toggled.

If you wish to work with the bleeding edge of extensions, and want to keep working on upon ratification (assuming, of course, that the extension doesn't change in incompatible ways), that you query the canonical extension name as well as the vendor extension name. For instance:

var ext = (
  gl.getExtension('OES_vertex_array_object') ||
  gl.getExtension('MOZ_OES_vertex_array_object') ||
  gl.getExtension('WEBKIT_OES_vertex_array_object')
);

Vendor prefix have been discouraged more and more and thus most browser implement experimental extensions behind a feature flag rather than vendor prefix.

The feature flags are:

  • webgl.enable-draft-extensions in Firefox
  • chrome://flags/#enable-webgl-draft-extensions in Chromium based browsers (Chrome, Opera).

Querying available extensions

The WebGL context supports querying what extensions are available.

var available_extensions = gl.getSupportedExtensions();

The WebGLRenderingContext.getSupportedExtensions() method returns an array of strings, one for each supported extension.

Extension list

The current extensions are:

Enabling an extension

Before an extension can be used it has to be enabled using WebGLRenderingContext.getExtension(). For example:

var float_texture_ext = gl.getExtension('OES_texture_float');

The return value is null if the extension is not supported, or an extension object otherwise.

Extension objects

If an extension defines specific symbols or functions that are not available in the core specification of WebGL, they will be available on the extension object returned by the call to gl.getExtension().

Compatibility of extensions

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_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 ? 34.0 (34.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_etc1 ? 30.0 (30.0) ? ? ?
WEBGL_compressed_texture_pvrtc ? 18.0 (18.0) ? ? ?
WEBGL_compressed_texture_s3tc ? 15.0 (15.0) ? ? ?
WEBGL_debug_renderer_info ? 19.0 (19.0) ? ? ?
WEBGL_debug_shaders ? 30.0 (30.0) ? ? ?
WEBGL_depth_texture ? 17.0 (17.0) ? ? ?
WEBGL_draw_buffers ? 28.0 (28.0) ? ? ?
WEBGL_lose_context ? 19.0 (19.0) ? ? ?
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.1
ANGLE_instanced_arrays ? ? ? ? ? ?
EXT_blend_minmax ? ? ? ? ? ?
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_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 was prefixed as MOZ_EXT_texture_filter_anisotropic in prior versions.

See also

--- move the following to dedicated extension pages ---

EXT_texture_filter_anisotropic

Anisotropic filtering improves the quality of mipmapped texture access when viewing a textured primitive at an oblique angle. Using just mipmapping, these lookups have a tendency to average to grey.

The extension defines two symbols:

  • extension_object.MAX_TEXTURE_MAX_ANISOTROPY_EXT: This is the pname argument to the gl.getParameter() call, and it returns the maximum available anisotropy.
  • extension_object.TEXTURE_MAX_ANISOTROPY_EXT: This is the pname argument to the gl.texParameter() and gl.getTexParameter{f,i}() call and sets the desired maximum anisotropy for a texture.

Example

var texture = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, texture);
var ext = (
  gl.getExtension('EXT_texture_filter_anisotropic') ||
  gl.getExtension('MOZ_EXT_texture_filter_anisotropic') ||
  gl.getExtension('WEBKIT_EXT_texture_filter_anisotropic')
);
if (ext){
  var max = gl.getParameter(ext.MAX_TEXTURE_MAX_ANISOTROPY_EXT);
  gl.texParameterf(gl.TEXTURE_2D, ext.TEXTURE_MAX_ANISOTROPY_EXT, max);
}

WEBGL_compressed_texture_s3tc

Compressed textures reduce the amount of memory needed to store a texture on the GPU, allowing for higher resolution textures or more of the same resolution textures.

The extension defines four new texture types:

  • extension_object.COMPRESSED_RGB_S3TC_DXT1_EXT
  • extension_object.COMPRESSED_RGBA_S3TC_DXT1_EXT
  • extension_object.COMPRESSED_RGBA_S3TC_DXT3_EXT
  • extension_object.COMPRESSED_RGBA_S3TC_DXT5_EXT

These compressed texture formats can be used in two functions: compressedTexImage2D and compressedTexSubImage2D.

Example

var ext = (
  gl.getExtension("WEBGL_compressed_texture_s3tc") ||
  gl.getExtension("MOZ_WEBGL_compressed_texture_s3tc") ||
  gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc")
);
var texture = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, texture);
gl.compressedTexImage2D(gl.TEXTURE_2D, 0, ext.COMPRESSED_RGBA_S3TC_DXT5_EXT, 512, 512, 0, textureData); 
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);

문서 태그 및 공헌자

태그: 
Contributors to this page: fscholz, Jeremie, kohei.yoshino, Sheppy, bjacob, ethertank, jbuck, pyalot
최종 변경: fscholz,