Results 1 to 5 of 5

Thread: No Depth Testing

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2002
    Location
    Boulder, CO USA
    Posts
    5

    No Depth Testing

    For some reason z-buffering/depth testing isn't working in my current project. Polygons display properly except ones in the back can cover up ones in the front. I have had this work in other projects by just putting:

    glClearDepth(1.0);
    glDepthFunc(GL_LESS);
    glEnable(GL_DEPTH_TEST);

    in the setup. However, projects I was using before used GLUT and this one does not. Is there something I'm missing? I don't want to use GLUT.
    Thanks,

    Keenan Crane

  2. #2
    Member Contributor
    Join Date
    Oct 2001
    Posts
    67

    Re: No Depth Testing

    Just to be sure...

    Are you sure the pixelformat you're using has a depth buffer?

    You mentioned you were using glut before and now you aren't, which is the only reason I'm asking...

  3. #3
    Junior Member Newbie
    Join Date
    Jun 2002
    Location
    Boulder, CO USA
    Posts
    5

    Re: No Depth Testing

    No, I'm not sure the pixelformat has a depth buffer and I'm also not sure how to check whether it does and how to set it so it does! I'm using a skeleton project so I'm not completely sure how it's set up. What specifically should I look for?
    Thanks,

    Keenan Crane

  4. #4
    Junior Member Newbie
    Join Date
    Jun 2002
    Location
    Boulder, CO USA
    Posts
    5

    Re: No Depth Testing

    Well here's what I found, so it looks like I should have a depth buffer:

    class GLContext
    {
    const CGLPixelFormatAttribute* GetPixelFormat(u_int32_t display_id = 0x01, int color = settings.depth, int depth = 0, int stencil = 0)
    {
    static CGLPixelFormatAttribute attribs[32];

    CGLPixelFormatAttribute* attrib = attribs;

    *attrib++ = kCGLPFANoRecovery;
    *attrib++ = kCGLPFADoubleBuffer;
    *attrib++ = kCGLPFAAccelerated;
    *attrib++ = kCGLPFAFullScreen;
    *attrib++ = kCGLPFADisplayMask; *attrib++ = (CGLPixelFormatAttribute) display_id;
    *attrib++ = kCGLPFAColorSize; *attrib++ = (CGLPixelFormatAttribute) color;
    *attrib++ = kCGLPFADepthSize; *attrib++ = (CGLPixelFormatAttribute) depth;
    *attrib++ = kCGLPFAStencilSize; *attrib++ = (CGLPixelFormatAttribute) stencil;
    *attrib++ = (CGLPixelFormatAttribute) 0;

    return attribs;
    }
    ...
    }


    which is later called by:

    CGLError err = CGLChoosePixelFormat(GetPixelFormat(display_id, 32), &pixel_format, &num_pixel_formats);


    Thanks!

  5. #5
    Junior Member Newbie
    Join Date
    Jun 2002
    Location
    Boulder, CO USA
    Posts
    5

    Re: No Depth Testing

    Ok, sorry once again - I set depth = 16 and it works.

Similar Threads

  1. Stencil-op depth fail with depth testing disabled
    By AvCol in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 01-22-2011, 09:48 PM
  2. depth testing with FBO
    By kreyszig in forum OpenGL: Advanced Coding
    Replies: 9
    Last Post: 10-07-2008, 04:21 PM
  3. Depth testing: How to
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 12-05-2001, 10:32 AM
  4. ATI HWA Depth Testing
    By G4Soon in forum OpenGL: macOS
    Replies: 4
    Last Post: 02-21-2001, 06:37 PM
  5. Depth Testing
    By j in forum OpenGL: Advanced Coding
    Replies: 14
    Last Post: 02-05-2001, 06:26 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean