clipping

Hi,

I have to implement a clipping routine according to the opengl specification.

This what i’ve been doing so far:

  1. clipped vertexes/triangles with the camera near/far plane after they have been transformed to camera space.

  2. projected the vertexes

  3. clipped against left/bottom/right/top plane.

Now i’ve read that with opengl all visible vertexes have to be within:
-w < x < w
-w < y < w
-w < z < w

The problem is i have no idea what this w is.

hey,
these are the coordinates of the near and far plane and the x-y clipping boundaries.So the x coodr has to be between the wxmin to wxmax
y has to be within wymin and wymax and z has to be between wzmin and wzmax.
u can have it from 0 to w
or -w to w…that up to u
hope this helps…

w is the fourth component of a vector, called the homogeneous coordinate. Homogeneous coordinates are used to simplify vertex transformation. By using them, a combination of a rotation and a translation of a vector can be performed by multiplying a 4x4 matrix by a 4 component homogeneous vector.

A homogenous vertex |x y z w| corresponds to a 3D vertex |x/w y/w z/w|

OpenGL clips all vertices to the canonical view volume, which means evrything outside the range [-1,1]x[-1,1]x[-1,1] is clipped.
so you get:

-1 < x < 1
-1 < y < 1
-1 < z < 1

In homogenous coordinates, this corresponds to:

-w < x < w
-w < y < w
-w < z < w

Nico