OpenGL Depth Buffering

Space must be allocated for the depth buffer:

glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH)

Depth buffering must be enabled:

glEnable(GL_DEPTH_TEST)

Depth buffer must be cleared each frame:

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)





glEnable

Some OpenGL features are not used by all programs

They may add to the processing time, or involve an effect that isn't always wanted

glEnable() turns on an optional feature
glDisable() turns it off





next