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

Thread: Order of execution of depth_clamp and depth_test

  1. #1
    Junior Member Regular Contributor
    Join Date
    Jun 2012
    Posts
    207

    Order of execution of depth_clamp and depth_test

    does depth clamp occurs before depth test or after depth test? I am rendering a primitive with coordinates > 1.0 and <-1.0 and using depth clamping with depth test. But when i enable depth test it does not render any geometry.

    Here is my code:
    Code :
     
    GLfloat vertices[]=
        {
    0.5f,0.5f,0.5f,                                   
    -0.5f,0.5f,0.5f,
    -0.5f,-0.5f,0.5f,
    0.5f,-0.5f,0.5f,
     
    0.5f,-0.5f,-0.5f,
    -0.5f,-0.5f,-0.5f,
    -0.5f,0.5f,-0.5f,
    0.5f,0.5f,-0.5f  
    }
     
    for(int i=0;i<24;i++)
        vertices[3*i+2]*=25;
     
        glEnable(GL_DEPTH_CLAMP);
     
            // when i comment stmt below, it draws triangle strips
            glEnable(GL_DEPTH_TEST); 
            glClearDepth(15.0f);
            glClearColor (1.0, 0.0, 0.0, 1.0);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
            glDrawArrays(GL_TRIANGLE_STRIP,0,6);

    How to use depth test and clamping together?

  2. #2
    Junior Member Regular Contributor
    Join Date
    Jun 2012
    Posts
    207
    Acco to From OpenGL 4.3, 17.3.6:

    If depth clamping (see section 13.5) is enabled, before the incoming fragment’s zw is compared, zw is clamped to the range [min(n; f ); max(n; f )]

    why above code does not draw anything on the screen ?

  3. #3
    Junior Member Regular Contributor
    Join Date
    Jun 2012
    Posts
    207
    i was assuming depth test by default is GL_LEQUAL.
    It worked when i added call glDepthFunc(GL_LEQUAL);

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,117
    A coupleof things

    glClearDepth is clamped to 0-1 so I am not sure why you are using 15.0f

    glDepthFunc is initially GL_LESS

Posting Permissions

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