static int mouse_x, mouse_y; /* previous values of mouse location */ // This function records the current mouse location when the button goes // down, facilitating the motion function. void twMouseFunction(int button, int state, int x, int y) { y=windowHeight-y; switch(button) { case GLUT_LEFT_BUTTON: if(GLUT_DOWN==state) { mouse_x = x; mouse_y = y; } break; case GLUT_MIDDLE_BUTTON: if(GLUT_DOWN==state) { twOrientVPN(x,y); } break; case GLUT_RIGHT_BUTTON: break; default: printf("invalid button in mouse callback: %d\n",button); break; } // I hoped this would fix the area around the mouse that isn't // updated, but no luck. glutPostRedisplay(); } void twMotionFunction(int x, int y) { y=windowHeight-y; twTrackballOrientation(mouse_x,mouse_y,x,y); mouse_x = x; mouse_y = y; }