I want to select and pick objects using VC++6. Where does this function as follows will be put, in OnDraw() or OnLButtonDown()?
How do I do?
PickPoint(int x,int y)
{
GLuint selectBuf[BUFSIZE];
GLint hits;
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);
DrawMyObjects(GL_SELECT);
glPopMatrix ();
glFlush ();
hits = glRenderMode(GL_RENDER);
}
Thanks!!!