Reputation: 18918
I have been experimenting with OpenGL, trying to draw spheres inside and outside of rectangular prisms. The problem is, no matter where I choose to draw the spheres, the grid is always laid on top of my circles, as can be seen below:
What I am doing right now is basically using glTranslatef
to initially translate everything 100 units in the negative z direction, then using GL_LINE_STRIP
to draw the lines that make up the prism, and finally using glTranslatef
and glusphere
to create the circles. The prism is supposed to extend from -50 to 0 on the z axis, and the sphere nearer the middle is supposed to be located at (30, 30, 0), while the sphere near the corner is supposed to be located at (50, 50, 5).
Is there anything wrong with this approach?
Upvotes: 0
Views: 457
Reputation: 33262
Did you call glEnable(GL_DEPTH_TEST)
in your rendering function ?
Upvotes: 4