Yep! I know that what I'm doing here is weird looking. The reason is because this is just meant to exhibit the bug, I wouldn't really use SFML like this, I promise!
Here's the code with clear calls before drawing is done on the window, with the same (wrong?) behavior...
#include <SFML/Graphics.hpp>
#include <list>
int main()
{
sf::RenderWindow window(sf::VideoMode(320, 240), "Test");
window.clear();
sf::RenderTexture buffer;
buffer.create(320, 240);
sf::RenderTexture buffer2;
buffer2.create(64, 64);
// Pink box
buffer.clear(sf::Color(255, 0, 255));
buffer.display();
// Blue box
buffer2.clear(sf::Color(0, 255, 255));
buffer2.display();
// Should draw a light blue box in the upper left corner with a pink
// background. OK!
buffer.draw(sf::Sprite(buffer2.getTexture()));
buffer.display();
window.draw(sf::Sprite(buffer.getTexture()));
window.display();
window.clear();
// White box.
buffer.clear(sf::Color(255, 255, 255));
buffer.display();
// Should draw a light blue box in the upper left corner with a white
// background. NOPE! Pure white background...
buffer.draw(sf::Sprite(buffer2.getTexture()));
buffer.display();
window.draw(sf::Sprite(buffer.getTexture()));
window.display();
while(window.isOpen())
{
sf::Event event;
while(window.pollEvent(event))
{
if(event.type == sf::Event::Closed)
window.close();
}
}
}
For a little background, I'm creating a JavaScript game engine here:
https://github.com/cha0s/avocado and I was interested in implementing a graphics backend using SFML. I've been testing it and this behavior is messing up my progress!