Jump to content
  • Advertisement
Sign in to follow this  
coldlamper

gluUnProject question

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

Here's my code: POINT pt; pt.x = LOWORD(lParam); pt.y = HIWORD(lParam); GLint vport[4]; GLdouble modelview[16]; GLdouble projection[16]; GLfloat winX, winY, winZ; GLdouble posX, posY, posZ; glGetDoublev( GL_MODELVIEW_MATRIX, modelview ); glGetDoublev( GL_PROJECTION_MATRIX, projection ); glGetIntegerv( GL_VIEWPORT, vport ); winX = pt.x; winY = vport[3] - pt.y; glReadPixels( winX, winY, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ ); gluUnProject(winX, winY, winZ, modelview, projection, vport, &posX, &posY, &posZ); My problem is whatever mouse coord I input for winX, winY, I get those back in posX and posY. Ex. winX = 127, posX = 127.0001 winY = 54, posY = 54.00042 Anyone see what I'm doing wrong? I've been trying this for a day or two and read most of the posts about gluUnProject and cannot figure out what is wrong.

Share this post


Link to post
Share on other sites
Advertisement
perhaps u havent enabled depthtesting etc.

try printing out the value u get from the readpixels (hopefully its changing as the mouse movesover the screen).

if that doesnt work, have a look at modelview,projection,viewport + see if they contain resonable values

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!