Jump to content
  • Advertisement

Archived

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

DDSquad

working with mouse - not in Ortho

This topic is 5936 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 want to have an object follow my mouse, but how can I do it without going into Ortho mode? [edited by - DDSquad on July 18, 2002 12:02:24 PM]

Share this post


Link to post
Share on other sites
Advertisement
When you really don''t want ortho, this can''t help.
But when not, read it please:

...
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glOrtho(...);
//Draw all in ortho mode here
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
...

Share this post


Link to post
Share on other sites
If Ive read your post correctly then this should solve your problem..

  
glPushMatrix();
glLoadIdentity();

GLint viewport[4];
GLdouble mvmatrix[16], projmatrix[16];
GLint realy;
glGetIntegerv (GL_VIEWPORT, viewport);
glGetDoublev (GL_MODELVIEW_MATRIX, mvmatrix);
glGetDoublev (GL_PROJECTION_MATRIX, projmatrix);
realy = viewport[3] - (GLint) mouseY - 1;

gluUnProject ((GLdouble) mouseX, (GLdouble) realy, Z,
mvmatrix, projmatrix, viewport, &wx, &wy, &wz);

glPopMatrix();

(the above is a text books example from somewhere (I forget..) but most ppl. on the net use it for making thier own cursors)

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!