Skip to main content
GameDev.net gamedev.net
🔒 Locked

gluUnProject question

Started by coldlamper Nov 13, 2004 at 10:55 AM 1 replies 450+ views
Original Post
coldlamper
coldlamper
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.
zedzeek
zedzeek
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
coldlamper
coldlamper
Got it working . Guess I have to reset the viewport before calling gluUnProject.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.