Reputation: 35
How to get the mouse coordinates always, without click on mouse?
void mouseMove(int mx, int my) {
}
int main(int argc, char ** argv){
glutInit( &argc, argv );
glutInitWindowSize( x, y );
glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH );
glutCreateWindow( "Freetype OpenGL" );
glutReshapeFunc( reshape );
glutDisplayFunc( display );
glutKeyboardFunc(keyboard);
glutMotionFunc(mouseMove);
timer();
glutMainLoop( );
return 0;
};
Upvotes: 2
Views: 4270
Reputation: 13960
glutMotionFunc()
is called when the mouse moves within the window while one or more mouse buttons are pressed, and glutPassiveMotionFunc()
is called when the mouse moves within the window while no mouse buttons are pressed.
You probably want to use both of them, to cover all the cases.
Upvotes: 4