Jump to content
  • Advertisement

Archived

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

cippyboy

gluProject(); How do you do it ?

This topic is 5797 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

I tryed this about 2 times and it doesn`t work...although someone told how to do it... Here it is : What`s wrong and what should I put in ? double transformed[3], realpoint[3]; float projmat[16];glGetFloatv(GL_PROJECTION_MATRIX,projmat); float modmat[16];glGetFloatv(GL_PROJECTION_MATRIX,modmat); double viewport[2]={width,height}; gluProject(realpoint[0], realpoint[1], realpoint[2], modmat, projmat, viewport, &transformed[0], &transformed[1], &transformed[2]);

Share this post


Link to post
Share on other sites
Advertisement
viewport needs to contain 4 values: top, bottom, left & right.
You need to add {0, 0} to your viewport array.
I''m not sure about the order though, can''t find my book at the moment...

http://users.ox.ac.uk/~univ1234

Share this post


Link to post
Share on other sites
The final version of that...(It works but it seems that the y is more than 0 ) :
typedef struct{
float x,y,z;
}CVector3;
void GetPoint(CVector3 Pos,int *x,int *y)
{//Still I need ints as returned values
double t[3],r[3]={Pos.x,Pos.y,Pos.z};
double projmat[16];glGetDoublev(GL_PROJECTION_MATRIX,projmat);
double modmat[16];glGetDoublev(GL_MODELVIEW_MATRIX,modmat);
int viewport[4]={0,0,int(width),int(height)};
gluProject(r[0],r[1],r[2],modmat,projmat,viewport,
&t[0],&t[1],&t[2]);
int xx=int(t[0]),yy=int(t[1]);
x[0]=xx;y[0]=yy;
}

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!