Original Post
I want to create my own sphere object, but it's not working. I've basically wrapped a gluSphere inside a CSphere class for future functionality. Everything else basically follows the NeHe tutorials. It compiles fine under VC++ 2005, but the sphere does not render. Here's what I have so far. Declaration: Definition: And finally, the DrawGLScene function: If anyone has any ideas why this might be the case, I would be most grateful to hear them. [Edited by - dreamtwister on May 11, 2007 12:40:28 AM]
class CSphere
{
public:
CSphere(float fRadius , int nLats , int nLongs );
~CSphere();
void Draw();
private:
float m_fRadius;
int m_nLats;
int m_nLongs;
};
CSphere::CSphere(float fRadius , int nLats , int nLongs)
{
m_fRadius = fRadius;
m_nLats = nLats;
m_nLongs = nLongs;
}
CSphere::~CSphere()
{
}
void CSphere::Draw()
{
GLUquadricObj *ball;
ball = gluNewQuadric();
gluQuadricNormals(ball,GLU_SMOOTH);
gluQuadricTexture(ball,true);
gluSphere(ball, m_fRadius, m_nLats, m_nLongs);
gluDeleteQuadric(ball);
}
bool DrawGLScene(GLvoid)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0f,0.0f,-40.0f);
glColor3f(1.0,1.0f,1.0f);
theSphere.Draw();
return true;
}