View Full Version : glVertex4*()?

01-14-2003, 11:37 PM
what does the 4th parameter do in any of the glVertex4*()'s??

[This message has been edited by jono_123 (edited 01-15-2003).]

01-15-2003, 12:05 AM
It's called w-coordinate and is the homogenous expansion of the 3D space, which is necessary to allow translation to be included in transformation matrix of size 4x4.
The resulting w-coordinate after transformation is used for frustum clipping and perspective correct interpolation of vertex attributes, esp. textures.
Specifying something different than 1.0 on API side can be used for special perspective effects.

Read the OpenGL RedBook Appendix F.

01-15-2003, 12:10 AM
When you specify a 4-coord vertex (x, y, z, w) the resulting 3-coord vertex is (x/w, y/w, z/w).

So, when w is set to 1, you won't notice anything.

When you set w to something different than 1, it's a bit like scaling.

And when you set w to 0, you're defining an infinite vertex, which is allowed in OpenGL but is rarely used.