SFML community forums

Help => Graphics => Topic started by: pixartist on November 23, 2013, 08:32:19 pm

Title: Sprite::SetScale broken?
Post by: pixartist on November 23, 2013, 08:32:19 pm
So, I'm setting up a window with a resolution of 800x400 and I'm creating a 800x800 RenderTexture. Then I'm drawing a circle an a square onto the RenderTexture. Now I'm putting the texture into a sprite and setting the sprite scale to 0.5, 1. Now this should draw the sprite without any distortion, but it doesn't. The circle is stretched vertically by a factor of ~1.3. Why?

edit: Got it, scale is relative to the sprite size, not the window size. Used view now and the follwing code to set the size:

       
        float innerRatio = defaultContentSize.x / (float)defaultContentSize.y;
        float outerRatio = winSize.x / (float)winSize.y;
       
        if(innerRatio > outerRatio)
        {
                contentView.setSize(sf::Vector2f(defaultContentSize.x, defaultContentSize.y/outerRatio));
        }
        else
        {
                contentView.setSize(sf::Vector2f(defaultContentSize.x*outerRatio, defaultContentSize.y));
        }
        contentView.setCenter(Tools::VDiv(defaultContentSize, 2));
Title: Re: Sprite::SetScale broken?
Post by: The Hatchet on November 23, 2013, 08:34:38 pm
sounds like you're scaling the sprite's X and not the Y.