Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [Solved] Sprite stretching due to setOutlineThickness on RectangleShape  (Read 1320 times)

0 Members and 2 Guests are viewing this topic.

mickey

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Inlimite
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?
« Last Edit: May 26, 2013, 06:49:36 pm by mickey »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Sprite stretching due to setOutlineThickness on RectangleShape
« Reply #1 on: May 25, 2013, 08:36:07 pm »
Update or downgrade your ATI drivers.
Laurent Gomila - SFML developer

mickey

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Inlimite
Re: Sprite stretching due to setOutlineThickness on RectangleShape
« Reply #2 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!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
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.
Laurent Gomila - SFML developer

mickey

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Inlimite
I will search for that then. Thank you very much!