mouse coordinates

hey is there anyway to get the mouse coordinates without a mouse event happening? IE so I can find out if a mouse is over something without a button being pressed.

using win32, declare a POINT then pass a reference to GetWindowPos().

{

POINT pt;

GetWindowPos(&pt);
// pt.x and pt.y are now current mouse coords

}

jebus

Or GetCursorPos which will give you current cursor position for Windows. I think that is actually what Jebus meant.

[This message has been edited by shinpaughp (edited 03-31-2003).]

haha! you are correct. major brain fart!

jebus

just out of curiosity is there a glut method?

i dont think so. but you can set it with glutWarpPointer(int x, int y). if you are using glut, set some globals in your passive mouse function callback, then you can tell where the mouse is all the time.

jebus

whats the passive mouse function? I only have mouse functions for when a mouse event happens.

You have two other mouse function, besides the glutMouseFunc.

I use the glutMouseFunc and glutPassiveMotion, to do a rubber band effect when drawing.

glutMotionFunc: mouse motion with button pressed inside the window

glutPassiveMotion: mouse motion inside window no buttons pressed

Originally posted by nick800:
whats the passive mouse function? I only have mouse functions for when a mouse event happens.

[This message has been edited by nexusone (edited 03-31-2003).]

I found it much better to have
static int mouse_x, mouse_y, mouse_b;
static int mouse_dx, mouse_dy, mouse_db; // detects changes in mouse state.

and set all those variables in each of every mouse functions (glutPassiveMotionFunc(), glutMotionFunc(), glutMouseFunc()).

Then, you cover all the mouse events at all time, and you can reuse that anywhere. I usually use functions

void GetMousePosition(int& mousex, int& mousey, int& mouseb);
void GetMouseMovement(int& mousedx, int& mousedy, int& mousedb);

gut does lack the basic getmouse() support.

You can use getMousePos(&POINT) or smthn, in glut, just remember coords will be from 1 to screen res like 1-640@y & 1-800@x

Originally posted by M/\dm/
:
You can use getMousePos(&POINT) or smthn, in glut, just remember coords will be from 1 to screen res like 1-640@y & 1-800@x

where is that function defined? not in glut.

glut does have glutGet() with a large list of enumerations, but no cursor positions (you can view them [ here ]. this has always baffled me, you can get window and screen coordinate information, but not the mouse position. wtf?!?

jebus

I think M/\dm/
was also referring to GetCursorPos.