I\'m unable to get the depth buffer working correctly on Android OpenGL ES 2.0. Regardless of what I do, the objects are always render in the order provided and completely i
Have you specified the buffer depth? This might be the solution to your problem.
myGlSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
harism's comment was the correct answer. The below three functions can only be done once you have a rendering context. I put them in the onSurfaceCreated method and it works. You can also put them in the onDraw method if you change them during rendering.
GLES20.glEnable( GLES20.GL_DEPTH_TEST );
GLES20.glDepthFunc( GLES20.GL_LEQUAL );
GLES20.glDepthMask( true );
I had the same problem. I fixed it by using a 24-bit depth buffer instead of the default, which is 16 bits (so selecting a 16-bit depth buffer won't make any difference). I used
myGlSurfaceView.setEGLConfigChooser(8,8,8,8,24,0);
Incidentally I had the same problem, with effectively the same solution, on iOS (my code is a portable map renderer, so I need it to run on lots of platforms). The iOS fix was to call
self.drawableDepthFormat = GLKViewDrawableDepthFormat24;
in the init function of my GLKView-derived class.