As you can see: https://i.stack.imgur.com/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?
Asked
Active
Viewed 1,713 times
3 Answers
5
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 .

Community
- 1
- 1

Jonas Bötel
- 4,452
- 1
- 19
- 28
0
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.

SuperMaximo93
- 2,036
- 1
- 16
- 7
-
3There's no such thing like "initialization" in OpenGL, it's all about state. Sure some things like textures, FBOs, PBOs and VBOs are created and then reused. But in any real OpenGL application this happens on demand, too. State like enabling/disabling depth testing and the depth func should be set in the rendering function right before the part that requires some particular state. – datenwolf Apr 30 '11 at 10:41
0
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.

Neigyl R. Noval
- 6,018
- 4
- 27
- 45