I can't figure out why I keep getting 0 hits when I click on anything. I had already gotten the main robot working and have it responding to keyboard commands great, but I can't seem to get it to register a hit for some reason.
Been trying to follow this tutorial: Lighthouse Tutorial
Full Code Here: My Git Repo
int handlePicking(int x, int y)
{
int hits;
GLint viewport[4];
glSelectBuffer(BUFSIZE, selectBuf);
glRenderMode(GL_SELECT);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glGetIntegerv(GL_VIEWPORT, viewport);
gluPickMatrix(x, viewport[3] - y, 5, 5, viewport);
glMatrixMode(GL_MODELVIEW);
glInitNames();
// restoring the original projection matrix
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glFlush();
// returning to normal rendering mode
hits = glRenderMode(GL_RENDER);
std::cout << hits << std::endl;
return -1;
}
void robot()
{
glInitNames();
glPushName(ROBOT_HEAD);
robotHead();
glPopName();
glPushName(ROBOT_EYES);
robotLeftEye();
robotRightEye();
glPopName();
glPushName(ROBOT_BODY);
robotBody();
glPopName();
glPushName(ROBOT_ARMS);
robotLeftArm();
robotRightArm();
glPopName();
glPushName(ROBOT_LEGS);
robotLeftLeg();
robotRightLeg();
glPopName();
}