此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

WebGLRenderingContext.depthMask()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2015年7月⁩.

WebGL APIWebGLRenderingContext.depthMask() 方法设置是否启用写入深度缓冲。

语法

void gl.depthMask(flag);

参数

flag

一个 GLboolean ,用于设置是否启用写入深度缓冲。默认值:true,表示启用写入。

返回值

无。

例子

js
gl.depthMask(false);

要获得当前的深度遮罩值,传入 DEPTH_WRITEMASK 常量,返回 Boolean.

js
gl.getParameter(gl.DEPTH_WRITEMASK);
// false

规范

Specification
WebGL Specification
# 5.14.3

浏览器兼容性

相关内容