jyoung77
12-14-2005, 02:15 PM
Hi,
My following code (in Windows XP) is to determine which objects are being drawn near the cursor. But I always get a return of zero hit. Can you spot any error? I disable GL_CULL_FACE since the documentation says "With polygons, no hit occurs if the polygon is culled". Could somebody help me out? Thanks for any advise.
Tony
*****************************************
const int selectBuffSize = 1000;
GLuint selectBuff[selectBuffSize];
glSelectBuffer (selectBuffSize, selectBuff);
glMatrixMode (GL_PROJECTION);
double dDiameter = 50.;
int viewport[4];
double projM[16];
glGetDoublev(GL_PROJECTION_MATRIX, projM);
glGetIntegerv (GL_VIEWPORT, viewport);
// point stores the double click location
glPushMatrix();
glLoadIdentity();
gluPickMatrix ((GLdouble)(point.x), (GLdouble)(viewport[3]-point.y),
dDiameter, dDiameter, viewport);
glMultMatrixd(projM);
// Enter the Select mode.
glRenderMode (GL_SELECT);
glInitNames ();
glPushName (0);
for (...) // loop through aGraphObjects
{
glLoadName(aGraphObjects[i].nName);
aGraphObjects[i]->Draw();
}
GLint nNumHits = glRenderMode(GL_RENDER);
glMatrixMode(GL_PROJECTION);
glPopMatrix();
if (nNumHits != 0)
return (void*)selectBuff[3];
else
return NULL;
My following code (in Windows XP) is to determine which objects are being drawn near the cursor. But I always get a return of zero hit. Can you spot any error? I disable GL_CULL_FACE since the documentation says "With polygons, no hit occurs if the polygon is culled". Could somebody help me out? Thanks for any advise.
Tony
*****************************************
const int selectBuffSize = 1000;
GLuint selectBuff[selectBuffSize];
glSelectBuffer (selectBuffSize, selectBuff);
glMatrixMode (GL_PROJECTION);
double dDiameter = 50.;
int viewport[4];
double projM[16];
glGetDoublev(GL_PROJECTION_MATRIX, projM);
glGetIntegerv (GL_VIEWPORT, viewport);
// point stores the double click location
glPushMatrix();
glLoadIdentity();
gluPickMatrix ((GLdouble)(point.x), (GLdouble)(viewport[3]-point.y),
dDiameter, dDiameter, viewport);
glMultMatrixd(projM);
// Enter the Select mode.
glRenderMode (GL_SELECT);
glInitNames ();
glPushName (0);
for (...) // loop through aGraphObjects
{
glLoadName(aGraphObjects[i].nName);
aGraphObjects[i]->Draw();
}
GLint nNumHits = glRenderMode(GL_RENDER);
glMatrixMode(GL_PROJECTION);
glPopMatrix();
if (nNumHits != 0)
return (void*)selectBuff[3];
else
return NULL;