Previous: glDeleteVertexArrays Table of Contents (GL) Next: glDepthMask

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

See Also

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 tests/shadow_1.py Lines: 312
OpenGLContext OpenGLContext/shadow/passes.py Lines: 129, 232, 317, 353
OpenGLContext OpenGLContext/passes/rendervisitor.py Lines: 341
OpenGLContext OpenGLContext/passes/flat.py Lines: 360, 362, 459, 479
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: 45
OpenGL-Demo PyOpenGL-Demo/tom/fog.py Lines: 43
OpenGL-Demo PyOpenGL-Demo/tom/cone.py Lines: 24
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson5.py Lines: 64
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson45.py Lines: 359
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson18.py Lines: 110
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson4.py Lines: 61
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson12.py Lines: 36
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson26.py Lines: 56
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson41.py Lines: 182
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson13.py Lines: 119
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson2.py Lines: 51
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson11.py Lines: 33
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson19.py Lines: 89
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson1.py Lines: 51
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson3.py Lines: 51
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson23.py Lines: 60
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson6.py Lines: 86
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson16.py Lines: 51
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson42.py Lines: 173
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson6-multi.py Lines: 120
{Artistic License} PymmLib applications/glutviewer.py Lines: 184
{Artistic License} PymmLib mmLib/OpenGLDriver.py Lines: 158
pyBzEdit pyBzEdit.py Lines: 405
{LGPL} Pyggel pyggel/view.py Lines: 166
{LGPL} pygl2d pygl2d/window.py Lines: 64
{LGPL or GPL or MPL} Kamaelia Code/Python/Kamaelia/Kamaelia/UI/OpenGL/OpenGLDisplay.py Lines: 461
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/Experiments/Spheres.py Lines: 42
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/Experiments/Cubes.py Lines: 65
{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 core/line.py Lines: 733, 804
Visvis text/text_base.py Lines: 250, 266
Visvis wobjects/polygonalModeling.py Lines: 915, 920
Previous: glDeleteVertexArrays Table of Contents (GL) Next: glDepthMask