Archived

This topic is now archived and is closed to further replies.

Skute

Non Focused Direct3D Window?

Recommended Posts

When i create a D3D window and display a triangle or anything like that, and then i blur the window (ie bring something else into focus other than the animation window), it lags my pc, the mouse jerks about over the screen and my pc almost freezes... Trying to close the window manually is sometimes too slow so i have to resort to ctrl alt del. Anyone know any good code i can put in the winproc to stop this happening when it doesnt have focus, and what implications would that have if someone say pressed the window key (if this was an actual game) Regards,

Share this post


Link to post
Share on other sites


case WM_ACTIVATEAPP:
bool fActive;
fActive = (bool)LOWORD(wparam);
if (mysub)
{
if (fActive == FALSE)
{
mysub->OnAppLostFocus();
}
else
{
mysub->OnAppGainFocus();
}
}




When your app is "Lost Focus", unaquire the device, and stop rendering, and slow down the game loop to like 100ms per interation. Thats what I do. Works fine for me. Make sure you you still call the GetMessage/TranslateMessage while its in the slowdown state. Otherwise the app might not get focus back.

Share this post


Link to post
Share on other sites
what would i need todo to slow it down as you say?
i was originally thinking about using sleep statements, but from what you say it propabably would lag the program if it tryed to get focus.

regards,

Share this post


Link to post
Share on other sites