the w you speak of is the magic homogeneous coordinate factor. <takes deep breath, and prepares to lecture about projective geometry>
I can’t think of a really cool way of explaining the homogeneous coordinate… so, I’ll say this:
if you have a cartesian coordinate (a, b, c), then the cartesian coordinate is (d, e, f, g) s.t. a=d/g, b=e/g and c=f/g
a trivial example is to set g=1 and then d=a, e=b and f=c.
an example. all of these coordiantes are EQUIVILENT:
(1, 2, 3) (cartesian)
(1, 2, 3, 1) (homogeneous)
(2, 4, 6, 2) (h)
(10, 20, 30, 10) (h)
and so on, ad neuseum. okay, you think, what if w=0? well, this is also a valid homogeous coordinate, but it ISN’T a valid cartesian coordiniate. such coordinates are said to be point/lines/planes/hyperplanes/etc at infinity. The fabled “vanishing point” that artists speak of with revered tones is a point at infinity; it can’t be expressed in cartesian coordinates, but it DOES have a corresponding homogeneous coordinate. The set of all vanishing points defines the LINE of infinity, or (as you’d see it), the horizon. Yep, there’s even a plane of infinity, which is the set of all horizons… and so on and so on. Homeogeous coordinates in the realm of projective geoemtry extend to n-spaces, so you have hyperplanes (sets of planes) and n-spaces and so on. but, that’s beyond the scope of this email.
so, suffice to say: w is a funky homogeous coordinate. its there to make the maths easier for opengl.
your second point: yep, the z-buffer range is from 0…1 which is a map to the near…far clip planes. its done like that because the z-buffer doesn’t have unlimited precision.