-
my simple demos often cause CPU usage 100%,why?
-
Re: my simple demos often cause CPU usage 100%,why?
-
Re: my simple demos often cause CPU usage 100%,why?
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.
-
Re: my simple demos often cause CPU usage 100%,why?
For a full-screen app, I think it is ok.
But, for a windowed app, I don't think it is always good.
-
Re: my simple demos often cause CPU usage 100%,why?
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.
Mark
-
Senior Member
OpenGL Guru
Re: my simple demos often cause CPU usage 100%,why?
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules