Table of Contents Glide Programming Guide



Download 6.22 Mb.
Page27/106
Date03.02.2023
Size6.22 Mb.
#60547
1   ...   23   24   25   26   27   28   29   30   ...   106
GLIDEPGM

7Convex Polygons


A polygon is a planar area enclosed by a closed loop of line segments, specified by their endpoints. While the Voodoo Graphics hardware does not render polygons directly, Glide provides a set of polygon rendering functions that are optimized for the hardware. The polygons rendered by the Glide functions are subject to some strong restrictions:

  • The edges of the polygon cannot intersect.

  • The polygon must be convex, that is, have no indentations. (The glossary at the end of this manual gives a precise definition of convexity.)

Figure Rendering Primitives.3 shows some examples of both valid and invalid polygons.
Figure Rendering Primitives.3 Polygons.

The convex polygons rendered by Glide are assumed to be planar in coordinate space. Two polygon rendering routines, (grDrawPlanarPolygon() and grDrawPlanarPolygonVertexList()), require that the rendering parameters (r, g, b, a, ooz, oow, sow, tow) be planar as well. None of the polygon rendering functions do any geometric clipping.


void grDrawPlanarPolygon( int nVerts, int ilist[], const GrVertex vlist[] )

void grDrawPolygon( int nVerts, int ilist[], const GrVertex vlist[] )


grDrawPlanarPolygon() and grDrawPolygon() both render a convex polygon with nVerts vertices. The second argument, ilist, is an array of indices into the list of vertices provided in the third argument. This level of indirection in specifying vertices is useful if you need to pre-process the list to do geometric clipping or hidden surface removal. The preprocessor can create the ilist for you rather than copying selected vertices to a new list.
grDrawPlanarPolygon() assumes that the vertex parameters for the polygon are planar. Parameter gradients will be calculated only once for the entire polygon, thus reducing the number of calculations significantly.
Another pair of polygon rendering functions defined in Glide, grDrawPlanarPolygonVertexList() and grDrawPolygonVertexList(), are functionally equivalent to grDrawPlanarPolygon () and grDrawPolygon(), respectively. The difference between the two pairs of routines is the way the vertices are specified.
void grDrawPlanarPolygonVertexList( int nVerts, const GrVertex vlist[] )
void grDrawPolygonVertexList( int nVerts, const GrVertex vlist[] )

There is no level of indirection in grDrawPlanarPolygonVertexList() and grDrawPolygonVertexList(). The ith vertex of the polygon passed to these routines is vlist[I], assuming that 0£I<nVerts, whereas the ith vertex of a polygon passed to grDrawPlanarPolygon () or grDrawPolygon() is vlist[ilist[I]].



Download 6.22 Mb.

Share with your friends:
1   ...   23   24   25   26   27   28   29   30   ...   106




The database is protected by copyright ©ininet.org 2024
send message

    Main page