Results 1 to 9 of 9

Thread: Any clues on why depth buffering isn't working for me?

  1. #1
    Junior Member Newbie
    Join Date
    May 2000
    Location
    Orlando, FL USA
    Posts
    4

    Any clues on why depth buffering isn't working for me?

    Hello all,

    I am using OpenGL 1.2 with an STB nVidia TNT card. I setup a double buffered GLUT window with a depth buffer by calling:
    glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );

    I then enable Depth testing by calling:
    glEnable( GL_DEPTH_TEST );

    And the first thing I do for each display callback is clear the depth buffer:
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    But all I get is a blank screen. If I disable depth testing, then my polygons are displayed by the reverse order in which they were drawn. It doesn't even seem to work properly on a machine with a Creative Labs TNT2 Ultra. Is this possibly a card/driver problem?

  2. #2
    Senior Member Regular Contributor
    Join Date
    Feb 2000
    Posts
    154

    Re: Any clues on why depth buffering isn't working for me?

    Have you set up the frustum?.. Specified near and far z plane?.

  3. #3
    Junior Member Newbie
    Join Date
    May 2000
    Location
    Orlando, FL USA
    Posts
    4

    Re: Any clues on why depth buffering isn't working for me?

    Yes. I'm using gluPerspective and have specified the near and far planes with that. I can verify that that part works correctly if I disable DEPTH_TEST and then move around.

  4. #4
    Senior Member OpenGL Guru Humus's Avatar
    Join Date
    Mar 2000
    Location
    Stockholm, Sweden
    Posts
    2,342

    Re: Any clues on why depth buffering isn't working for me?

    Have you set up any depthtest function with glDepthFunc()?

  5. #5
    Junior Member Newbie
    Join Date
    May 2000
    Location
    Orlando, FL USA
    Posts
    4

    Re: Any clues on why depth buffering isn't working for me?

    If one is not specified, it defaults to using GL_LESS. But I have tried calling glDepthFunc with all 8 variants - GL_LESS, GL_GREATER, etc. GL_NEVER appropriately gives a blank screen and GL_ALWAYS is the same as having no depth test.

    Using GL_GREATER actually seems to work appropriately. It gives a blank screen if I set glClearDepth( 1.0 ) and does proper drawing if I set glClearDepth( 0.0 ). But GL_LESS just gives a blank screen with either glClearDepth setting or if I don't specify one - which I believe defaults to 1.0. And, of course, GL_LESS is the one that I need to have working.

  6. #6
    Junior Member Newbie
    Join Date
    May 2000
    Location
    Orlando, FL USA
    Posts
    4

    Re: Any clues on why depth buffering isn't working for me?

    First off, let me thank AndersO and Humus for trying to help and all those that read this thread with the intent of helping.

    Second, I found my problem. A lesson learned the hard way for me is to not set your near clipping plane to 0. Bad and unexpected things can happen. So I set it to .1 and things work as they should.

  7. #7
    Member Contributor
    Join Date
    May 2000
    Posts
    72

    Re: Any clues on why depth buffering isn't working for me?

    Yeah, ANY number that quantitizes to > 0 (i.e. you FPU doesn't round it to zero) is fine

  8. #8
    Junior Member Newbie
    Join Date
    May 2000
    Location
    Taipei Taiwan
    Posts
    7

    Re: Any clues on why depth buffering isn't working for me?

    Originally posted by shillis:
    Hello all,

    I am using OpenGL 1.2 with an STB nVidia TNT card. I setup a double buffered GLUT window with a depth buffer by calling:
    glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );

    I then enable Depth testing by calling:
    glEnable( GL_DEPTH_TEST );

    And the first thing I do for each display callback is clear the depth buffer:
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    But all I get is a blank screen. If I disable depth testing, then my polygons are displayed by the reverse order in which they were drawn. It doesn't even seem to work properly on a machine with a Creative Labs TNT2 Ultra. Is this possibly a card/driver problem?

    You say you are using opengl 1.2.

    Where did you get the implementation?

  9. #9
    Member Contributor
    Join Date
    May 2000
    Posts
    72

    Re: Any clues on why depth buffering isn't working for me?

    I think he's just saying he's writing 1.2 code

Similar Threads

  1. FBO and Depth Buffering
    By Zulfiqar Malik in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 07-02-2005, 07:08 AM
  2. Depth buffering & transparency plz. help!
    By W. C. Picker in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 02-18-2003, 03:58 AM
  3. Depth Buffering Question
    By Roach in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 01-06-2003, 12:51 PM
  4. Depth Buffering - HELP !!
    By stockton in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 01-22-2002, 07:05 AM
  5. Depth Buffering
    By SpaceCadet in forum OpenGL: Advanced Coding
    Replies: 8
    Last Post: 04-26-2000, 08:05 PM

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