From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../api/webglrenderingcontext/depthfunc/index.html | 83 ++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 files/zh-cn/web/api/webglrenderingcontext/depthfunc/index.html (limited to 'files/zh-cn/web/api/webglrenderingcontext/depthfunc') diff --git a/files/zh-cn/web/api/webglrenderingcontext/depthfunc/index.html b/files/zh-cn/web/api/webglrenderingcontext/depthfunc/index.html new file mode 100644 index 0000000000..71c4c1b04e --- /dev/null +++ b/files/zh-cn/web/api/webglrenderingcontext/depthfunc/index.html @@ -0,0 +1,83 @@ +--- +title: WebGLRenderingContext.depthFunc() +slug: Web/API/WebGLRenderingContext/depthFunc +translation_of: Web/API/WebGLRenderingContext/depthFunc +--- +
{{APIRef("WebGL")}}
+ +

WebGL API 的 WebGLRenderingContext.depthFunc() 方法,指定将输入像素深度与当前深度缓冲区值进行比较的函数。

+ +

语法

+ +
void gl.depthFunc(func);
+
+ +

参数

+ +
+
func
+
是一个指定深度比较函数的 {{domxref("GLenum")}},它设置像素将被绘制的条件。默认值是 gl.LESS。可能的值是: +
    +
  • gl.NEVER(永不通过)
  • +
  • gl.LESS(如果传入值小于深度缓冲值,则通过)
  • +
  • gl.EQUAL(如果传入值等于深度缓冲区值,则通过)
  • +
  • gl.LEQUAL(如果传入值小于或等于深度缓冲区值,则通过)
  • +
  • gl.GREATER(如果传入值大于深度缓冲区值,则通过)
  • +
  • gl.NOTEQUAL(如果传入的值不等于深度缓冲区值,则通过)
  • +
  • gl.GEQUAL(如果传入值大于或等于深度缓冲区值,则通过)
  • +
  • gl.ALWAYS(总是通过)
  • +
+
+
+ +

返回值

+ +

无。

+ +

示例

+ +

深度测试默认是禁用的。 要启用或禁用深度测试,请使用带有参数  gl.DEPTH_TEST 的 {{domxref("WebGLRenderingContext.enable", "enable()")}} 和 {{domxref("WebGLRenderingContext.disable", "disable()")}} 方法。

+ +
gl.enable(gl.DEPTH_TEST);
+gl.depthFunc(gl.NEVER);
+
+ +

要检查当前深度函数,请查询 DEPTH_FUNC 常量。

+ +
gl.getParameter(gl.DEPTH_FUNC) === gl.NEVER;
+// true
+
+ +

规范

+ + + + + + + + + + + + + + + + + + + +
规范状态注释
{{SpecName('WebGL', "#5.14.3", "depthFunc")}}{{Spec2('WebGL')}}初始定义
{{SpecName('OpenGL ES 2.0', "glDepthFunc.xml", "glDepthFunc")}}{{Spec2('OpenGL ES 2.0')}}OpenGL API 手册
+ +

浏览器兼容性

+ + + +

{{Compat("api.WebGLRenderingContext.depthFunc")}}

+ +

另请参阅

+ + -- cgit v1.2.3-54-g00ecf