Windows Events
Posted: Wed Jan 11, 2006 2:16 pm
What event-like commands do PureBASIC users recommend for fullscreen games programming in a multi-tasking operating system like Windows?
What seems ideal is something like this DirectX code which doesn't halt the program completely to let Windows back-in (which is inefficient). It takes care of Windows calls and gives the program the time that is left (to render in the example).
WPARAM StartMessageLoop()
{
MSG msg;
while(1)
{
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
// use idle time here
Render();
}
}
return msg.wParam;
}
What seems ideal is something like this DirectX code which doesn't halt the program completely to let Windows back-in (which is inefficient). It takes care of Windows calls and gives the program the time that is left (to render in the example).
WPARAM StartMessageLoop()
{
MSG msg;
while(1)
{
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
// use idle time here
Render();
}
}
return msg.wParam;
}