WebGLRenderingContext.getExtension()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

WebGLRenderingContext.getExtension() 方法可以启用一个 WebGL 扩展。

语法

gl.getExtension(name);

参数

name

String 形式表示的需要启用的 WebGL 扩展的名称。

返回值

一个 WebGL 扩展对象。如果扩展名称(区分大小写)与 WebGLRenderingContext.getSupportedExtensions 中的任何结果都不匹配,则只会返回 null

示例

当一个 WebGL 扩展被启用后,就可以使用该扩展提供的方法、属性和常量。

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

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

WebGL 扩展

WebGL API 的扩展在 WebGL Extension Registry 定义。目前支持的扩展在这里列出

规范

Specification
WebGL Specification
# 5.14.14

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
getExtension

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

参阅