Using LESS system resources

Started by
17 comments, last by VanKurt 20 years, 5 months ago
I read somewhere that games like half life use up 99% of CPU and it is not necessarily a "bad thing"
Advertisement
Every game uses all the cpu time they can get and that''s good, but when they don''t have focus then it''s bad, a game must use a different loop when not in focus to free the cpu when not active.
So can''t you just stop or "pause" the main loop when you''ve lost focus? Wouldn''t that free the CPU up for the other things?
is there a way to let your program test fi it has focus so you can do one thing " on focus" and another off focus?
Hooks are not necessary.

Testing ''do we have focus'' is still the wrong way to approach the problem. This is really just a programing Windows 101 question here. The original poster simply needs to register hotkeys for the keys to watch and process those messages inside the application.
--God has paid us the intolerable compliment of loving us, in the deepest, most tragic, most inexorable sense.- C.S. Lewis
How do you register those hotkeys? i used hooks for it before and it worked ok (yes, i agree that you must be carefull with them) but registered hotkeys sounds a better approach.
RegisterHotKey();
UnregisterHotKey();

MSDN is your friend.
--God has paid us the intolerable compliment of loving us, in the deepest, most tragic, most inexorable sense.- C.S. Lewis
Sure you could do it that way, but it''d be a million times easier to use a GetKeyAsync or whatever its called. Sure it won''t be "right," but it isn''t going to use any processor at all as long as it''s calling Sleep(). You can then use a PeekMessage inside the main loop.
My Page : http://acidbase.computed.net
Wow! So many good ideas! Thanks people!
I''ll have a look at all of them...

THANKS!! :-D

This topic is closed to new replies.

Advertisement