glDepthFunc

specify the value used for depth buffer comparisons

Signature

glDepthFunc( GLenum ( func ) )-> void
glDepthFunc( func )

Parameters

VariablesDescription
func
Specifies the depth comparison function. Symbolic constants GL_NEVER , GL_LESS , GL_EQUAL , GL_LEQUAL , GL_GREATER , GL_NOTEQUAL , GL_GEQUAL , and GL_ALWAYS are accepted. The initial value is GL_LESS .

Description

glDepthFunc specifies the function used to compare each incoming pixel depth value with the depth value present in the depth buffer. The comparison is performed only if depth testing is enabled. (See glEnable and glDisable of GL_DEPTH_TEST .)
func specifies the conditions under which the pixel will be drawn. The comparison functions are as follows:
GL_NEVER
Never passes.
GL_LESS
Passes if the incoming depth value is less than the stored depth value.
GL_EQUAL
Passes if the incoming depth value is equal to the stored depth value.
GL_LEQUAL
Passes if the incoming depth value is less than or equal to the stored depth value.
GL_GREATER
Passes if the incoming depth value is greater than the stored depth value.
GL_NOTEQUAL
Passes if the incoming depth value is not equal to the stored depth value.
GL_GEQUAL
Passes if the incoming depth value is greater than or equal to the stored depth value.
GL_ALWAYS
Always passes.
The initial value of func is GL_LESS . Initially, depth testing is disabled. If depth testing is disabled or if no depth buffer exists, it is as if the depth test always passes.

Notes

Even if the depth buffer exists and the depth mask is non-zero, the depth buffer is not updated if the depth test is disabled. In order to unconditionally write to the depth buffer, the depth test should be enabled and set to GL_ALWAYS .

Errors

GL_INVALID_ENUM is generated if func is not an accepted value.

Associated Gets

glGet with argument GL_DEPTH_FUNC
glIsEnabled with argument GL_DEPTH_TEST

Version Support

glDepthFunc

See Also

Copyright

Copyright
1991-2006 Silicon Graphics, Inc. Copyright
2010-2014 Khronos Group. This document is licensed under the SGI Free Software B License. For details, see .

Sample Code References

The following code samples have been found which appear to reference the functions described here. Take care that the code may be old, broken or not even use PyOpenGL.

glDepthFunc
OpenGLContext OpenGLContext/shadow/passes.py Lines: 129, 232, 317, 353
OpenGLContext OpenGLContext/passes/flatcompat.py Lines: 88, 90, 178, 198
OpenGLContext OpenGLContext/passes/flatcore.py Lines: 78, 79, 165, 185
OpenGLContext OpenGLContext/passes/_flat.py Lines: 343, 344, 441, 461
OpenGLContext OpenGLContext/passes/rendervisitor.py Lines: 336
OpenGLContext tests/shadow_1.py Lines: 313
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson11.py Lines: 36
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson18.py Lines: 112
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson6.py Lines: 88
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson41.py Lines: 184
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson16.py Lines: 53
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson23.py Lines: 62
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson5.py Lines: 66
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson4.py Lines: 63
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson26.py Lines: 58
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson12.py Lines: 39
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson3.py Lines: 53
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson13.py Lines: 116
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson1.py Lines: 53
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson19.py Lines: 92
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson42.py Lines: 166
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson2.py Lines: 53
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson6-multi.py Lines: 123
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson45.py Lines: 343
OpenGL-Demo PyOpenGL-Demo/GLUT/shader_test.py Lines: 27
OpenGL-Demo PyOpenGL-Demo/GLUT/tom/cone.py Lines: 48
OpenGL-Demo PyOpenGL-Demo/tom/conechecker.py Lines: 42
OpenGL-Demo PyOpenGL-Demo/tom/fog.py Lines: 39
OpenGL-Demo PyOpenGL-Demo/tom/cone.py Lines: 20
OpenGL-Demo py2exe-example/shader_test.py Lines: 28
{Artistic License} PymmLib pymmlib/applications/glutviewer.py Lines: 184
{Artistic License} PymmLib pymmlib/mmLib/OpenGLDriver.py Lines: 165
{LGPL} Pyggel pyggel/view.py Lines: 166
{LGPL} pygl2d pygl2d/display.py Lines: 43
{LGPL or GPL or MPL} Kamaelia Code/Python/Kamaelia/Kamaelia/UI/OpenGL/OpenGLDisplay.py Lines: 462
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/Experiments/Cubes.py Lines: 84
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/Experiments/Spheres.py Lines: 61
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Kamaelia/UI/OpenGL/OpenGLDisplay.py Lines: 461
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Sketches/Display3D.py Lines: 137
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Sketches/playground/Display3D.py Lines: 146
{LGPL or GPL or MPL} Kamaelia Sketches/THF/3D/Display3D.py Lines: 137
{LGPL or GPL or MPL} Kamaelia Sketches/THF/3D/playground/Display3D.py Lines: 146
Visvis wobjects/polygonalModeling.py Lines: 916, 921
Visvis text/text_base.py Lines: 251, 267
Visvis core/line.py Lines: 669, 703, 738, 809
{GPL3} OpenGL-Programmable 05-shader.py Lines: 323
{GPL3} OpenGL-Programmable 07-attrib.py Lines: 342
{GPL3} OpenGL-Programmable 03-array.py Lines: 243
{GPL3} OpenGL-Programmable 09-gles2.py Lines: 385
{GPL3} OpenGL-Programmable 06-perpixel.py Lines: 331
{GPL3} OpenGL-Programmable 10-gl3.2core.py Lines: 395
{GPL3} OpenGL-Programmable 02-displaylist.py Lines: 241
{GPL3} OpenGL-Programmable 04-vbo.py Lines: 262
{GPL3} OpenGL-Programmable 01-direct.py Lines: 232
{GPL3} OpenGL-Programmable 08-pbo.py Lines: 364