The program is here.
void CTopView::OnLButtonDown(UINT nFlags, CPoint point)
{
PickPoint(point.x,point.y);
}
GLuint CTopView::PickPoint(int x,int y)
{
GLuint selectBuf[BUFSIZE];
GLint hits;
GLint viewport[4];
glGetIntegerv(GL_VIEWPORT, viewport);
glSelectBuffer (BUFSIZE, selectBuf);
(void) glRenderMode (GL_SELECT);
glInitNames();
glPushName(-1);
glMatrixMode (GL_PROJECTION);
glPushMatrix ();
glLoadIdentity ();
gluPickMatrix((GLdouble)x, (GLdouble) (viewport[3] - y), 18, 18, viewport);
gluPerspective(35.0, (GLfloat)viewport[2]/(GLfloat)viewport[3], 1.0f, 5000.0f);
myDrawScene(GL_SELECT);
glPopMatrix ();
glFlush ();
hits = glRenderMode(GL_RENDER);
}
anyone can tell me where this is wrong.