SFML community forums

Help => Graphics => Topic started by: mickey on May 25, 2013, 06:27:15 pm

Title: [Solved] Sprite stretching due to setOutlineThickness on RectangleShape
Post by: mickey on May 25, 2013, 06:27:15 pm
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:

(http://i.imgur.com/LJnxrte.jpg)
Code as is above.

(http://i.imgur.com/BT6cAJj.jpg)
Thickness line commented out
// shape.setOutlineThickness(1);

(http://i.imgur.com/jOHhSUG.jpg)
Only drawing the shape

(http://i.imgur.com/TMkDurJ.jpg)
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?
Title: Re: Sprite stretching due to setOutlineThickness on RectangleShape
Post by: Laurent on May 25, 2013, 08:36:07 pm
Update or downgrade your ATI drivers.
Title: Re: Sprite stretching due to setOutlineThickness on RectangleShape
Post by: mickey on May 26, 2013, 06:48:21 pm
Update or downgrade your ATI drivers.

This worked. How strange that the problem is so specific. Is there no other way to fix this issue? Id like to know in case someone who plays my game has the same not updated driver. I wouldn't want them to not see the background.  :/

Thank you though!
Title: Re: [Solved] Sprite stretching due to setOutlineThickness on RectangleShape
Post by: Laurent on May 26, 2013, 07:10:42 pm
To be clear: the problem is on ATI side, so there's no clean way to solve it.

However, someone posted a simple workaround on the forum, I think it was a few months ago. You can try to find it.
Title: Re: [Solved] Sprite stretching due to setOutlineThickness on RectangleShape
Post by: mickey on May 26, 2013, 07:13:07 pm
I will search for that then. Thank you very much!