I tested it, finally!
Actually, drawing into a RenderTexture is about 15x slower than drawing directly into the RenderWindow...
Main code (shared part)
#include <SFML/Graphics.hpp>
#include <iostream>
using namespace std;
/*
*
*/
int main()
{
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML tests");
sf::RenderTexture screenBuffer;
screenBuffer.create(window.getSize().x, window.getSize().y);
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
shape.setOutlineColor(sf::Color::Yellow);
shape.setOutlineThickness(5);
shape.setPointCount(shape.getPointCount()*1.5);
shape.setOrigin(100, 100);
shape.setPosition(400, 300);
sf::Clock clock;
sf::Texture texture;
texture.loadFromFile("bin/img.png");
sf::Sprite sprite(texture);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
switch (event.type)
{
case sf::Event::Closed:
window.close();
break;
default:
break;
}
}
/* TEST PART, LOOK BELOW */
window.display();
cout << clock.restart().asMicroseconds() << endl;
}
return 0;
}
RenderWindow test part: (output: ~14800 microseconds)
for(int i=0; i<1000; ++i)
{
window.clear();
sprite.setColor(sf::Color(255, 255, 255));
window.draw(sprite);
window.draw(shape);
sprite.setColor(sf::Color(255, 255, 255, 100));
window.draw(sprite);
}
RenderTexture test part: (output: ~222000 microseconds)
for(int i=0; i<1000; ++i)
{
screenBuffer.clear();
sprite.setColor(sf::Color(255, 255, 255));
screenBuffer.draw(sprite);
screenBuffer.draw(shape);
sprite.setColor(sf::Color(255, 255, 255, 100));
screenBuffer.draw(sprite);
screenBuffer.display();
window.draw(sf::Sprite(screenBuffer.getTexture()));
}
Am I doing something wrong?