This topic is now archived and is closed to further replies.

2d positions from 3d calculations?

This topic is 5221 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

you can use gluProject(...)

try this:

//[in] x,y,z are vertex coordinates
//[out] wx,wy,wz are the returned window coordinate (you can ignore wz)

void GetScreenCoord(double & x,double & y,double & z,
double & wx,double & wy, double & wz)
GLint viewport[4]; //array to hold viewport
GLdouble mvmatrix[16],projmatrix[16]; // model/projection matrix

glGetIntegerv(GL_VIEWPORT, viewport);
glGetDoublev(GL_MODELVIEW_MATRIX, mvmatrix);
glGetDoublev(GL_PROJECTION_MATRIX, projmatrix);


//now wx,wy have the screen coord.


hope that helps

Share this post

Link to post
Share on other sites