SFML community forums
Help => General => Topic started by: vicer1234 on May 19, 2011, 07:05:40 pm
-
Hi,
I am just running a simple code:
int main(int argc, char* argv[])
{
sf::RenderWindow Game(sf::VideoMode(800, 600, 32), "Box2d");
while(Game.IsOpened())
{
while(Game.GetEvent(Event))
{
if(Event.Type == sf::Event::Closed)
Game.Close();
}
Game.Clear(sf::Color(127, 149, 237));
Game.Display();
}
}
when i check the CPU usage in task manager it is around 45-50%.
Why so much high percentage usage, am i doing something wrong?
-
There is a loop there, which goes on infinitely.
That means the CPU will process that loop as fast as it can. If you have a dualcore cpu, the 50% stands for one of cores processing at full speed.
I believe this is common in Real time applications!
-
There is a loop there, which goes on infinitely.
That means the CPU will process that loop as fast as it can. If you have a dualcore cpu, the 50% stands for one of cores processing at full speed.
I believe this is common in Real time applications!
Hi,
That means in a GameLoop, which also runs infinitely, the CPU percentage will be high. When the game loads and does complex process like physics etc the CPU will increase further?????
-
There is a loop there, which goes on infinitely.
That means the CPU will process that loop as fast as it can. If you have a dualcore cpu, the 50% stands for one of cores processing at full speed.
I believe this is common in Real time applications!
Hi,
That means in a GameLoop, which also runs infinitely, the CPU percentage will be high. When the game loads and does complex process like physics etc the CPU will increase further?????
No, it will stay the same, but the framerate will decrease. Limit the framerate (there's a function to do that) to reduce the cpu usage. You'll find that it should be using less than 1% of your cpu for this particular program.
-
It is using high cpu because you didn't put any fps limit.
http://www.bit-tech.net/news/gaming/2010/08/03/starcraft-2-doesn-t-limit-framerates/1 should be relevant
You can easily fix this issue by putting this code
Game.SetFramerateLimit(60);
-
this should answer a lot of your questions
http://dewitters.koonsolo.com/gameloop.html