View Full Version : what is the use of glDepthRange function ?

12-28-2012, 04:41 AM
Documentations say that, glDepthRange defines the mapping of normalized device coordinates (range [-1, 1]) with the window-space Z coordinate ranges from [0, 1]. -1 is mapped to near values and 1 in mapped to far value.

But, what exactly is the use of this ? if I give glDepthRange(0.4,0.6), will it cause clipping of the graphics ? (I tried this but did not see any impact). Also, how is it different from the last two parameters of glOrtho function ?

12-28-2012, 06:03 PM
This is purely a mapping function it does not effect anything except the value stored in the z-buffer. Normally it is 0-1. I can see no reason to change this since any smaller range will only serve to increase z-buffer fighting. It does not cause any sort of clipping. Do not confuse this with the near and far clipping planes of glOrtho which define how to convert from camera space to NDC

12-29-2012, 01:30 AM
Thanks tonyo_au. I also believed the same, but was wondering, why at all this API has been provided, if it does not impact anything. Hence thought of posting the question.

While going through some documentation on web, I found that, in olden days, when system processing power was low, graphics developers were using half depth buffer alternatively for successive frame(ie 0.0 - 0.5 for 1st frame and 0.5-1.0 for the next). This would allow them to wok without clearing the depth buffer, hence improving performance.

Thanks for the quick reply and clarifying my doubts.