06-12-2003, 06:29 AM

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_COMPONEN T,GL_FLOAT,&window_z);

bool succeeds = gluUnProject(

point.x,

//point.y,

view[3]-point.y-1,

window_z,

proj,

model,

view,

&x,

&y,

&z

);

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_COMPONEN T,GL_FLOAT,&window_z);

bool succeeds = gluUnProject(

point.x,

//point.y,

view[3]-point.y-1,

window_z,

proj,

model,

view,

&x,

&y,

&z

);