Name
glPolygonMode — select a polygon rasterization modeC Specification
void glPolygonMode( | GLenum | face, |
GLenum | mode) ; |
Parameters
face
- Specifies the polygons that
mode
applies to. Must beGL_FRONT
for front-facing polygons,GL_BACK
for back-facing polygons, orGL_FRONT_AND_BACK
for front- and back-facing polygons. mode
- Specifies how polygons will be rasterized. Accepted values are
GL_POINT
,GL_LINE
, andGL_FILL
. The initial value isGL_FILL
for both front- and back-facing polygons.
Description
glPolygonMode
controls the interpretation of polygons for rasterization. face
describes which polygons mode
applies to: front-facing polygons (GL_FRONT
), back-facing polygons (GL_BACK
), or both (GL_FRONT_AND_BACK
). The polygon mode affects only the final rasterization of polygons. In particular, a polygon's vertices are lit and the polygon is clipped and possibly culled before these modes are applied.Three modes are defined and can be specified in
mode
: (glPolygonMode)GL_POINT
- Polygon vertices that are marked as the start of a boundary edge are drawn as points. Point attributes such as
GL_POINT_SIZE
andGL_POINT_SMOOTH
control the rasterization of the points. Polygon rasterization attributes other thanGL_POLYGON_MODE
have no effect. GL_LINE
- Boundary edges of the polygon are drawn as line segments. They are treated as connected line segments for line stippling; the line stipple counter and pattern are not reset between segments (see glLineStipple). Line attributes such as
GL_LINE_WIDTH
andGL_LINE_SMOOTH
control the rasterization of the lines. Polygon rasterization attributes other thanGL_POLYGON_MODE
have no effect. GL_FILL
- The interior of the polygon is filled. Polygon attributes such as
GL_POLYGON_STIPPLE
andGL_POLYGON_SMOOTH
control the rasterization of the polygon.
Examples
To draw a surface with filled back-facing polygons and outlined front-facing polygons, callglPolygonMode(GL_FRONT
,GL_LINE
);
Notes
Vertices are marked as boundary or nonboundary with an edge flag. Edge flags are generated internally by the GL when it decomposes polygons; they can be set explicitly using glEdgeFlag.Errors
GL_INVALID_ENUM
is generated if either face
or mode
is not an accepted value.GL_INVALID_OPERATION
is generated if glPolygonMode
is executed between the execution of glBegin and the corresponding execution of glEnd.Copyright
Copyright © 1991-2006 Silicon Graphics, Inc. This document is licensed under the SGI Free Software B License. For details, see http://oss.sgi.com/projects/FreeB/.Example of glPolygonMode
void RenderScene(void){
GLfloat x,y,angle;
int iPivot = 1;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if(bCull)
glEnable(GL_CULL_FACE);
else
glDisable(GL_CULL_FACE);
if(bDepth)
glEnable(GL_DEPTH_TEST);
else
glDisable(GL_DEPTH_TEST);
if(bOutline)
glPolygonMode(GL_BACK,GL_LINE);
else
glPolygonMode(GL_BACK,GL_FILL);
glPushMatrix();
glRotatef(xRot,1.0f,0.0f,0.0f);
glRotatef(yRot,0.0f,1.0f,0.0f);
glBegin(GL_TRIANGLE_FAN);
glVertex3f(0.0f,0.0f,75.0f);
for(angle=0.0f; angle < (2.0f*GL_PI); angle +=(GL_PI/8.0f))
{
x = 50.0f*sin(angle);
y = 50.0f*cos(angle);
if((iPivot %2) == 0)
glColor3f(0.0f,1.0f,0.0f);
else
glColor3f(1.0f,0.0f,0.0f);
iPivot++;
glVertex2f(x,y);
}
glEnd();
glBegin(GL_TRIANGLE_FAN);
glVertex2f(0.0f,0.0f);
for(angle = 0.0f; angle < (2.0f*GL_PI); angle += (GL_PI/8.0f))
{
x=50.0f*sin(angle);
y=50.0f*cos(angle);
if((iPivot %2) == 0)
glColor3f(0.0f,1.0f,0.0f);
else
glColor3f(1.0f,0.0f,0.0f);
iPivot++;
glVertex2f(x,y);
}
glEnd();
glPopMatrix();
glFlush(); }