Jump to content
  • Advertisement

Archived

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

emmai

how can I decrease fps when the game's main window is deactived?

This topic is 5330 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

in the WinProc:
BOOL g_bActive = FALSE;
...
case WM_SIZE:
			if( SIZE_MAXHIDE == wParam || SIZE_MINIMIZED == wParam )  
			{
				g_bActive = FALSE;
			}
			else
			{
				g_bActive = TRUE;
			}
			break;
		case WM_ACTIVATEAPP:
			g_bActive = wParam;
			return 0;
		case WM_ACTIVATE:
			if(LOWORD(wParam) == WA_ACTIVE || LOWORD(wParam) == WA_CLICKACTIVE)
				g_bActive = TRUE;
			else
				g_bActive = FALSE;
			return 0;
in game''s loop
if(!g_bActive)
	Sleep((1/32.0f)*1000);  //decrease fps,that another app can get more cpu

the previous code does work on my computer,but on another computers may got few fps even if the main windows is actived.I''m not sure why,can u help me?? best regards.

Share this post


Link to post
Share on other sites
Advertisement
You could rewrite your message pump to use GetMessage() instead of PeekMessage when the application does not have the focus.

EDIT: Although this doesn't do exactly what you want it to (although you could use a WM_TIMER to make sure it redraws reasonably often) if your game is not active, the chances are you're probably going to want to suspend it if you're not active anyway.

[edited by - Sandman on April 13, 2004 8:09:18 AM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Take a look at SetPriorityClass()
Call it when your window loses focus with IDLE_PRIORITY_CLASS, and again when the window regain focus with NORMAL_PRIORITY_CLASS

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!