GLU Quadrics Objects
GLUquadricObj * pointTool;
// create the rendering tool
pointTool=gluNewQuadric();
gluQuadricDrawStyle(pointTool,GLU_POINT);
// delete the rendering tool
gluDeleteQuadric(pointTool);
The default drawing style is to fill in shapes using polygon and triangle strip primitives, GLU_FILL
GLU_FILL |
Fill in using polygon and triangle strip primitives. |
GLU_LINE |
Render wireframe objects using line primitives. |
GLU_SILHOUETTE |
Render using line primitives, render only outside edges. |
GLU_POINT |
Render using point primitives. |
We can generate lighting normals for quadrics.
void gluQuadricNormals(GLUquadricObj * obj, GLenum mode)
mode |
---|
GLU_NONE |
No lighting normals. |
GLU_FLAT |
Lighting normals generated for each polygon - faceted appearance. |
GLU_SMOOTH |
Lighting normals generated for each vertex - smooth appearance. |
We can control the direction of lighting normals eg. may be inside or outside a sphere.
gluQuadricOrientation(fillTool,GLU_OUTSIDE);
gluQuadricOrientation(fillTool,GLU_INSIDE);
Cylinder
void gluCylinder(GLUquadricObj * obj,
GLdouble baseRadius, GLdouble topRadius,
GLdouble height,
GLint slices, GLint stacks)
The cylinder is projected height units along the positive z-axis.
slices: subdivisions around the cylinder (sides) - 20 = fairly smooth curve, otherwise faceted appearance
stacks: subdivisions along cylinder - set high for spotlights or lots of specular light (20), otherwise set to 2 for top and bottom
Make cones by specifying a top or bottom radius of 0.0.
Ends of cylinder not filled in. Fill them in with disks if you wish.
void gluDisk(GLUquadricObj *obj,
GLdouble innerRadius, GLdouble outerRadius,
GLint slices, GLint loops)
innerRadius
and outerRadius
control the size of the hole and disk.
Set innerRadius
to 0.0 to render a solid circle.
slices: number of sides to disk (eg. 3 for equilateral triangle, 6 for a washer 20 for a circle).
loops: number of concentric rings rendered eg. 1 for circles 2 for washers. Using larger values for loops improves specular lighting and the effect of spotlights.
void gluPartialDisk(GLUquadricObj *obj,
GLdouble innerRadius, GLdouble outerRadius,
GLint slices, GLint loops,
GLdouble startAngle, GLdouble sweepAngle)
startAngle: clockwise angle in degrees from the top of the disk
sweepAngle: number of degrees of arc to draw eg. 90o is a quarter disk
void gluSphere(GLUquadricObj *obj,
GLdouble radius,
GLint slices,GLint stacks)
slices: longitude stacks: latitude
Fran Soddell
email:F.Soddell@bendigo.latrobe.edu.au
last updated 17 September 2002