I ran across a very strange issue while working on my game. I use the latest SFML2 library.
This is the code I'm working with for reference:
while (window.isOpen())
{
window.clear();
// just some sprite
sf::Sprite sprite;
sf::Texture * txtr = new sf::Texture();
txtr->loadFromFile("images/shipViewBg.png");
sprite.setTexture(*txtr);
// just some shape
sf::RectangleShape shape;
shape.setOutlineThickness(1); // <-- important line
shape.setPosition(50,50);
shape.setSize(sf::Vector2f(50,50));
window.draw(sprite);
window.draw(shape);
window.display();
}
Now, the issue:
I want to be able to display a bunch of sprites and then draw a transparent rectangle on top with only a border (a selection box basically)
What I found was that when I set a border thickness to my box, the first sprite to be draw on screen gets stretched out significantly. If I comment out the border thickness, both draw correctly.
Here are a few comparison screenshots with the previous code:
Code as is above.
Thickness line commented out
// shape.setOutlineThickness(1);
Only drawing the shape
Only drawing the sprite
The strange thing is is that it only affect the first sprite drawn on screen. All subsequent sprites are draw correctly. Just the first one is stretched out.
Any thoughts? Am i doing something wrong?