I made this
http://en.sfml-dev.org/forums/index.php?topic=9624 post with the same problem, and i have found some new things to add to this very peculiar bug.
I (almost (see Case 3)) only get the bug when drawing 2 Shapes, not with 1. The 2 Shapes yields the same result as one Shape with the setOutlineThickness(2.0f);.
If you have several Sprites with the same texture, only the first
of one type of texture will not work. Thus if you try to draw 3 Sprites with Texture 1 (and some RectangleShapes or whatnot to get the bug) they will not work, but after that you can draw a Sprite with another Texture and after you have drawn that one you can draw the first Texture!
It's hard to explain in text so here is the code used and some images:
#include "stdafx.h"
#include <SFML/Graphics.hpp>
using namespace sf;
int main(){
RenderWindow window(VideoMode(150, 140, 32), "SFML", Style::Default);
window.setFramerateLimit(4);
CircleShape fooShape(20.0f, 30);
CircleShape barShape(25.0f, 30);
fooShape.setPosition(10.0f, 10.0f);
barShape.setPosition(70.0f, 20.0f);
Texture aTexture1;
aTexture1.loadFromFile("texture1.png");
Texture aTexture2;
aTexture2.loadFromFile("texture2.png");
Sprite sprite1;
sprite1.setTexture(aTexture1);
sprite1.setPosition(15.0f, 100.0f);
Sprite sprite2;
sprite2.setTexture(aTexture1);
sprite2.setPosition(40.0f, 100.0f);
Sprite sprite3;
sprite3.setTexture(aTexture1);
sprite3.setPosition(65.0f, 100.0f);
Sprite sprite4;
sprite4.setTexture(aTexture2);
sprite4.setPosition(90.0f, 100.0f);
Sprite sprite5;
sprite5.setTexture(aTexture1);
sprite5.setPosition(115.0f, 100.0f);
Sprite sprite6;
sprite6.setTexture(aTexture1);
sprite6.setPosition(40.0f, 50.0f);
bool drawFoo = false;
bool drawBar = false;
bool drawOtherSprites = true;
bool drawTexture2 = true;
bool drawMiddle = false;
while(window.isOpen()){
Event Event;
while(window.pollEvent(Event)){
if(Event.type == Event.KeyPressed){
if(Event.key.code == Keyboard::U){/*Choose if drawing first shape*/
if(drawFoo) drawFoo = false;
else drawFoo = true;
}else if(Event.key.code == Keyboard::I){/*Choose if drawing second shape*/
if(drawBar) drawBar = false;
else drawBar = true;
}else if(Event.key.code == Keyboard::O){/*Choose if drawing other sprites than the first and the middle-Sprite*/
if(drawOtherSprites) drawOtherSprites = false;
else drawOtherSprites = true;
}else if(Event.key.code == Keyboard::P){/*Choose if drawing Sprite with texture2*/
if(drawTexture2) drawTexture2 = false;
else drawTexture2 = true;
}else if(Event.key.code == Keyboard::L){/*Choose if drawing texture1 Sprite between drawing of shapes*/
if(drawMiddle) drawMiddle = false;
else drawMiddle = true;
}
}
}
window.clear(Color(200, 100, 40));
if(drawFoo)
window.draw(fooShape);
if(drawMiddle)
window.draw(sprite6);
if(drawBar)
window.draw(barShape);
window.draw(sprite1);
if(drawOtherSprites){
window.draw(sprite2);
window.draw(sprite3);
if(drawTexture2)
window.draw(sprite4);
window.draw(sprite5);
}
window.display();
}
return EXIT_SUCCESS;
}
(I'm using Visual C++ 2010 Express, a XFX Radeon 5750 graphics card and i updated to the latest SFML 2.0 build today)
Case 1.
All Sprites. Only the first few are affected. When not drawing second textured sprite, all are affected.
Case 2.
I also noticed a difference when i have transparency in my Textures:
Exactly the same as before but with transparency instead of white background.
As seen the partially transparent Textures will not draw anything at all instead of a white box.
Case 3.
Also, when drawing only the first Sprite, it will be affected by the bug after one of the Shapes have been set to not drawing, furthermore if i then start drawing the other Sprites
it will take exactly 1 frame to update and show all the Textures correctly:
Bug. Still Bug. This will show for exactly one frame and then revert to this.
This is the reason of window.setFramerateLimit(4); in the code, because it will not be noticeable with a framerate of 60 or even 10.
Case 4.
As you said in the posts before, after a Shape has been drawn, the Sprites after that one will not work, in my case, after 2 shapes, and if i draw one Sprite of texture1.png, between those two Shapes, everything will render normally, except if i remove the middle Sprite and then draw it again, it will produce something like in Case 3.
This is way too much info, but if any one can get something out of this I'm happy to help!