I'm using GLUT to work with OpenGL (would work with SDL if I could). And I need to draw sphere. I'm using gluSphere
but it simply doesn't draw anything.
Here's my GLUT initialization:
// Initializes display
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(600, 600);
// Window settings
glutCreateWindow("Collision detect");
glClearColor(0.0, 0.0, 0.0, 1.0);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glEnable(GL_TEXTURE_2D);
Quadratic initialization:
quadratic = gluNewQuadric();
if( !quadratic){
throw new PROGRAM_EXCEPTION( "Cannot initialize quadartic", NULL);
}
gluQuadricNormals(quadratic, GLU_SMOOTH);
//gluQuadricDrawStyle( quadratic, GLU_FILL);
gluQuadricTexture(quadratic, GL_TRUE); // Tried both GL_TRUE and GL_FALSE
And my draw function:
glPushMatrix();
glTranslatef( position.getX(), position.getY(), position.getZ());
// This commented piece of code draws dot where I want it to,
// so coordinates and camera position are just fine
// glBegin(GL_POINTS);
// glVertex3f( 0,0,0);
// glEnd();
gluSphere( quadratic, 20.0f, 32, 32); // Tried r = 0.02f, 0.2f, 2.0f, 20.0f, none works
glPopMatrix();
Question: what am I missing? Is there some trick in glut to enable quadratics to draw? Is it incompatible with some of my settings?
I've spent several hours trying to sort this out, tried different things... If you need some other piece of code, just say which... I don't want to paste 2000 lines here. And one more thing, I've triple check, I'm not using it inside glBegin()
and glEnd()
. I have few triangles enclosing the space and they draw just fine.
Question: what am I missing?
How about setting up a viewport and projection?