Hi,
My following code has some problems. I hit entity when it shouldn’t but don’t hit when it should. I exactly follow some other examples. Could someone help me out? Any hint is much appreciated.
Tony
int Test(CPoint point)
{
GLuint selectBuff[100];
glSelectBuffer (selectBuffSize, selectBuff);
glMatrixMode (GL_PROJECTION);
int viewport[4];
double projM[16];
glGetDoublev(GL_PROJECTION_MATRIX, projM);
glGetIntegerv (GL_VIEWPORT, viewport);
glPushMatrix();
glLoadIdentity();
gluPickMatrix ((GLdouble)(point.x),
(GLdouble)(viewport[3]-point.y),
20., 20., viewport);
glMultMatrixd(projM);
glRenderMode (GL_SELECT);
glInitNames ();
glPushName (0);
for (…)
{
glLoadName(v[i].id);
v[i].Draw();
}
GLint nNumHits = glRenderMode(GL_RENDER);
glMatrixMode(GL_PROJECTION);
glPopMatrix();
if (nNumHits != 0)
return selectBuff[3];
else
return -1;
…
}