PDA

View Full Version : homogenous projections/clipping

genghis37
06-22-2002, 11:55 AM
I read a little subsection from cg http://www.opengl.org/discussion_boards/ubb/tongue.gifrinciples and practice that discusses clipping in homogenous coordinates. In this i learned that a line segment in homogenous space might project onto the w=1 plane with a line that extends to infinity in two directions from the projected vertices. In result this should cause the graphics engine to map the line into two lines on the screen. So i thought id try this out on opengl but i only see the positive half of the line (this happens even when i swap the vertices).

Heres the snippet:
glBegin(GL_LINES);
glVertex4f(1.0, 0.0, 0.0, -3.0);
glVertex4f(1.0, 0.0, 0.0, 2.0);
glEnd();

The projection matrix is simply orthographic from (-1,-1,-1) to (1,1,1). The line should show a horizontal line extending from the left edge to -1/3 and another horizontal line extending from 1/2 to the right edge.

I thought clipping in opengl was done in homogenous space since the perspective divide is shown in diagrams to be performed afterward. I suppose the line is only clipped a single time then as opposed to being split up and clipped twice as shown in the book cg: principles and practice.

Is there a way to enable true homogenous clipping in opengl then?

genghis37
06-22-2002, 01:38 PM
Okay, nobody seems to interested but i think ive found an acceptable solution. Respecify all primitives with w's that have different signs and reverse the sign of all their components before respecifying them. For primitives with vertices that are all neg w components, specify them once but reverse all the components signs before specification. This works for lines at least.

[This message has been edited by genghis37 (edited 06-22-2002).]

Bob
06-22-2002, 03:32 PM
You should always read the specification when you want to know something about how OpenGL operates.

From OpenGL 1.3 specification, section 2.11 Clipping, p. 41

A line segment or polygon whose vertices have wc values of differing signs
may generate multiple connected components after clipping. GL implementations
are not required to handle this situation. That is, only the portion of the primitive
that lies in the region of wc > 0 need be produced by clipping.