View Full Version : my simple demos often cause CPU usage 100%,why?

05-14-2005, 07:20 AM

05-14-2005, 08:25 AM

05-14-2005, 09:05 AM
Most code frameworks use a "render as many frames as possible" scheme. This means that either a part of the GPU pipeline or the CPU will always run at 100%. This is expected behaviour and nothing to worry about.

05-14-2005, 04:10 PM
For a full-screen app, I think it is ok.
But, for a windowed app, I don't think it is always good.

05-16-2005, 11:27 PM
Insert a 1ms delay somewhere in the loop of your code. This will drasticly reduce cpu usage and makes almost no difference in game performance.


05-17-2005, 01:14 AM
Most of the simple tutorials put their rendering calls into the idle loop. This is "game style".
If you don't need that, write a standard window message handler and do the drawing inside the WM_PAINT handler and you won't use any CPU cycles if your demo doesn't need to react on paint messages.
If you want it animated, setup a timer with SetTimer() and a WM_TIMER message handler calling InvalidateRect() which sends WM_PAINT messages to your handler.
Very clean, but not to be used for fullspeed or benchmarks.