![]() |
| [[ Home | Forums | 3D Engines Database | Wiki | Articles/Tutorials | Game Dev Jobs | IRC Chat Network | Contact Us ]] |
|
|
#1 |
|
New Member
Join Date: Jul 2004
Posts: 1
|
I noticed that the CPU usage was spiking to 100% when the app was not active. Normally this is if its a windowed app, or if you alt-tabbed out of a full screen app.
I fixed this by having the framework sleep 5 seconds in the main loop if it wasn't active. look at the code below, I added an else, and the Sleep inside it. Code:
|
|
|
|
|
|
#2 |
|
DevMaster Staff
Join Date: Sep 2003
Location: Hell
Posts: 1,109
|
yeah, that should have been done before. Always good to let the CPU have some time to itself when inactive.
|
|
|
|
|
|
#3 | |
|
New Member
Join Date: Jan 2005
Posts: 1
|
Quote:
I've had a think about this and would like to suggest an alternative. The active status should only change when a windows message is received. Ideally the game should respond as soon as this is received. A way to do this is to replace the Sleep call with a GetMessage() / TranslateMessage() / DispatchMessage() set of calls. The GetMessage() call will block until a message is received and so free the CPU until the game needs it again. |
|
|
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|