while ( isRunning )
{
...
// 1a. Pick up message
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
//1b. Handle message
}
// 2. Renders scene
Update();
...
}
I do not understand, what is wrong with HTC devices, that they handle key press related message so slowly, that it blocks the game loop. I thought this is a common issue, so I tried to search Internet, but the only reference I found was there http://blogs.msdn.com/windowsmobile/archive/2007/08/13/have-you-migrated-to-directdraw-yet.aspx. Guy named Fred Di Sano wrote:
"…Getting input via the message pump is kind of clunky and in some cases (like on various HTC devices) it slows down the app!", but I do not find any other reference..."
I did not found any solution except defining the maximal number of messages that can be processed in the loop iteration:
// Max. messages that are processed in one step
const int KMaxMessagesProcessedInOneStep = 3;
while ( isRunning )
{
...
// Messages processed
int messagesProcessed = 0;
// 1a. Pick up message
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
//1b. Handle message
// Check how many messages were processed
messagesProcessed++;
if ( messagesProcessed > KMaxMessagesProcessedInOneStep )
break;
}
// 2. Renders scene
Update();
...
}
I believe this is not the best solution, so if anyone can suggest something better I will appreciate it.
0 comments:
Post a Comment