4
« on: July 28, 2010, 04:49:34 pm »
Hi there, found a few posts on this topic but nothing with the same issue as mine, so thought I'd start a new thread.
I'm reasonably new to C++, although I have a lot of experience with Java/C#. I've gone through the tutorials and have a pretty good handle on pointers/references etc. I'm attempting a learn by doing approach with a project using sfml, but I'm finding the sprite drawing routines to not be as efficient as I would have hoped. I'm sure it's probably something in my code so I was wondering if someone wouldn't mind telling me if I'm doing something wrong.
None of this is final architecture, more of a test run for rendering tiles. If I make an array of 200x200 sprites, (all with the same image instance I think) and draw I get around 10 fps. I'll put in some clipping or whatever to cut out the offscreen ones but my concern is that the same app in xna doing 200x200 gets around 50 fps. Is this something I'll have to live with or is there something I'm doing that's drastically wrong?
Sprite Creation Code:
sf::Sprite ** tileMap;
tileMap = new sf::Sprite * [tileCount];
for(int i = 0; i < tileCount; i++)
{
tileMap[i] = new sf::Sprite [tileCount];
}
string strPath = "content" + string(PATH_SEPERATOR);
static sf::Image imageTest;
imageTest.LoadFromFile(strPath + "template.PNG");
imageTest.SetSmooth(false);
for(int i = 0; i < tileCount; i++)
{
for(int j = 0; j < tileCount; j++)
{
sf::Sprite sprite;
sprite.SetImage(imageTest);
tileMap[i][j] = sprite;
}
}
Drawing Code:
for(int i = 0; i < tileCount; i++)
{
for(int j = 0; j < tileCount; j++)
{
app.Draw(tileMap[i][j]);
}
}
Obviously if I cut out the app.Draw call it runs at 2000fps or something similar. It's definitely the drawing call that's slowing everything down.
Edit: All with SFML 1.6 and yes I'm testing fps with release build.