マウス入力2010年1月4日 | |
![]() ファイル使い方ウインドウ上でマウスを動かしたりボタンを押したりすると、コンソール上にメッセージが表示されます。 内容GLUT を使ってマウスの入力を拾います。コールバック関数を使います。
glutMouseFunc(mouse); glutMotionFunc(motion); glutPassiveMotionFunc(passiveMotion); glutMouseFunc() で設定する関数の定義は次のようにします。 void mouse(int button, int state, int x, int y); 引数の button には押されたボタンの種類、state にはボタンの状態、x, y にはウインドウ上のマウスの位置が入ってきます。button は以下の値をとります。
state は以下の値をとります。
glutMotionFunc(), glutPassiveMotionFunc() で設定する関数の定義はそれぞれ次のようにします。 void motion(int x, int y); void passiveMotion(int x, int y); 引数の x, y には、ウインドウ上のマウスの位置が入ってきます。 | |
| PENGUINITIS | |