Hello!
I'm having trouble using gluUnProject with my orthographic camera. The function gives me values that I don't expect (dx,dy,dz) although it returns success. Maybe it's because I'm not using gluLookAt()? I've used gluUnProject before but always together with gluLookAt.
This is my code for setting up the the view (isometric):
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-width/2, width/2, -height/2, height/2, -1000, 1000);
// Rotate view to 2:1 isometric
glRotated(-60, 1, 0, 0);
glRotated(45, 0, 0, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
This is my gluUnProject code inside WM_MOUSEMOVE:
double mvmatrix[16], projmatrix[16], dx, dy, dz;
int viewport[4];
double mouseX = LOWORD(lParam); // 0 at left side
double mouseY = height-HIWORD(lParam); // 0 at bottom
glGetIntegerv(GL_VIEWPORT, viewport);
glGetDoublev (GL_MODELVIEW_MATRIX, mvmatrix);
glGetDoublev (GL_PROJECTION_MATRIX, projmatrix);
gluUnProject (mouseX, mouseY, 0.0,
mvmatrix, projmatrix, viewport,
&dx, &dy, &dz);
Any help appreciated!
[Edited by - O-san on May 15, 2007 4:24:36 AM]