WEBGL_depth_texture

WEBGL_depth_texture extension is part of the WebGL API and defines 2D depth and depth-stencil textures.

WebGL extensions are available using the WebGLRenderingContext.getExtension() method. For more information, see also Using Extensions WebGL tutorial .

Availability: This extension is only available to WebGL1 contexts. In WebGL2 , the functionality of this extension is available on the WebGL2 context by default. The constant in WebGL2 is gl.UNSIGNED_INT_24_8 .

常量

This extension adds a new constant:

ext.UNSIGNED_INT_24_8_WEBGL
Unsigned integer type for 24-bit depth texture data.

Extended methods

This extension extends WebGLRenderingContext.texImage2D() :

  • format and internalformat parameters now accept gl.DEPTH_COMPONENT and gl.DEPTH_STENCIL .
  • type parameter now accepts gl.UNSIGNED_SHORT , gl.UNSIGNED_INT ,和 ext.UNSIGNED_INT_24_8_WEBGL .
  • pixels parameter now accepts an ArrayBufferView of type Uint16Array and Uint32Array .

This extension extends WebGLRenderingContext.framebufferTexture2D() :

  • attachment parameter now accepts gl.DEPTH_STENCIL_ATTACHMENT .

Incorrectly stated as the target parameter in the specification, see https://www.khronos.org/bugzilla/show_bug.cgi?id=674 .

范例

var ext = gl.getExtension('WEBGL_depth_texture');
gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT, 512, 512, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_SHORT, null);
					

规范

规范 状态 Comment
WEBGL_depth_texture
The definition of 'WEBGL_depth_texture' in that specification.
Recommendation 初始定义。

浏览器兼容性

更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
WEBGL_depth_texture Chrome Yes
Yes
Yes
Prefixed
Prefixed Implemented with the vendor prefix: WEBKIT_
Edge ≤18 Firefox 22
22
不支持 ? — 58
Prefixed
Prefixed Implemented with the vendor prefix: MOZ_
IE ? Opera Yes
Yes
Yes
Prefixed
Prefixed Implemented with the vendor prefix: WEBKIT_
Safari ? WebView Android Yes
Yes
Yes
Prefixed
Prefixed Implemented with the vendor prefix: WEBKIT_
Chrome Android Yes
Yes
Yes
Prefixed
Prefixed Implemented with the vendor prefix: WEBKIT_
Firefox Android ? Opera Android Yes
Yes
Yes
Prefixed
Prefixed Implemented with the vendor prefix: WEBKIT_
Safari iOS ? Samsung Internet Android Yes
Yes
Yes
Prefixed
Prefixed Implemented with the vendor prefix: WEBKIT_

图例

完整支持
完整支持
兼容性未知
兼容性未知
要求使用供应商前缀或不同名称。
要求使用供应商前缀或不同名称。

另请参阅