Sign in to follow this  
r2d2rigo

Crappy mouse behaviour

Recommended Posts

Hello, I have been lurking in this forum for a very long time, but now it comes the time to register and post some questions :) So, I'm trying to do some kind of engine, mainly for FPS-type games. The problem comes when I want to translate the mouse moving into view rotation. I'm using standard OpenGL + Win32 API, and to check for mouse input I have the following code scheme in the WM_MOUSEMOVE message: GetCursorPos(); CalcPositionAwayFromCenter(); AddAngles(); And, after the render takes place, I SetCursor() the position to the center of the screen (to prevent endless loops if I do it in the WM_MOUSEMOVE piece). The problem is, if the polycount of the scene is ~3k polys, the mouse moves ok. But if I navigate and get to places with ~20-30k (the frame rate is the same, only the render takes some milliseconds more to complete), the mouse is completely lagged. Does anyone have a clue on why does this happen?

Share this post


Link to post
Share on other sites
Doing a call to SetCursorPos() generates a WM_MOUSEMOVE message. So, doing it inside the WM_MOUSEMOVE parsing function creates an endless loop... :P

EDIT: I'm going to try moving the mouse updating code to another place, so it looks like this:

ReadPosition();
AddAngles();
Render();
ResetPosition();

I'll tell you if this does work.

EDIT2: Okay, it works flawless now :) The solution was to do the following:

ReadPosition();
AddAngles();
ResetPosition();
Render();

Just as you said, Palidine. Thanks for the help :)

Share this post


Link to post
Share on other sites
But AFAIK you don't want to do it inside the message event queue. At least I never did anything like that when doing engine work. I've always just set up my app like this:


void updateInput()
{
//to use your code
GetCursorPos();
CalcPositionAwayFromCenter();
AddAngles();
SetCursorPos( centerOfScreen );
}

void update()
{
updateInput();
updateotherstuff();
}

int main()
{
//replace this with the PeekMessage gameloop deal (i forget the code)
while (running)
{
update();
}
}




and just drop the MOUSEMOVE message on the floor.

-me

Share this post


Link to post
Share on other sites
Yes, I did it just as you posted now. Look at the second edit of my previous post. Again, thanks for giving that idea. I can't believe I didn't think in anything that obvious :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this