how do i use glutMotionFunc() to make my object rotate as i press my left button of mouse? i already done rotaton using the arrow keys (left,right,up,down) but how do i do it with the mouse?
The mouse motion function is called when a button is pressed and the mouse if moving in the window.
I use both the glutMouseFunc and glutMotionFunc together.
I get what button has been pressed with the glutMouseFunc and then track the mouse with glutMotionFunc.
glutMouseFunc( int Button, int x, int y)
{
if (left_button_down)
{
left_button_state = 1;
}else left_button_state = 0;
}
glutMotionFunc(int x, int y)
{
if(left_button_state) move_object(x,y);
}
note this is just an example code, a little more would need to be added for it to be functional.