glDepthFunc function

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

Syntax

void WINAPI glDepthFunc(
   GLenum func
);

Parameters

func

Specifies the depth-comparison function. The following symbolic constants are accepted.

Value 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_LEQUAL
Passes if the incoming z value is less than or equal to the stored z value.
GL_EQUAL
Passes if the incoming z value is 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.

Return value

This function does not return a value.

Error codes

The following error code can be retrieved by the glGetError function.

Name Meaning
GL_INVALID_OPERATION
The function was called between a call to glBegin and the corresponding call to glEnd.

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

Requirements

Requirement Value
Minimum supported client
Windows 2000 Professional [desktop apps only]
Minimum supported server
Windows 2000 Server [desktop apps only]
Header
Gl.h
Library
Opengl32.lib
DLL
Opengl32.dll

See also

glBegin

glDepthRange

glEnable

glEnd

glGet

glIsEnabled