views:

30

answers:

1

I'm programming a GUI in my app and I noticed that button presses weren't being registered very quickly. I did some lazy debugging (send coordinates of mouse to output) and I noticed that Input's GetMouseX and GetMouseY weren't responding nearly fast enough to when the mouse moved somewhere.

This small tidbit should be able to reproduce it (in a HandleEvents function that is called in a typical game loop, obviously replace App::whatever with whatever you have in your workspace).

int x = App::GetApp()->GetInput().GetMouseX();
int y = App::GetApp()->GetInput().GetMouseY();
std::cout << x << " " << y << "\n";

Just move your mouse around on the screen and watch the output. I'm not sure if this is correct behavior and I'm using it for the wrong purpose, or what, but I need some way to retrieve the mouse's exact location at any given time. Any help is appreciated, thanks.

P.S. If I move the mouse slowly the problem doesn't occur.

Edit:

I was wrong. The problem only occurs in context with the rest of the stuff going on. When I blocked out most of the game loop and only included retrieving cursor position, it worked fine. Still not sure what is wrong though.

+1  A: 

The problem was that I was only polling one event per frame rather than polling all of the events.

random