Egy Win SDK példa

Top  Previous  Next

 

 

The IRIS GL Sphere Library

 

OpenGL doesn't support the IRIS GL sphere library. You can replace your sphere library calls with quadrics routines from the GLU library. For more information about the GLU library, see the Open GL Programming Guide and GLU.

 

The following table lists the OpenGL quadrics functions.

 

OpenGL Call        Meaning

gluNewQuadric        Create a new quadric object.

gluDeleteQuadric        Delete a quadric object.

gluQuadricCallback        Associate a callback with a quadric object, for error handling.

gluQuadricNormals        Specify normals: no normals, one per face, or one per vertex.

gluQuadricOrientation        Specify direction of normals: outward or inward.

gluQuadricTexture        Turn texture-coordinate generation on or off.

gluQuadricDrawstyle        Specify drawing style: polygons, lines, points, and so on.

gluSphere                Draw a sphere.

gluCylinder                Draw a cylinder or cone.

gluPartialDisk        Draw an arc.

gluDisk                Draw a circle or disk.

 

 

You can use one quadric object for all quadrics you want to render in similar ways. The following code fragment uses two quadric objects to draw four quadrics, two of them textured.

 

GLUquadricObj    *texturedQuad, *plainQuad;

 

texturedQuad = gluNewQuadric(void);

gluQuadricTexture(texturedQuad, GL_TRUE);

gluQuadricOrientation(texturedQuad, GLU_OUTSIDE);

gluQuadricDrawStyle(texturedQuad, GLU_FILL);

 

plainQuad = gluNewQuadric(void);

gluQuadricDrawStyle(plainQuad, GLU_LINE);

 

glColor3f (1.0, 1.0, 1.0);

 

gluSphere(texturedQuad, 5.0, 20, 20);

glTranslatef(10.0, 10.0, 0.0);

gluCylinder(texturedQuad, 2.5, 5, 5, 10, 10);

glTranslatef(10.0, 10.0, 0.0);

 

gluDisk(plainQuad, 2.0, 5.0, 10, 10);

glTranslatef(10.0, 10.0, 0.0);

gluSphere(plainQuad, 5.0, 20, 20);