So basically, we have a std::map of sprite objects (gameSprites). Every render, we do this:
for (size_t i = 0; i < displayListLen; i++)
{
string tmpStr = displayList.at(i);
if (gameSprites[tmpStr].gfxScr == 1)
window1.Draw(gameSprites[tmpStr].Sprite);
}
...that's pretty much it. As I said, I can trace this to the size of sprites being drawn. Lots of little sprites = no problems. One or more large sprite = 1fps. Not sure if there is anything else you need to see?
We load the tiles/images at start-up, and then display. The problem only seems to be on this hardware :(
Thanks for the help. With the new version of SFML, and this test code:
int _tmain(int argc,_TCHAR *argv[])
{
// Create the main window
sf::RenderWindow window1(sf::VideoMode(1024,768,32), "SFML window 1",sf::Style::None);
sf::RenderWindow window2(sf::VideoMode(1024,768,32), "SFML window 2",sf::Style::None);
sf::Vector2i pos(1024,0);
window2.setPosition(pos);
window1.setFramerateLimit(30); // Set to 30fps max
window2.setFramerateLimit(30); // Set to 30fps max
// Load a sprite to display
sf::Texture texture;
if (!texture.loadFromFile("test.png")) // could be a PNG, whatever
return EXIT_FAILURE;
sf::Sprite sprite(texture);
// Start the game loop
while (window1.isOpen())
{
// Process events
sf::Event event;
while (window1.pollEvent(event)) // Click X in top right of window to close program
{
// Close window : exit
if (event.type == sf::Event::Closed)
{
window1.close();
window2.close();
}
}
// Clear screen
window1.clear();
window2.clear();
// Draw the sprite - see Sprite::Render where vertexs are added, and Renderer::ProcessVertex where the gl stuff is done
window1.draw(sprite);
window2.draw(sprite);
// Update the window
window1.display();
window2.display();
}
return EXIT_SUCCESS;
}
I get 100% CPU. Switch to 1 window, and it's 1% CPU :D
Run it on other (non Intel 82855 chipset) and with 2 windows - which we need to have - it's 1% CPU again. So it is the crap hardware that's the problem, and by the looks of it, nothing can be done to fix this with the new SFML updates. Oh well!