glFrontFace

The glFrontFace function defines front- and back-facing polygons.

void glFrontFace(
  GLenum mode   
);
 

Parameters

mode
The orientation of front-facing polygons. GL_CW and GL_CCW are accepted. The default value is GL_CCW.

Remarks

In a scene composed entirely of opaque closed surfaces, back-facing polygons are never visible. Eliminating these invisible polygons has the obvious benefit of speeding up the rendering of the image. You enable and disable elimination of back-facing polygons with glEnable and glDisable using argument GL_CULL_FACE.

The projection of a polygon to window coordinates is said to have clockwise winding if an imaginary object following the path from its first vertex, its second vertex, and so on, to its last vertex, and finally back to its first vertex, moves in a clockwise direction about the interior of the polygon. The polygon's winding is said to be counterclockwise if the imaginary object following the same path moves in a counterclockwise direction about the interior of the polygon. The glFrontFace function specifies whether polygons with clockwise winding in window coordinates, or counterclockwise winding in window coordinates, are taken to be front-facing. Passing GL_CCW to mode selects counterclockwise polygons as front-facing; GL_CW selects clockwise polygons as front-facing. By default, counterclockwise polygons are taken to be front-facing.

The following function retrieves information about glFrontface:

glGet with argument GL_FRONT_FACE

Error Codes

The following are the error codes generated and their conditions.

Error Code Condition
GL_INVALID_ENUM mode was not an accepted value.
GL_INVALID_OPERATION glFrontFace was called between a call to glBegin and the corresponding call to glEnd.

QuickInfo

  Windows NT: Use version 3.5 and later.
  Windows: Use Windows 95 and later.
  Windows CE: Unsupported.
  Header: Declared in gl.h.
  Import Library: Link with opengl32.lib.

See Also

glBegin, glCullFace, glDisable, glEnable, glEnd, glGet, glLightModel