How to transform a 3d-Point in a 2d-Point??

Hi!
I have a 3d-Vector/Point with x,y,z and it´s rendered in my 3d-space. But what are the actual 2d-coordinates for this point, after it´s rendered (where I can find it on my screen)??
thnx,
Blob

You mean your 3D point projected in the viewport?

I’m not sure about this, but I think it’s like this.

p = (x, y, z, 1) in other words, your 3D point/vector
mv = modelview matrix
pr = projection matrix
vp = projected point in untransformed viewport coordinates

vp = pr * mv * p.

To get real windows space coordinates, you have to scale and offset vp. This is dependand of the size of the viewport.

Well, Thanks.
But, how do I get the modelview matrix, how the viewport matrix and how do i multiply them with my vector??

You can get the modelview matrix with glGetFloatv(GL_MODELVIEW_MATRIX, &mv), where mv is a float mv[16];. The projection matrix is obtained in the same way, but with GL_PROJECTION_MATRIX.

As for multiplication, well, bah, use gluProject instead . You pass the modelview- and projectionmatrix, the viewport coordinates, the point, and it will return the projected point. Forgot about it in my first post, it will do the job for you.

Ahhh! Thank you very much! Works well!!!