So I am doing some OpenGL experimentation using this tutorial but I am running into an issue, for some reason the depth of my vertices doesn’t seem to matter in how they are drawn. In the screenshot below the cubes have the same size, however the larger cube is closer to the screen. I believe it should be occluding the smaller cube, but it is not. I have followed the code in the tutorial almost exactly, is there anything obviously wrong?
http://games.ianterrell.com/opengl-basics-with-glkit-in-ios5-encapsulated-drawing-and-animation/
You probably set up your GLKView without a depth buffer. GLKView has a propery
drawableDepthFormatthat controls creation and precision of the drawable’s depth buffer. The default value isGLKViewDrawableDepthFormatNonewhich is good for 2D compositing.When you want to draw 3D objects you should set it to
GLKViewDrawableDepthFormat16orGLKViewDrawableDepthFormat24if you need more depth precision.