Jump to content
Posted 16 February 2013 - 08:51 AM
Posted 16 February 2013 - 09:44 AM
Your objects, while defined in a 3D space, are still being drawn on a 2D display. So what happens is OpenGL draws the first object it comes across (first in your script) and then draws the second object it comes across (second in your script). I believe GL_DEPTH_TEST is supposed to check where in the 3D world the object is so when it renders the object, it knows what order to do it in. You could do this yourself by simply testing which object is further from the camera and render it first, find the next closest object and render that next, and so on until they're all rendered. I wouldn't recommend it though because as your scene gets more complicated, you'll just run into more issues. But that's what OpenGL is for.
Your problem is likely you haven't enabled a depth buffer for your rendering context. Something like this (from http://nehe.gamedev.net/tutorial/creating_an_opengl_window_%28win32%29/13001/):
glClearDepth(1.0f); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL);
If you're having any more issues, posting your code will help.
Edited by akciom, 16 February 2013 - 09:45 AM.
Posted 16 February 2013 - 12:16 PM
And when I enable:
and in loop i have: glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
I see this:
Edited by QIZI94, 16 February 2013 - 12:17 PM.