This works fine:
void draw_sphere()
{
GLUquadric* m_sphere_quad = gluNewQuadric();
glColor3f(1.0, 1.0, 0.0);
gluSphere(m_sphere_quad, 30.0, 15, 15);
gluDeleteQuadric(m_sphere_quad);
}
This crashes on gluSphere() call:
// sphere.h
class sphere
{
GLUquadric *m_quad;
public:
sphere();
~sphere();
void draw();
};
// sphere.cpp
sphere::sphere()
{
m_quad = gluNewQuadric();
}
void sphere::draw()
{
glColor3f(1.0, 1.0, 0.0);
gluSphere(m_quad, 30.0, 15, 15); // Crashes even though m_quad != NULL
}
Is there any reason why the GLUquadric pointer can’t be a member of a class?
thanks,
graham