Depth test not working
I am using OpenGL ES 2.0 on iOS. I enabled DEPTH_TEST, but still object that should be hidden are rendered.
In the seconds image, the green rectangle should be hidden by the red rectangle.
I use the following code in my rendering:
glClearColor(bgColor.r, bgColor.g, bgColor.b, bgColor.a);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST | GL_CULL_FACE);
What i could miss?
This is garbage. The constants GL_DEPTH_TEST (0x0B71) and GL_CULL_FACE (0x0B44) are not flags (GL_COLOR_BUFFER_BIT and GL_DEPTH_BUFFER_BIT are, hence the _BIT).
Originally Posted by esapir
You have to call glEnable(GL_DEPTH_TEST) and glEnable(GL_CULL_FACE) seperately.
You are correct of course. I had another bug that i fixed after that.
Originally Posted by Agent D
All works well now. thanks!