/**
* This function is called by glutMouseFunc(mouse)
* The parameter here is
* button : type of the button
* state: down and up
* x: horizontal position, start from left
* y: vertical position, start from top
*/
void mouse(int button, int state, int x, int y){
// called twice
cout << "State: " << state << endl;
cout << "Position: x->" << x << " y->" << y << endl;
switch(button){
case GLUT_LEFT_BUTTON:
cout << "Left Button" << endl; // called twice
if(state == GLUT_DOWN){
cout << "Left Button Down" << endl;
}
if(state == GLUT_UP){
cout << "Left Button Up" << endl;
}
break;
case GLUT_MIDDLE_BUTTON:
cout << "Middle Button" << endl;
if(state == GLUT_DOWN){
cout << "Middle Button Down" << endl;
}
if(state == GLUT_UP){
cout << "Middle Button Up" << endl;
}
break;
case GLUT_RIGHT_BUTTON:
cout << "Right Button" << endl;
if(state == GLUT_DOWN){
cout << "Right Button Down" << endl;
}else if(state == GLUT_UP){
cout << "Right Button Up " << endl;
}
}
}
cout << "State: " << state << endl;
cout << "Position: x->" << x << " y->" << y << endl;
switch(button){
case GLUT_LEFT_BUTTON:
cout << "Left Button" << endl; // called twice
if(state == GLUT_DOWN){
cout << "Left Button Down" << endl;
}
if(state == GLUT_UP){
cout << "Left Button Up" << endl;
}
break;
case GLUT_MIDDLE_BUTTON:
cout << "Middle Button" << endl;
if(state == GLUT_DOWN){
cout << "Middle Button Down" << endl;
}
if(state == GLUT_UP){
cout << "Middle Button Up" << endl;
}
break;
case GLUT_RIGHT_BUTTON:
cout << "Right Button" << endl;
if(state == GLUT_DOWN){
cout << "Right Button Down" << endl;
}else if(state == GLUT_UP){
cout << "Right Button Up " << endl;
}
}
}
No comments:
Post a Comment