Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 02 Dec 2012
Offline Last Active Mar 02 2013 10:52 AM

Posts I've Made

In Topic: Object behind another object

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/):




If you're having any more issues, posting your code will help.