Sign in to follow this  

gluUnProject question

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

This topic is 4812 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this