glDepthRange()

I want the near clipping plane at z=0.1 and the far clipping plane at z=100000000 (actually i dont want a far clippingplane). This results in the zbuffer having problems sorting two polygons close to each other (f.ex. z=1 and z=2).

But i only need the zbuffer to function on the interval [0.1, 5000] (for example). I know you can scale the zcoordinates written to the zbuffer using ‘glDepthRange()’, but i can only scale them down, not up.

I realize that by scaling the coordinates up, any zvalue over 5000 will result in undefined sorting for that pixel, but i promise i will only write normalized zvalues in the range [0.1, 5000] to the zbuffer.

Is this even possible in ogl?

radde

Take a look at an old Tip of the Day at flipCode.
http://www.flipcode.com/cgi-bin/msg.cgi?showThread=Tip-OGLD3DProjectMatrix&forum=totd&id=-1

For your case:

  1. Draw everything with Z > 5000 not using Z testing.
  2. Clear Z buffer, set Z range to 0.1->5000
  3. Draw everything with Z < 5000

(primitives with Z values both > and < 5000 will be drawn twice, which is OK)