Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: 50% of CPU used to power a simple program  (Read 2171 times)

0 Members and 1 Guest are viewing this topic.

Dark Byte

  • Newbie
  • *
  • Posts: 30
    • View Profile
50% of CPU used to power a simple program
« on: October 24, 2010, 02:25:53 am »
I wanted to know why so much CPU is required to run this
Code: [Select]

#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>

int main()
{
sf::RenderWindow App(sf::VideoMode(800,600,32), "Test app");
sf::Image Back;
if ( !Back.LoadFromFile("background.png") )
App.Close();

sf::Sprite BackSPR;
BackSPR.SetImage(Back);
while ( App.IsOpened() )
{
App.Clear();
sf::Event Event;
while ( App.GetEvent(Event) )
{
if ( Event.Type == sf::Event::Closed )
App.Close();
}
App.Draw(BackSPR);

App.Display();
}

return 0;
}


The compiled program uses about 50% of my CPU.
Some computer info:
RAM 8gb
HDD 1tb
processor 2.6ghz

I am using MinGW to compile.

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
50% of CPU used to power a simple program
« Reply #1 on: October 24, 2010, 08:59:44 am »
You need to set a FPS limit. Check out the tutorials and search the forum.   :wink:
SFML / OS X developer

Dark Byte

  • Newbie
  • *
  • Posts: 30
    • View Profile
50% of CPU used to power a simple program
« Reply #2 on: October 24, 2010, 07:40:52 pm »
Oh lol thanks.

 

anything