📄 appendixc.html
字号:
coordinates, and <I>data</I> is an arbitrary pointer that's sent to the
callback associated with GLU_VERTEX. Typically, it contains vertex data,
texture coordinates, color information, or whatever else the application
may find useful.
<P>void <B>gluNextContour</B>(GLUtriangulatorObj *<B>tessobj</B>, GLenum
<B>type</B>);
<P>Marks the beginning of the next contour when multiple contours make
up the boundary of the polygon to be tessellated. <I>type</I> can be GLU_EXTERIOR,
GLU_INTERIOR, GLU_CCW, GLU_CW, or GLU_UNKNOWN. These serve only as hints
to the tessellation. If you get them right, the tessellation might go faster.
If you get them wrong, they're ignored, and the tesselation still works.
For a polygon with holes, one contour is the exterior contour and the others
interior. <B>gluNextContour()</B> can be called immediately after <B>gluBeginPolygon()</B>,
but if it isn't, the first contour is assumed to be of type GLU_EXTERIOR.
GLU_CW and GLU_CCW indicate clockwise- and counterclockwise- oriented polygons.
Choosing which are clockwise and which are counterclockwise is arbitrary
in three dimensions, but in any plane, there are two different orientations,
and the GLU_CW and GLU_CCW types should be used consistently. Use GLU_UNKNOWN
if you don't have a clue.
<P>void <B>gluEndPolygon</B>(GLUtriangulatorObj *<B>tessobj</B>);
<P>Indicates the end of the polygon specification and that the tessellation
can begin using the tessellation object <B>tessobj</B>.
<P>
<HR>
<H2>
Rendering Spheres, Cylinders, and Disks</H2>
The GLU includes a set of routines to draw various simple surfaces (spheres,
cylinders, disks, and parts of disks) in a variety of styles and orientations.
These routines are described in detail in the <I>OpenGL Reference Manual</I>;
their use is discussed briefly in the following paragraphs, and their prototypes
are also listed.
<P>To create a quadric object, use <B>gluNewQuadric()</B>. (To destroy
this object when you're finished with it, use <B>gluDeleteQuadric()</B>.)
Then specify the desired rendering style, as follows, with the appropriate
routine (unless you're satisfied with the default values):
<UL>Whether surface normals should be generated, and if so, whether there
should be one normal per vertex or one normal per face: <B>gluQuadricNormals()</B>
<BR>
<P>Whether texture coodinates should be generated: <B>gluQuadricTexture()</B>
<BR>
<P>Which side of the quadric should be considered the outside and which
the inside: <B>gluQuadricOrientation()</B>
<BR>
<P>Whether the quadric should be drawn as a set of polygons, lines, or
points: <B>gluQuadricDrawStyle()</B></UL>
After you've specified the rendering style, simply invoke the rendering
routine for the desired type of quadric object<B>: gluSphere()</B>, <B>gluCylinder()</B>,
<B>gluDisk()</B>, or <B>gluPartialDisk()</B>. If an error occurs during
rendering, the error-handling routine you've specified with <B>gluQuadricCallBack()</B>
is invoked.
<P>It's better to use the <B>*Radius</B>, <B>height</B>, and similar arguments
to scale the quadrics rather than the <B>glScale*()</B> command, so that
unit-length normals that are generated don't have to be renormalized. Set
the <B>loops</B> and <B>stacks</B> arguments to values other than 1 to
force lighting calculations at a finer granularity, especially if the material
specularity is high.
<P>The prototypes are listed in three categories.
<P>Manage quadric objects:
<DL>
<DT>
GLUquadricObj* <B>gluNewQuadric</B> (void);</DT>
<DD>
</DD>
<DT>
</DT>
<BR>void <B>gluDeleteQuadric</B> (GLUquadricObj *<I>state</I>);
<DD>
</DD>
<DT>
</DT>
<BR>void <B>gluQuadricCallback</B> (GLUquadricObj *<I>qobj</I>, GLenum
<I>which</I>, void (*<I>fn</I>)());
<DD>
</DD>
</DL>
Control the rendering:
<DL>
<DT>
void <B>gluQuadricNormals</B> (GLUquadricObj *<I>quadObject</I>, GLenum
<I>normals</I>);</DT>
<DD>
</DD>
<DT>
</DT>
<BR>void <B>gluQuadricTexture</B> (GLUquadricObj *<I>quadObject</I>, GLboolean
<I>textureCoords</I>);
<DD>
</DD>
<DT>
</DT>
<BR>void <B>gluQuadricOrientation</B> (GLUquadricObj *<I>quadObject</I>,
GLenum <I>orientation</I>);
<DD>
</DD>
<DT>
</DT>
<BR>void <B>gluQuadricDrawStyle</B> (GLUquadricObj *<I>quadObject</I>,
GLenum <I>drawStyle</I>);
<DD>
</DD>
</DL>
Specify a quadric primitive:
<DL>
<DT>
void <B>gluCylinder</B> (GLUquadricObj *<I>qobj</I>, GLdouble <I>baseRadius</I>,
GLdouble <I>topRadius</I>, GLdouble <I>height</I>, GLint <I>slices</I>,
GLint <I>stacks</I>);</DT>
<DD>
</DD>
<DT>
</DT>
<BR>void <B>gluDisk</B> (GLUquadricObj *<I>qobj</I>, GLdouble <I>innerRadius</I>,
GLdouble <I>outerRadius</I>, GLint <I>slices</I>, GLint <I>loops</I>);
<DD>
</DD>
<DT>
</DT>
<BR>void <B>gluPartialDisk</B> (GLUquadricObj *<I>qobj</I>, GLdouble <I>innerRadius</I>,
GLdouble <I>outerRadius</I>, GLint <I>slices</I>, GLint <I>loops</I>, GLdouble
<I>startAngle</I>, GLdouble <I>sweepAngle</I>);
<DD>
</DD>
<DT>
</DT>
<BR>void <B>gluSphere</B> (GLUquadricObj *<I>qobj</I>, GLdouble <I>radius</I>,
GLint <I>slices</I>,GLint <I>stacks</I>);
<DD>
</DD>
</DL>
<HR>
<H2>
NURBS Curves and Surfaces</H2>
NURBS routines provide general and powerful descriptions of curves and
surfaces in two and three dimensions. They're used to represent geometry
in many computer-aided mechanical design systems. The GLU NURBS routines
can render such curves and surfaces in a variety of styles, and they can
automatically handle adaptive subdivision that tessellates the domain into
smaller triangles in regions of high curvature and near silhouette edges.
All the GLU NURBS routines are described in Chapter 9 ; their prototypes
are listed here.
<P>Manage a NURBS object:
<DL>
<DT>
GLUnurbsObj* <B>gluNewNurbsRenderer</B> (void);</DT>
<DD>
</DD>
<DT>
</DT>
<BR>void <B>gluDeleteNurbsRenderer</B> (GLUnurbsObj *<I>nobj</I>);
<DD>
</DD>
<DT>
</DT>
<BR>void <B>gluNurbsCallback</B> (GLUnurbsObj *<I>nobj</I>, GLenum <I>which</I>,
void (*<I>fn</I>)());
<DD>
</DD>
</DL>
Create a NURBS curve:
<DL>
<DT>
void <B>gluBeginCurve</B> (GLUnurbsObj *<I>nobj</I>);</DT>
<DD>
</DD>
<DT>
</DT>
<BR>void <B>gluEndCurve</B> (GLUnurbsObj *<I>nobj</I>);
<DD>
</DD>
<DT>
</DT>
<BR>void <B>gluNurbsCurve</B> (GLUnurbsObj *<I>nobj</I>, GLint <I>nknots</I>,
GLfloat *<I>knot</I>, GLint <I>stride</I>, GLfloat *<I>ctlarray</I>, GLint
<I>order</I>, GLenum <I>type</I>);
<DD>
</DD>
</DL>
Create a NURBS surface:
<DL>
<DT>
void <B>gluBeginSurface</B> (GLUnurbsObj *<I>nobj</I>);</DT>
<DD>
</DD>
<DT>
</DT>
<BR>void <B>gluEndSurface</B> (GLUnurbsObj *<I>nobj</I>);
<DD>
</DD>
<DT>
</DT>
<BR>void <B>gluNurbsSurface</B> (GLUnurbsObj *<I>nobj</I>, GLint <I>uknot_count</I>,
GLfloat *<I>uknot</I>, GLint <I>vknot_count</I>, GLfloat *<I>vknot</I>,
GLint <I>u_stride</I>, GLint <I>v_stride</I>, GLfloat *<I>ctlarray</I>,
GLint <I>uorder</I>, GLint <I>vorder</I>, GLenum <I>type</I>);
<DD>
</DD>
</DL>
Define a trimming region:
<DL>
<DT>
void <B>gluBeginTrim</B> (GLUnurbsObj *<I>nobj</I>);</DT>
<DD>
</DD>
<DT>
</DT>
<BR>void <B>gluEndTrim</B> (GLUnurbsObj *<I>nobj</I>);
<DD>
</DD>
<DT>
</DT>
<BR>void <B>gluPwlCurve</B> (GLUnurbsObj *<I>nobj</I>, GLint <I>count</I>,
GLfloat *<I>array</I>, GLint <I>stride</I>, GLenum <I>type</I>);
<DD>
</DD>
</DL>
Control NURBS rendering:
<DL>
<DT>
void <B>gluLoadSamplingMatrices</B> (GLUnurbsObj *<I>nobj</I>, const GLfloat
<I>modelMatrix</I>[16], const GLfloat <I>projMatrix</I>[16], const GLint
<I>viewport</I>[4]);</DT>
<DD>
</DD>
<DT>
</DT>
<BR>void <B>gluNurbsProperty</B> (GLUnurbsObj *<I>nobj</I>, GLenum <I>property</I>,
GLfloat <I>value</I>);
<DD>
</DD>
<DT>
</DT>
<BR>void <B>gluGetNurbsProperty</B> (GLUnurbsObj *<I>nobj</I>, GLenum <I>property</I>,
GLfloat *<I>value</I>);
<DD>
</DD>
</DL>
<HR>
<H2>
Describing Errors</H2>
The GLU provides a routine for obtaining a descriptive string for an error
code. For information about OpenGL's error handling facility, see "Error
Handling." const GLubyte*<B> gluErrorString</B>(GLenum <B>errorCode</B>);
<P>Returns a pointer to a descriptive string that corresponds to the OpenGL,
GLU, or GLX error number passed in <B>errorCode</B>. The defined error
codes are described in the <I>OpenGL Reference Manual</I> along with the
command or routine that can generate them.
<P>
<HR><A HREF="appendixb.html">[Previous chapter]</A> <A HREF="appendixd.html">[Next
chapter]
<HR></A>See the <A HREF="about.html">About</A> page for copyright, authoring
and distribution information.
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -