Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Depth test not working

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2014
    Posts
    21

    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.
    See screenshots:

    http://postimg.org/image/9kp5ltcx7/50d44327/
    http://postimg.org/image/t70ga5kw7/

    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?

  2. #2
    Junior Member Regular Contributor Agent D's Avatar
    Join Date
    Sep 2011
    Location
    Innsbruck, Austria
    Posts
    140
    Quote Originally Posted by esapir View Post
    glEnable(GL_DEPTH_TEST | GL_CULL_FACE);
    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).
    You have to call glEnable(GL_DEPTH_TEST) and glEnable(GL_CULL_FACE) seperately.

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2014
    Posts
    21
    Quote Originally Posted by Agent D View Post
    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).
    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.
    All works well now. thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •