In this sample code below alternating red and blue squares should be shown when space is pressed, but the red square is not displayed. This is using the SFML 2.0 branch version from Jan. 27. This problem doesn't occur if either the first buffer.Draw(sprite) in the code is commented or the second is uncommented. Also, it works for an older version from Dec. 17. (compiled using MinGW/Codeblocks in Windows XP)
#include <SFML/Graphics.hpp>
int main(){
sf::RenderWindow window(sf::VideoMode(640, 480, 32), "");
sf::RenderImage buffer;
buffer.Create(640, 480);
sf::Sprite bufsprite;
bufsprite.SetImage(buffer.GetImage());
sf::Image image; image.Create(1, 1);
sf::Sprite sprite(image);
int mode = 0;
while (window.IsOpened()){
sf::Event event;
while (window.GetEvent(event)){
if (event.Type == sf::Event::KeyPressed){
if (event.Key.Code == sf::Key::Escape) window.Close();
else if (event.Key.Code == sf::Key::Space) mode = 1-mode;
}
}
buffer.Clear();
if (mode == 0){
buffer.Draw(sprite);
buffer.Draw(sf::Shape::Rectangle(0, 0, 200, 200, sf::Color(0,0,255)));
}else{
//buffer.Draw(sprite);
buffer.Draw(sf::Shape::Rectangle(0, 0, 200, 200, sf::Color(255,0,0)));
}
buffer.Display();
window.Draw(bufsprite);
window.Display();
}
return EXIT_SUCCESS;
}