Hi everyone! I'm very new to SFML, pardon if I'm making a glaring error here...
Normally my game runs at about 150 fps, but as soon as I load an 800x600 PNG background, assign it to a background Sprite, and Draw() it in my game loop, the game plummets to <10 fps.
My code looks something like this:
void Game::gameMain()
{
// Game loop
while (!quitLevel && window.IsOpened())
{
// Process events
// ...event handling...
// This changes depending on what the current level is. Right now it's set to level1().
(this->*updateAndDisplay)();
window.Display();
}
}
void Game::level1()
{
// SPRITES
static sf::Image background1Im;
// Sprite is a derived class of sf::Sprite with a few wrapper functions included.
static Sprite background1;
// INITIALIZED WORLD
if (!initializedLevel)
{
// Load images
background1Im.LoadFromFile("background1.png");
background1.SetImage(background1Im);
// ...
initializedLevel = true;
}
// ...
// DRAW WORLD
// fillScreen(50, 50, 50);
window.Draw(background1);
}
I'm compiling in Visual Studio Express 2010 with the static libraries. I'm running it on a pretty low-performance laptop, but I can still play 3D games, so I can't imagine that's the cause of the performance hit.
What I'm actually trying to do is cut up a 8000x600 background into 800x600 pieces (the game is a sidescroller) since SFML doesn't seem to be able to load textures that large.