Jump to content
  • Advertisement


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


point coordinates

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

Hi, how can i retrieve the coordinates of a point on the screen ? I have a terrain engine based on a simple triangle strip of 256x256 vertices. I''d like, when i move the mouse on a certain point, to get the coordinates. So far i''ve been able to get the depth of the points with glReadPixels, but i also need the x and y coordinates. Can you help me ? Thx

Share this post

Link to post
Share on other sites
Guest Anonymous Poster

Share this post

Link to post
Share on other sites
i have the current code in my mousemove routine:

xPos = LOWORD(lParam); // horizontal position of cursor
yPos = HIWORD(lParam); // vertical position of cursor
GLint viewport[4];
GLdouble model_view[16];
GLdouble projection[16];
GLdouble dx,dy,dz;
glGetDoublev(GL_MODELVIEW_MATRIX, model_view);
glGetDoublev(GL_PROJECTION_MATRIX, projection);
gluUnProject(xPos, viewport[3] - (GLint) yPos - 1, 1.0, model_view, projection, viewport, &dx, &dy ,&dz);

Results are that when i move the mouse on the terrain grid, dz is stuck always at the same value, so i guess depth buffer is ignored, and dx and dy they change accordingly to mouse movement. Is there something wrong with this code ?

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!