Results 1 to 10 of 10

Thread: Purpose of glClearDepth

  1. #1
    Member Contributor
    Join Date
    Mar 2001
    Posts
    50

    Purpose of glClearDepth

    The documentation indicates that "The glClearDepth function specifies the clear value for the depth buffer" and that it is clamped to the range [0,1]. So what does setting the depth buffer clear value do?

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jun 2000
    Location
    Shreveport, LA, USA
    Posts
    1,502

    Re: Purpose of glClearDepth

    Well, it does exactly what the description says. You use it to specify the value used when the depth buffer is cleared. And if you try to set it to a value less than 0, it will use 0, and if you try to set it to a value greater than 1, it will use 1.

  3. #3
    Member Contributor
    Join Date
    Mar 2001
    Posts
    50

    Re: Purpose of glClearDepth

    I understand that. What I mean to ask is what physical difference will be noticed when I use 0.5 as opposed to 1.0 and 0.0?

  4. #4
    Junior Member Newbie
    Join Date
    Aug 2001
    Posts
    11

    Re: Purpose of glClearDepth

    When you clear the depth buffer if you have this value set to 0 nothing will get cleared. If you have it set to 1 (the default) everything gets cleared. Anything in between clears part of the depth buffer (remember z depth is not linear).

  5. #5
    Senior Member OpenGL Pro
    Join Date
    Jun 2000
    Location
    Shreveport, LA, USA
    Posts
    1,502

    Re: Purpose of glClearDepth

    Unless I'm mistaken, the value used to clear the depth buffer does not affect in any way how much of it gets cleared when using glClear. glClear will clear the entire depth buffer by writing the value to all pixels. Just like selecting the color clear value doesn't affect how much of the color buffer gets cleared, the depth clear value does not determine how much of the depth buffer gets cleared.

  6. #6
    Senior Member Regular Contributor
    Join Date
    Dec 1969
    Location
    Munich,Germany
    Posts
    227

    Re: Purpose of glClearDepth

    DFrey I don't think you are mistaken . glClearDepth clears the complete DepthBuffer no matter which value is set.

    Greetz Chris
    yes

  7. #7
    Senior Member Regular Contributor
    Join Date
    May 2001
    Location
    Germany, Hannover
    Posts
    160

    Re: Purpose of glClearDepth

    glClearDepth sets the value, which will be written to the depthbuffer when calling glClear, like glClearcolor for the colorbuffer, so u can set a clipplane which will be between the nearclipplane and farclipplane ...

  8. #8
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: Purpose of glClearDepth

    glClearDepth can be seen as an additional clip plane. But that is not always true.

    If depthtest function is disabled, this "plane" is also disabled. If depthtest function is GL_ALWAYS, GL_GREATER or similar, you can "make holes" in the plane, writing new values, which is larger that the clear value, into the depthbuffer.

    So, this clipplane analogy is only valid if depthtest is on, and depthfunction is a less-variant (GL_LESS, GL_LEQUAL).

  9. #9
    Junior Member Newbie
    Join Date
    Aug 2001
    Posts
    11

    Re: Purpose of glClearDepth

    Yup, I'm wrong here. I've never used it and just thought that was how it worked. Looked it up and see I'm wrong. Sorry about that folks.

  10. #10
    Member Contributor
    Join Date
    Mar 2001
    Posts
    50

    Re: Purpose of glClearDepth

    I got it! Thanks folks

Similar Threads

  1. glClearDepth
    By Flurite in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 08-27-2012, 11:32 AM
  2. Reg : glClearDepth and glDepthFunc
    By Chaitra CJ in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 03-05-2012, 09:29 PM
  3. Purpose of .tga
    By AE in forum OpenGL: Basic Coding
    Replies: 17
    Last Post: 04-16-2006, 05:00 AM
  4. glClearDepth
    By t123 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 08-01-2005, 09:20 PM
  5. Replies: 3
    Last Post: 04-13-2005, 03:40 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