problems with gluPickMatrix () and GL_SELECT mode

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;

}

Hi !

The glMultMatrix() and all the Draw() calls are made with the projection matrix selected, is that what you want ? it could be that you need to put a glMatrixMode in there to switch to modelview matrix…

Mikael