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 8 of 8

Thread: Depth_buffer

  1. #1
    Guest

    Depth_buffer

    I would like to use the DepthBuffer. I used this command to enable it:
    glDepthFunc(GL_LEQUAL);
    glEnable(GL_DEPTH_TEST );
    and in the main loop:
    glClear(GL_DEPTH_BUFFER_BIT);

    but it doesn't work and I would like to know why(I still see the rectangle that should be in the back in the front)? can someone help me?
    Thanx (sorry for my English...I'm Italian)

  2. #2
    Junior Member Regular Contributor
    Join Date
    Dec 2001
    Location
    Belmont, CA, USA
    Posts
    224

    Re: Depth_buffer

    Looks ok to me. I normally use the default GL_LESS.

    Maybe you are calling glDepthMask(GL_FALSE)?

  3. #3
    Junior Member Newbie
    Join Date
    Dec 2001
    Location
    Copenhagen, Denmark
    Posts
    22

    Re: Depth_buffer

    Or maybe you are looking in the opposite direction of what you think. Remember that the camera looks towards the negative z-axis so z=-1 is closer than z=-2

  4. #4
    Guest

    Re: Depth_buffer

    the same programm made under Visual C++ works...but with C++ (normal) it doesn't.

  5. #5
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    3,115

    Re: Depth_buffer

    Ehm, can you explain that one a bit more please. You say it works with Visual C++, but not with normal C++?

    Thing is, Visual C++ IS normal C++. The Visual part is just the name of Microsofts "normal" C++ compiler.

  6. #6
    Guest

    Re: Depth_buffer

    you're right...what I wanted to say is that the programm I made starting from zero, where I included only windows.h, gl.h and glu.h (where I copied the "open a window" part), it's seems that it doesn't use the detph buffer, even if I tell him to use it (with enable(DEPTH_BUFFER....bla...bla));while with a programm that start with all the classes already done (MFC) the openGL seem to use the depth buffer normally.

  7. #7
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    3,115

    Re: Depth_buffer

    Do you even ask for a depth buffer when creating the pixel format? If you don't ask for a depth buffer, you can't say for sure you will get one.

  8. #8
    Guest

    Re: Depth_buffer

    I found it! It' was my stupidity!...It's was glperspective(angle,aspect,near,far)...near and far should be positive...and I put 0.0 as value for near. I'm really sorry for stealing your time for such a stupid thing. Thax

Posting Permissions

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