173 176














Open GL Super Bible:Drawing in 3D: Lines, Points, and Polygons















To access the contents, click the chapter and section titles.


Open GL Super Bible


(Publisher: Macmillan Computer Publishing)

Author(s): Waite group Press

ISBN: 1571690735

Publication Date: 08/01/96


 




Previous
Table of Contents
Next




glEdgeFlag

Purpose
Flags polygon edges as either boundary or nonboundary edges. This can be used to determine whether interior surface lines are visible.
Include File
<gl.h>
Variations
void glEdgeFlag(GLboolean flag); void glEdgeFlagv(const GLboolean *flag);
Description
When two or more polygons are joined to form a
larger region, the edges on the outside define the boundary of the newly
formed region. This function flags inside edges as nonboundary. This is
used only when the polygon mode is set to either GL_LINE or GL_POINT.


Parameters

flag

GLboolean: Sets the edge flag to this value, True or False.
*flag

const GLboolean *: A pointer to a value that is used for the edge flag.
Returns
None.


Example
The following code from the STAR program in this chapter sets the edge flag to False for triangle borders inside the region of the star. It draws the star either as a solid, an outline, or just the vertices.

// Draw back side as a polygon only, if flag is set
if(iMode == MODE_LINE)
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);

if(iMode == MODE_POINT)
glPolygonMode(GL_FRONT_AND_BACK,GL_POINT);

if(iMode == MODE_SOLID)
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);

// Begin the triangles
glBegin(GL_TRIANGLES);

glEdgeFlag(bEdgeFlag);
glVertex2f(-20.0f, 0.0f);
glEdgeFlag(TRUE);
glVertex2f(20.0f, 0.0f);
glVertex2f(0.0f, 40.0f);

glVertex2f(-20.0f,0.0f);
glVertex2f(-60.0f,-20.0f);
glEdgeFlag(bEdgeFlag);
glVertex2f(-20.0f,-40.0f);
glEdgeFlag(TRUE);

glVertex2f(-20.0f,-40.0f);
glVertex2f(0.0f, -80.0f);
glEdgeFlag(bEdgeFlag);
glVertex2f(20.0f, -40.0f);
glEdgeFlag(TRUE);

glVertex2f(20.0f, -40.0f);
glVertex2f(60.0f, -20.0f);
glEdgeFlag(bEdgeFlag);
glVertex2f(20.0f, 0.0f);
glEdgeFlag(TRUE);

// Center square as two triangles
glEdgeFlag(bEdgeFlag);
glVertex2f(-20.0f, 0.0f);
glVertex2f(-20.0f,-40.0f);
glVertex2f(20.0f, 0.0f);

glVertex2f(-20.0f,-40.0f);
glVertex2f(20.0f, -40.0f);
glVertex2f(20.0f, 0.0f);
glEdgeFlag(TRUE);

// Done drawing Triangles
glEnd();


See Also
glBegin, glPolygonMode.


glEnd

Purpose
Terminates a list of vertices that specify a primitive initiated by glBegin.
Include File
<gl.h>
Syntax
void glEnd();
Description
This function is used in conjunction with glBegin to delimit the vertices of an OpenGL primitive. Multiple vertices sets may be included within a single glBegin/glEnd pair, as long as they are for the same primitive type. Other settings may also be made with additional OpenGL commands that affect the vertices following them. Only these OpenGL functions may be called within a glBegin/glEnd sequence: glVertex, glColor, glIndex, glNormal, glEvalCoord, glCallList, glCallLists, glTexCoord, glEdgeFlag, and glMaterial.
Returns
None.


Example
You can find this ubiquitous function in literally every example and supplementary sample in this chapter. The following code shows a single point being drawn at the origin of the x,y,z coordinate system.

glBegin(GL_POINTS)
glVertex3f(0.0f, 0.0f, 0.0f);
glEnd();


See Also
glBegin, glVertex


glFrontFace

Purpose
Defines which side of a polygon is the front or back.
Include File
<gl.h>
Syntax
void glFrontFace(GLenum mode);
Description
When a scene comprises objects that are closed
(you cannot see the inside), color or lighting calculations on the
inside of the object are unnecessary. The glCullFace function turns off
such calculations for either the front or back of polygons. The
glFrontFace function determines which side of the polygons is considered
the front. If the vertices of a polygon as viewed from the front are
specified so that they travel clockwise around the polygon, the polygon
is said have clockwise winding. If the vertices travel counterclockwise,
the polygon is said to have counterclockwise winding. This function
allows you to specify either the clockwise or counterclockwise wound
face to be the front of the polygon.


Parameters

mode

GLenum: Specifies the orientation of front-facing polygons: clockwise (GL_CW) or counterclockwise (GL_CCW).
Returns
None.


Example
The following code from the TRIANGLE example in this chapter shows how the color and drawing operations are disabled for the inside of the cone. It is also necessary to indicate which side of the triangles are the outside by specifying clockwise winding.

// Clockwise wound polygons are front facing, this is reversed
// because we are using triangle fans
glFrontFace(GL_CW);





// Turn culling on if flag is set
if(bCull)
glEnable(GL_CULL_FACE);
else
glDisable(GL_CULL_FACE);


See Also
glCullFace, glLightModel


glGetPolygonStipple

Purpose
Returns the current polygon stipple pattern.
Include File
<gl.h>
Syntax
void glGetPolygonStipple(GLubyte *mask);
Description
This function returns a 32 x 32-bit pattern
that represents the polygon stipple pattern. The pattern is copied to
the memory location pointed to by mask. The packing of the pixels is
affected by the last call to glPixelStore.


Parameters

*mask

GLubyte: A pointer to the polygon stipple pattern.
Returns
None.


Example
The following code segment retrieves the current stipple pattern:

GLubyte mask[32*4];
// 4 bytes = 32bits per row X 32 rows



glGetPolygonStipple(mask);


See Also
glPolygonStipple, glLineStipple, glPixelStore






Previous
Table of Contents
Next














 


Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.












Wyszukiwarka

Podobne podstrony:
173 176
173 21 (10)
173 00
173 23 (10)
173 17
173 19 (10)
1731f Budzet Panstwa
173 09 (9)
176 177
173 16 (2)

więcej podobnych podstron