Get mouse cursor with GLUT

Hi!

I would like to know the equivalent functions or way to do the following using GLUT instead of windows

Any ideas? Thanks!

code starts here:
POINT mousePos;
int mid_x = mWindowWidth >> 1;
int mid_y = mWindowHeight >> 1;
float angle_y = 0.0f;
float angle_z = 0.0f;

GetCursorPos(&mousePos);				// Get the mouse cursor 2D x,y position					

if( (mousePos.x == mid_x) && (mousePos.y == mid_y) ) return;

SetCursorPos(mid_x, mid_y);	// Set the mouse cursor in the middle of the window						

// Get the direction from the mouse, and bring the number down to a reasonable amount
angle_y = (float)( (mid_x - mousePos.x) ) / 1000;		
angle_z = (float)( (mid_y - mousePos.y) ) / 1000;

endcode…

There are two glut functions that will get mouse location.

glutMouseFunc(int button, int state, int x,int y); // gives which mouse button was clicked, button up/down, pos, when inside the glut window. Note only is called when the mouse button is pushed or released.

glutPassiveMotionFunc(int x, int y); location of mouse inside glut window. updates with mouse movement.

Call before calling glutMainLoop();

example of what I think you are looking for.

glutPassiveMotionFunc( My_mouse_routine );

void My_mouse_routine(int x, int y)
{

mouse_x = x; place current mouse pos in mouse_x
mouse_y = y;

}

Originally posted by fcoutel:
[b]Hi!

I would like to know the equivalent functions or way to do the following using GLUT instead of windows

Any ideas? Thanks!

code starts here:
POINT mousePos;
int mid_x = mWindowWidth >> 1;
int mid_y = mWindowHeight >> 1;
float angle_y = 0.0f;
float angle_z = 0.0f;

GetCursorPos(&mousePos); // Get the mouse cursor 2D x,y position

if( (mousePos.x == mid_x) && (mousePos.y == mid_y) ) return;

SetCursorPos(mid_x, mid_y); // Set the mouse cursor in the middle of the window

// Get the direction from the mouse, and bring the number down to a reasonable amount
angle_y = (float)( (mid_x - mousePos.x) ) / 1000;
angle_z = (float)( (mid_y - mousePos.y) ) / 1000;

endcode…[/b]

for setting the mouse position, use glutWarpPointer(int x, int y)

jebus