gluUnProject not working correctly

Hi, glu Un project is not working correctly. It is returning the same coordingate no matter where I click. If I rotate the model view it returns a different coordinate but same for all positions on the screen. Any ideas?

void CGameView::OnLButtonDown(UINT nFlags, CPoint point)
{
double x,y,z;
double proj[16],model[16];
int view[4],window_z;
glGetDoublev(GL_PROJECTION_MATRIX,proj);
glGetDoublev(GL_MODELVIEW_MATRIX,model);
glGetIntegerv(GL_VIEWPORT,view);

glReadPixels(point.x,point.y,1,1,GL_DEPTH_COMPONENT,GL_FLOAT,&window_z); 
bool succeeds =  gluUnProject(
							 point.x,	     
							 //point.y,
						view[3]-point.y-1,                     
							 window_z,		                   
							   proj,        
							   model,	   
							   view,	        
								&x,		                  
								&y,		                   
								&z		                  
							  );

I had exactly the same problem when I tried to implement a picking algorithm. Would be interested in finding the solutiion just as much as you do.

I see two things. In glReadPixels, you pass thwe wrong Y-coordinate, it should be the same as the one you pass to gluUnProject ( view[3]-point.y-1). In gluUnProject, the modelview matrix is the fourth parameter and the projection matrix is the fifth parameter.