View Full Version : Controlling apps
08-02-2005, 07:37 PM
Hi, I use glut to make my programs and evertime I run my program my CPU usage goes up to 100%. Is there a way in glut to keep this from happening?
All replies are greatly appreciated
08-03-2005, 12:29 AM
What are you drawing?
Rotations, translations, scalings and lighting involves lots of calculations.
And how fast is you're CPU?
These things affect the cpu usage, I don't think GLUT is caussing the problem.
08-03-2005, 12:50 AM
Do not render in the idle callback.
08-04-2005, 07:03 AM
I'm creating an entire scene that you can roam around in using a first person camera. Although this may seem to be the problem all of my apps take 100% CPU usage to try and get as many frames per second as possible. And I dont render in the idle function, I use glutDisplayFunc for rendering my scene.
Can you throw us a bone? :confused:
It's a good idea to wrap suspect code with profilers, so you'll always have a good idea where the time is spent. This way you can isolate problem areas within your app without guessing.
08-04-2005, 10:16 PM
"try and get as many frames per second as possible"
Well, that's a perfectly valid reason to get 100% CPU usage. If you continuously render (in whatever callback) you burn as much as your system can give.
08-05-2005, 04:57 AM
My program is running as many frames per seconds as it can on the machine it is running on. A simple window has the same problem. Here's the code for just a window, but it will use 100% CPU
void main(int argc, char ** argv)
}This program itself will run using 100% CPU power on any machine, I would like to know if there is a way to keep it from happening.
08-05-2005, 05:49 AM
Yes, don't do glutPostRedisplay() in the display routine.
Do it when you need a repaint. If the image doesn't change, don't repaint it.
If it changes all the time, you're stuck.
You could limit the framerate (and CPU load) by sending the update from a timer callback.
If that's all not feasible for your case, I would at least put the glutPostRedisplay() at the end of that function for peace of mind. ;)
The glFlush is useless and only needed for single buffered pixelformats. Remove it for double buffered ones.
ok, Thanks for all your help
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.