Advertisement

a question about "w"

Started by October 12, 2005 02:23 PM
20 comments, last by mc30900 18 years, 11 months ago
i've seen that the function glVertex can take 4 parameters. and not 3 as i used to think. but i am not sure what the 4th do which is "w" someone told me its about timing but i still dont understand. can anyone please explain to me what it do and show me how to use it? thanks in advance
31 views and no one knows?:(
Advertisement
I've never used it, but if I remember correctly, it would be a scaling factor.
Hopefully this helps.

Beginner in Game Development?  Read here. And read here.

 

it is im pretty sure aits a scaling facto just use glVector3f()
someone told me that i need to use it else my program will work else on every computer.
and for it will be the same fps and all that stuff i need to use it.
he said somthing about metrics i think
Advertisement
The coordinates used in glVertex are homogeneous coordinates. Here's what the OpenGL Programming Guide says about them:

"A set of n+1 coordinates used to represent points in n-dimensional projective space. Points in projective space can be thought of as points in Euclidean space together with some points at infinity. The coordinates are homogeneous because a scaling of each of the coordinates by the same nonzero constant doesn't alter the point to which the coordinates refer. Homogeneous coordinates are useful in the calculations of projective geometry, and thus in computer graphics, where scenes must be projected onto a window."

In other words, this allows you to specify points at infinity by setting the w-coordinate equal to zero.

There is nothing that is going to break on any computer if you don't use the w-coordinate. It always defaults to 1.0, so you can safely use glVertex3f, for instance.
Quote: Original post by mc30900
someone told me that i need to use it else my program will work else on every computer.
and for it will be the same fps and all that stuff i need to use it.

That someone is misinformed. The w parameter has precisely nothing to do with animation or cross-platform compatibility. In fact, the only time you'll need glVertex4f is for rather obscure infinite-volume stuff (for instance, with shadow volumes).
Quote: Original post by James Trotter
The coordinates used in glVertex are homogeneous coordinates. Here's what the OpenGL Programming Guide says about them:

"A set of n+1 coordinates used to represent points in n-dimensional projective space. Points in projective space can be thought of as points in Euclidean space together with some points at infinity. The coordinates are homogeneous because a scaling of each of the coordinates by the same nonzero constant doesn't alter the point to which the coordinates refer. Homogeneous coordinates are useful in the calculations of projective geometry, and thus in computer graphics, where scenes must be projected onto a window."

In other words, this allows you to specify points at infinity by setting the w-coordinate equal to zero.

There is nothing that is going to break on any computer if you don't use the w-coordinate. It always defaults to 1.0, so you can safely use glVertex3f, for instance.

does at infinity mean points that we can't see on the screen?

Beginner in Game Development?  Read here. And read here.

 

Not necessarily, no. For instance, the point z=-infinity (assuming a RH coordinate system) is visible in the center of the screen.

This topic is closed to new replies.

Advertisement