I perfectly understand that GLUT is limited and the following problem can't probably be solved with OpenGL/GLUT, but since I don't know exactly if it can or not, I better just ask. Maybe I'm doing something wrong or forgetting something important. Or probably not and GLUT doesn't get better than this.
My problem is that I can't trap the mouse inside the window. Well, actually, I can, the code below does just that. I trap the mouse inside the window and I can use the mouse freely to rotate the world. The problem? If I move the mouse too fast I can get way from window prison.
Is there a way around this with OpenGL/GLUT or the only option is another library or make some calls to the Windows API directly? Enough words, here's my current code:
void processPassiveMouseMotion(int x, int y) {
static int centerX = glutGet(GLUT_WINDOW_WIDTH) / 2;
static int centerY = glutGet(GLUT_WINDOW_HEIGHT) / 2;
CameraAngle.x = -1.0f * (y - centerY);
CameraAngle.y = -1.0f * (x - centerX);
if(CameraAngle.x != 0.0f || CameraAngle.y != 0.0f) {
SceneCamera.Rotate(CameraAngle);
glutPostRedisplay();
glutWarpPointer(centerX, centerY);
}
}
glutPassiveMotionFunc(processPassiveMouseMotion);