Reputation: 422
When working with glut, i used glutsolidsphere to draw my spheres, but having moved to glfw, i had to use glusphere. I basically copied the entire function "glutsolidsphere" to my own code, but am getting a strange lighting problem where before i wasn't. Heres the code for the sphere :
void drawSolidSphere(GLdouble radius, GLint slices, GLint stacks)
{
GLUquadric *shape = gluNewQuadric();
gluQuadricDrawStyle(shape, GLU_FILL);
gluQuadricNormals(shape, GLU_SMOOTH);
gluSphere(shape, radius, slices, stacks);
}
Whats the problem here?
Edit : For some reason, i cant upload images from college, so i'll try describe it : The sphere outline looks fine, however you can see the segments on the inside, like the outside of the sphere is transparent, and it causes there to be clear divides in the sphere.
Upvotes: 0
Views: 1771
Reputation: 17266
Looks like there's a problem with depth testing.
Assuming you have a depth buffer from glfw, does this fix it?
glEnable(GL_DEPTH_TEST);
I haven't used glfw, but to request a depth buffer it looks like you just need to pass 24 for example to the depthbits
argument of glfwOpenWindow
.
You will also need to add GL_DEPTH_BUFFER_BIT
to your glClear
call if you haven't already.
I've experienced inconsistencies with the default GL state, specifically GL_DEPTH_TEST, across windows and linux using glut/freeglut before.
Also, see gluNewQuadric leaking memory
Upvotes: 1