PDA

View Full Version : how does glDepthRange work?

debonair
01-07-2013, 05:23 AM
My vertex cords are :

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,//face 1

0.5f,-0.5f,-0.5f,
-0.5f,-0.5f,-0.5f,
-0.5f,0.5f,-0.5f,
0.5f,0.5f,-0.5f,//face 2

0.5f,0.5f,0.5f,
0.5f,-0.5f,0.5f,
0.5f,-0.5f,-0.5f,
0.5f,0.5f,-0.5f,//face 3

-0.5f,0.5f,0.5f,
-0.5f,0.5f,-0.5f,
-0.5f,-0.5f,-0.5f,
-0.5f,-0.5f,0.5f,//face 4

0.5f,0.5f,0.5f,
0.5f,0.5f,-0.5f,
-0.5f,0.5f,-0.5f,
-0.5f,0.5f,0.5f,//face 5

-0.5f,-0.5f,0.5f,
-0.5f,-0.5f,-0.5f,
0.5f,-0.5f,-0.5f,
0.5f,-0.5f,0.5f//face 6

};

now, i am changing z cords by:

for(int i=0;i<24;i++)
vertices[i*3+2]*=10
glDepthRange(0,10.0);

Now, i am expecting that z cords will be mapped to -0.5 to 0.5 range due to glDepthRange call and i can see a proper cube, but it gives o/p as that of when i comment glDepthRange call above with distorted geometry.

dukey
01-07-2013, 03:30 PM
I would assume depthrange would only work between the values of 0 - 1

tonyo_au
01-07-2013, 04:44 PM
It set the linear tranformation from NDC to the z-buffer - and yes it is in the range 0-1. Do not confuse this with near and far planes of the projection matrix.

debonair
01-08-2013, 12:13 AM
It set the linear tranformation from NDC to the z-buffer - and yes it is in the range 0-1. Do not confuse this with near and far planes of the projection matrix.

How can i simulate the above effect? by giving coords > 1 i want to scale that to 0-1..

tonyo_au
01-08-2013, 01:38 AM
By definition NDC is in the range -1 to +1, the z value is thenglRangeDepth is applied; so you can't have a coordinate > 1.