Reputation: 1437
As you can see: https://i.sstatic.net/ztM0v.png, certain polygons are simply being rendered over the other ones. Does anyone have any suggestions or related reading on rendering these in the correct order so that they do not overlap?
Upvotes: 0
Views: 1755
Reputation: 6038
You should make sure that you have set the matrix mode in projection view or 3d and work with 3d always.
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(p, (double) w / (double) h, arg1, arg2);
Then make sure you enable depths by this:
glEnable(GL_DEPTH_TEST);
Next, render using GL...3f or GL...3d to render through 3d, where ... is whatever function you need.
Upvotes: 0
Reputation: 4482
For opaque faces render order is not important as long as you use the depth buffer.
NeHe has a tutorial covering all the basics. Start here http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=02
See also Opengl Depth buffer and Culling and Depth Buffer in OpenGL .
Upvotes: 5
Reputation: 2056
You need to enable depth testing. Make sure that
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL); //Maybe not this line but try it anyway, GL_DEPTH_TEST is the important one
is in your initialisation code.
Upvotes: 0