PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

VERY stange FPS problem

Hi,
I've made a very simple program that blits a fullscreen image to screen and a little sprite using GAPI calls. I have a decent frame rate : arount 50 FPS, so 20 ms to build each frame.
...
BUT
...
Some frames, say every 1 or 2 seconds require more than 100ms to be built !!!! Then, the moving sprite hasn't a smooth move : very annoying !

Each frame, I use this code to handle events :
Code:

MSG msg;
while (PeekMessage(&msg;, 0, 0, 0, PM_NOREMOVE) == TRUE)
{ GetMessage(&msg;, 0, 0, 0);
TranslateMessage(&msg;);
DispatchMessage(&msg;);
}


Am I doing something wrong ?
It seems like there is some other process running in background that asks for processor time every 1 or 2 seconds. I have an iPAQ H2210, I first thought to disable Bluetooth but it wasn't better.

Maybe there is a way to give my game thread the highest priority ?
Thanks for your help !!!!


FYI, I trap those messages :
Code:

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{ switch (message)
{ case WM_ENABLE:
break;
case WM_ACTIVATE:
...
break;
case WM_CREATE:
case WM_SETTINGCHANGE:
...
break;
case WM_LBUTTONDOWN:
...
break;
case WM_LBUTTONUP:
...
break;
case WM_MOUSEMOVE:
...
break;
case WM_DESTROY:
...
break;
case WM_KEYUP:
...
break;
case WM_KEYDOWN:
...
break;
case WM_KILLFOCUS:
...
break;
case WM_SETFOCUS:
...
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
Pejo Software - Per · 25 Apr 2004, 10:46 UTC
You can use SetThreadPriority.

I am not totally convinced that this is your problem but it might be a good idea to increase your priority one or two steps anyway. If you set a high priority you might have to make your thread sleep every now and then to allow other threads with lower priority to run.

Do not use CeSetThreadPriority unless you know exactly how this will affect the system.
OK thanks, it works perfectly now with SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST);
Are there any 'today screen' items running? I used to have a battery indicator that would cause a similar problem - but it would do that to all games.