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:



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?

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 ?

i was assuming depth test by default is GL_LEQUAL. :stuck_out_tongue:
It worked when i added call glDepthFunc(GL_LEQUAL);

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