Depth, blending & cullingGL 1.0
glCullFace
Chooses which faces are discarded when face culling is enabled.
Signature
void glCullFace(GLenum mode);
How it works
On a closed mesh, the triangles facing away from the camera are always hidden behind the ones facing it. Culling skips them before rasterization, saving roughly half the fragment work. Whether a triangle is front or back is decided by its winding (see glFrontFace).
Parameters
modeGLenum
Which side to discard.
Common values
- GL_BACK
- Discard back faces (default).
- GL_FRONT
- Discard front faces — used in shadow passes to reduce peter-panning.
- GL_FRONT_AND_BACK
- Discard all polygons (lines and points still draw).
Example
example.cpp
1glEnable(GL_CULL_FACE);
2glCullFace(GL_BACK);
3glFrontFace(GL_CCW);