[gameprogrammer] Re: game taking up a lot of cpu when minimized

I found a solution to this, what i did is i keep track of whether the window
has focus or not (by watching the WM_KILLFOCUS and WM_SETFOCUS events in the
wndproc) and if the game does not have focus, it does a sleep of 250ms
instead of running the game logic, but of course the messagepump still runs
every loop!

That solved it pretty well

On Sat, Apr 25, 2009 at 8:44 PM, Biswanath Das <biswanath.che@xxxxxxxxx>wrote:

> Dear Alan,
>
> Check your message loop. It might not be the normal loop that is there in
> Win32 project.
>
> Regards
> Biswanath Das
>
>
> On Sun, Apr 26, 2009 at 8:51 AM, Alan Wolfe <alan.wolfe@xxxxxxxxx> wrote:
>
>> ok so i think this is a fairly common problem, cause i hit it before when
>> working on a project with some other people but i dont remember how it was
>> solved....
>>
>> im makin a game on the windows platform in directx, and when my game
>> window is obscured or it's minimized, etc, it eats up a ton of cpu.
>>
>> i'm guessing it's because vsync isn't there to slow it down (since nothing
>> is being rendered) but im not sure.
>>
>> When a d3d error of D3DERR_DEVICELOST is returned, i have it sleep for
>> 500ms before going to the next game loop.  I thought that was the fix for
>> this problem but im finding that i am NEVER getting the device lost error
>> when minimizing or the window is obscured.
>>
>> anyone know how to handle this issue?
>>
>> Thanks!
>> Alan
>>
>
>

Other related posts: