我不知道为什么当我点击任何东西时我总是得到 0 次点击。我已经让主机器人工作了,它对键盘命令的响应很好,但由于某种原因,我似乎无法让它注册一个命中。
一直在尝试遵循本教程: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();
}