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

Author Topic: Program extremely laggy?  (Read 1836 times)

0 Members and 2 Guests are viewing this topic.

Portalboat

  • Newbie
  • *
  • Posts: 9
    • View Profile
Program extremely laggy?
« on: February 08, 2011, 12:02:28 am »
I made a simple program, and it's extremely laggy, taking up 98% of my CPU. Why is this? Did I do something wrong?
Code: [Select]
#include <SFML/Graphics.hpp>
#include "Player.h"
int main()
{
//Create main window, using the best available resolution, and make the reference
sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Window");
sf::RenderWindow &rApp = App;

//Control framerate to reduce CPU usage
App.SetFramerateLimit(30);

//Reference Classes
Player player(rApp);

//This is the main loop, it will loop until you exit the system.
while (App.IsOpened())
{
//Here we process the events list
sf::Event Event;
while (App.GetEvent(Event))
{
//Close window: exit
if (Event.Type == sf::Event::Closed)
{
App.Close();
}
//Clear the screen with a color
App.Clear();
//Here you will draw all of the stuff in the frame buffer
player.Update();
//Render the frame on screen
App.Display();
}
}
return EXIT_SUCCESS;
}


And Player.h:
http://pastebin.com/AA0wwrP6
Player.cpp:
http://pastebin.com/QXNPkurf

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
Program extremely laggy?
« Reply #1 on: February 08, 2011, 12:16:18 am »
Your render code shouldnt be inside the event loop

Portalboat

  • Newbie
  • *
  • Posts: 9
    • View Profile
Program extremely laggy?
« Reply #2 on: February 08, 2011, 01:32:28 am »
....whoops.