PDA

View Full Version : from feedback buffer to gluUnProject



122100
09-08-2004, 09:55 AM
from feedback buffer i got the xMax, xMin, yMax
yMin,zMax, zMin values
I want to use gluUnproject to turn them into 3D coordinate, but i failed!the result is not right!
gluUnProject((GLdouble)m_xMin,
(GLdouble)m_yMin,
(GLdouble)m_zMax,
dModelMatrix,
dProjMatrix,
iViewPort,
&ObjectX,
&ObjectY,
&ObjectZ);
??????

122100
09-08-2004, 10:23 AM
i use the glutLookAt function in my program!
is there any thing about it?

09-10-2004, 03:14 AM
that gluUnproject function will ham-string you if youre not careful. mainly, watch the screen-z (non-linear) and viewport-y (reversed):


GLint viewport[4];
glGetIntegerv(GL_VIEWPORT, viewport);

gluUnProject(
screen_x, // screen x
viewport[3]-1-screen_y,// flip screen y
screen_z, // between 0.0 and 1.0
dModelMatrix, // model matrix
dProjMatrix, // projection matrix
viewport, // viewport
&ObjectX, // world x
&ObjectY, // world y
&ObjectZ // world z
);