Can someone tell me how to draw a sphere
if I have the data like this:
8 /* 8 triangles */
3 /* each has 3 points */
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000
1.000000 0.000000 0.000000
…
Thank you very much!
Can someone tell me how to draw a sphere
if I have the data like this:
8 /* 8 triangles */
3 /* each has 3 points */
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000
1.000000 0.000000 0.000000
…
Thank you very much!
Do you mean how to draw a geodesic type sphere using recursion?
gav
Use the GLU library, I don’t have time to explain so here is some example code, good luck … hope it helps…
#include <glu.h>
…
GLUquadricObj* p_Quadric = gluNewQuadric();
…
switch(drawMode)
{
case Points:
gluQuadricDrawStyle(p_Quadric,GLU_POINT);
break;
case Textured:
case Shaded:
gluQuadricDrawStyle(p_Quadric,GLU_FILL);
break;
case WireFrame:
gluQuadricDrawStyle(p_Quadric,GLU_LINE);
break;
}
…
if (drawMode==Textured)
{
glPushAttrib(GL_ENABLE_BIT);
glEnable(GL_TEXTURE_2D);
glPushMatrix();
gluQuadricDrawStyle(p_Quadric,GLU_FILL);
gluQuadricTexture(p_Quadric,GL_TRUE);
glPushAttrib(GL_TEXTURE_BIT);
m_Texture.bind();
gluSphere(p_Quadric,0.50f,m_NumSlices,m_NumStacks);
glPopAttrib();
glPopMatrix();
glPopAttrib();
}
else
{
glPushAttrib(GL_ENABLE_BIT);
glDisable(GL_TEXTURE_2D);
glEnable(GL_DEPTH_TEST);
glEnable(GL_LINE_SMOOTH);
gluSphere(p_Quadric,0.50f,m_NumSlices,m_NumStacks);
glPopAttrib();
}
Oops, add the following to cleanup …
gluDeleteQuadric(p_Quadric);