# The mouse

It looks like there’s not a lot of traffic on this board, but maybe someone can help me out. I’m just trying to find out the best way to read the mouse position. I’m building an OpenGL engine, and want to implement a standard mouse-driven camera. I think that I need to get the mouse position relative to the position the previous frame, but I’m not sure how to do this. Using the standard toolbox mouse routines gives you a coordinate in screen space, which means that once you’ve gone so far to the left, for example, you can’t go any farther. Obviously that isn’t what you want for mouse-driven movement.

I’m sure there’s a standard way of doing this. Anyone know what it is? Thanks.

Wouldn’t you just need to know the position of the mouse relative to the centre of the screen? So if the mouse is at x/2, y/2 there is no movement?

gav

I’ve noticed too that there aren’t many visitors in this forum. There is, however, a LOT of traffic on the Apple OpenGL mailing list and newsgroups. Check it out: http://lists.apple.com/

[This message has been edited by Decimal Dave (edited 08-10-2001).]

Thanks, I’ll check out that link.

I don’t think knowing the position of the mouse in relation to the center of the screen is enough. You only want movement when the mouse position has changed, so you need to know the position of the mouse relative to its previous position. Normally, when the mouse reaches the edge of the screen, it has reached x or y = screenMin or screenMax, and can’t move any farther. This would mean that you could only move so far, but then you would have to move back the other way.

It seems that you need a way to set the mouse coordinates as well as read them, so you can snap the mouse coords back to the center of the screen after every read. But I don’t know how to do that

Snap the mouse back to the centre!? Are you sure? Knowing the position of the mouse relative to the last frame is easy.

/* global; */
int last_mouse_x, last_mouse_y;

void mouse_move_func(int x, int, y /** someother bits, c an’;t remember /)
{
/
do your translations **/

/*****************************/
last_mouse_x = x;
last_mouse_y = y;

}

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.