//variables
GLint viewPort[4];
GLdouble modelView[16];
GLdouble projection[16];
GLfloat winX, winY, winZ;
GLdouble mouseWorldCoordX, mouseWorldCoordY, mouseWorldCoordZ;
winX = (float)mousePos.x; //Reading mouse coords x
winY = (float)mousePos.y; //Reading mouse coords y
glGetIntegerv(GL_VIEWPORT, viewPort); //getting viewport
winY = (float)viewPort[3] - winY; //changey to increase from bottom to up
glGetDoublev(GL_MODELVIEW_MATRIX, modelView); //getting modelView matrix
glGetDoublev(GL_PROJECTION_MATRIX, projection); //getting projection Matrix
glReadPixels(winX, winY, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ); // ???
gluUnProject( winX, winY, winZ, modelView, projection, viewPort, &mouseWorldCoordX, &mouseWorldCoordY, &mouseWorldCoordZ); //get world values
those final variables
mouseWorldCoordX
mouseWorldCoordY
mouseWorldCoordZ
have just the same values as my winX winY winZ coords.
any suggestion?
thanks
problem with window coords--- world coords
hi, i've read the tutorial about transforming window coordinates to Opengl coordinates.
in the last step, when i transform my window mouse coordinates to new opengl world coordinates x,y,z.... i have a problem because they are just the same as my old window coordinates, and z reads -1 all the time.
heres the code:
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement