PDA

View Full Version : Ortho clipping

BruceG
06-14-2014, 02:59 PM
I realize I'm bringing up a worn-out topic, but after having read about a million posts, it's not clear to me that clipping is fully understood. For example, one repeatedly finds calls to glOrtho with the Near and Far parameters set to (-1,1), which is clearly in violation of the Redbook. In that reference, at least to me, it seems that one must draw between the clipping planes to avoid having his drawing clipped out of existence, and that makes perfect sense. For example, one should be able to set Near and Far to (1,3), draw on the plane Z=2, and bask in victory. However, I can't make it work. What I CAN make work is setting Near and Far to (1,3) and drawing on Z=-2! What's going on here?

Bruce

carsten neumann
06-15-2014, 01:02 AM
... calls to glOrtho with the Near and Far parameters set to (-1,1), ...

Nothing wrong with that, see glOrtho (http://www.opengl.org/sdk/docs/man2/xhtml/glOrtho.xml) - the restriction that 0 < near < far only applies to glFrustum (http://www.opengl.org/sdk/docs/man2/xhtml/glFrustum.xml).

What I CAN make work is setting Near and Far to (1,3) and drawing on Z=-2! What's going on here?

This works as intended, albeit it does take some getting used to. The camera looks along the -z axis of view space, but the near and far values are distances from the z=0 plane of view space (measured along the view axis, so a positive distance takes you along the negative z axis). As such setting near,far to 1,3 means things between the z=-1 plane and z=-3 plane (of view space) are visible.

BruceG
06-15-2014, 09:05 AM
...the restriction that 0 < near < far only applies to glFrustum...

which requires that condition - ok, makes sense

... camera looks along the -z axis of view space ...a positive distance takes you along the negative z axis ...

ahhh - glOrtho maps a right-handed coordinate system into a left-handed coordinate system - ok, makes sense AND answers my question

Add this to the view transformation order and it appears to me that OpenGL is more than a bit counter-intuitive. Which is ok, of course, as long as its consistent. Like you say, it will take some getting used to. Thanks for the prompt and cogent response.

Bruce