Crappy mouse behaviour
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?
Why not just reset the cursor position immediately after you read it? That's the more realistic datapoint anyway.
-me
-me
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 :)
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 :)
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:
and just drop the MOUSEMOVE message on the floor.
-me
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement