Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Does Depth Buffer Allow Writing Into When Disabling Depth Test

  1. #1
    Intern Newbie
    Join Date
    Nov 2006
    Posts
    37

    Does Depth Buffer Allow Writing Into When Disabling Depth Test

    It seems that it would NOT allow writing depth buffer when just disable depth testing. I use the following sentences:

    glDisable(GL_DEPTH_TEST);
    glDepthMask(GL_TRUE);
    glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);

    Can anybody tell me the truth?

  2. #2
    Senior Member OpenGL Pro Zengar's Avatar
    Join Date
    Sep 2001
    Location
    Germany
    Posts
    1,979

    Re: Does Depth Buffer Allow Writing Into When Disabling Depth Test

    Use glDepthFunc(GL_ALWAYS)

    It seems that disabling teh depth test will also disable the depth updating in the z-buffer

  3. #3
    Intern Newbie
    Join Date
    Nov 2006
    Posts
    37

    Re: Does Depth Buffer Allow Writing Into When Disabling Depth Test

    What do you mean by using glDepthFunc(GL_ALWAYS)?
    It seems cannot make depth buffer writable when disabling depth test and using glDepthFunc(GL_ALWAYS).

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

    Re: Does Depth Buffer Allow Writing Into When Disabling Depth Test

    You need to keep depth test enabled, because that's what GL_ALWAYS is; a depth test function.

    Disabling depth test completely disables everything related to the depth buffer. That's not what you want, you want the depth buffer writes to happen so you must have it enabled.

  5. #5
    Intern Newbie
    Join Date
    Nov 2006
    Posts
    37

    Re: Does Depth Buffer Allow Writing Into When Disabling Depth Test

    Is it the same for other buffers, such as stencil buffer ?

  6. #6
    Intern Newbie
    Join Date
    Nov 2006
    Posts
    37

    Re: Does Depth Buffer Allow Writing Into When Disabling Depth Test

    I mean that, when you call glDisable(GL_STENCIL_TEST), everthing stencil-buffer-related will be disabled?

  7. #7
    Advanced Member Frequent Contributor arekkusu's Avatar
    Join Date
    Nov 2003
    Posts
    676

    Re: Does Depth Buffer Allow Writing Into When Disabling Depth Test

    Correct.

    This is all spelled out very clearly in the specification.

  8. #8
    Intern Newbie
    Join Date
    Nov 2006
    Posts
    37

    Re: Does Depth Buffer Allow Writing Into When Disabling Depth Test

    Thanks to you all, guys.

  9. #9
    Intern Newbie
    Join Date
    Nov 2006
    Posts
    37

    Re: Does Depth Buffer Allow Writing Into When Disabling Depth Test

    I find it , thanks again, I think I should refer to it more frequently later on:

    {
    4.1.6 Depth Buffer Test

    The depth buffer test discards the incoming fragment if a depth comparison fails.The comparison is enabled or disabled with the generic Enable and Disable commands using the symbolic constant DEPTH TEST.

    When disabled, the depth comparison and subsequent possible updates to the depth buffer value are bypassed and the fragment is passed to the next operation.
    }

  10. #10
    Advanced Member Frequent Contributor
    Join Date
    Feb 2006
    Location
    Sweden
    Posts
    748

    Re: Does Depth Buffer Allow Writing Into When Disabling Depth Test

    Ok recap time, there is a lot of confusion in this thread, so here is exactly how it is.

    glDepthFunc(.....); sets the test to be made against the depthbuffer, normally this should be GL_LEQUAL, GL_ALWAYS is not a good one since it will always pass, even if the fragment is behind previous written depth value.

    glDisable(GL_DEPTH_TEST); and glEnable(GL_DEPTH_TEST); controls the discarding the color part of the current fragment, based on the above test.

    glDepthMask(....); same as above but for the depth part of the fragment.
    (It should really be glEnable(GL_DEPTH_WRITE), but i guess whats done is done.)

    So to answer the original question, yes it does.

Posting Permissions

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