IRIS GL Sphere 库
OpenGL 不支持 IRIS GL 球体库。 可以将球体库调用替换为 GLU 库中的 quadrics 例程。 有关 GLU 库的详细信息,请参阅 Open GL 编程指南 和 OpenGL 实用工具库。
下表列出了 OpenGL quadrics 函数。
OpenGL 函数 | 含义 |
---|---|
gluNewQuadric | 创建新的四边形对象。 |
gluDeleteQuadric | 删除一个 quadric 对象。 |
gluQuadricCallback | 将回调与 quadric 对象关联,以便进行错误处理。 |
gluQuadricNormals | 指定法线:无法线、每个面一个或每个顶点一个。 |
gluQuadricOrientation | 指定法线方向:向外或向内。 |
gluQuadricTexture | 打开或关闭纹理坐标生成。 |
gluQuadricDrawstyle | 指定绘图样式:多边形、线条、点等。 |
gluSphere | 绘制球体。 |
gluCylinder | 绘制一个圆柱体或圆锥。 |
gluPartialDisk | 绘制弧线。 |
gluDisk | 绘制圆或磁盘。 |
对于要以类似方式呈现的所有四边形,可以使用一个 quadric 对象。 下面的代码示例使用两个四边形对象绘制四个四边形,其中两个四边形经过纹理处理。
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);