glDepthFunc

The glDepthFunc function specifies the value used for depth-buffer comparisons.

void glDepthFunc(
  GLenum func   
);
 

Parameters

func
The depth-comparison function. The following symbolic constants are accepted.
Symbolic Constant Meaning
GL_NEVER Never passes.
GL_LESS Passes if the incoming z value is less than the stored z value. This is the default value.
GL_EQUAL Passes if the incoming z value is equal to the stored z value.
GL_LEQUAL Passes if the incoming z value is less than or equal to the stored z value.
GL_GREATER Passes if the incoming z value is greater than the stored z value.
GL_NOTEQUAL Passes if the incoming z value is not equal to the stored z value.
GL_GEQUAL Passes if the incoming z value is greater than or equal to the stored z value.
GL_ALWAYS Always passes.

Remarks

The glDepthFunc function specifies the function used to compare each incoming pixel z value with the z value present in the depth buffer. The comparison is performed only if depth testing is enabled. (See glEnable with the argument GL_DEPTH_TEST.)

Initially, depth testing is disabled.

The following functions retrieve information related to glDepthFunc:

glGet with argument GL_DEPTH_FUNC

glIsEnabled with argument GL_DEPTH_TEST

Error Codes

The following are the error codes generated and their conditions.

Error Code Condition
GL_INVALID_ENUM func was not an accepted value.
GL_INVALID_OPERATION glDepthFunc was called between a call to glBegin and the corresponding call to glEnd.

QuickInfo

  Windows NT: Use version 3.5 and later.
  Windows: Use Windows 95 and later.
  Windows CE: Unsupported.
  Header: Declared in gl.h.
  Import Library: Link with opengl32.lib.

See Also

glBegin, glDepthRange, glEnable, glEnd, glGet, glIsEnabled