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

Author Topic: Sprite::SetScale broken?  (Read 1248 times)

0 Members and 1 Guest are viewing this topic.

pixartist

  • Newbie
  • *
  • Posts: 19
    • View Profile
Sprite::SetScale broken?
« 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));
« Last Edit: November 23, 2013, 08:41:07 pm by pixartist »

The Hatchet

  • Full Member
  • ***
  • Posts: 135
    • View Profile
    • Email
Re: Sprite::SetScale broken?
« Reply #1 on: November 23, 2013, 08:34:38 pm »
sounds like you're scaling the sprite's X and not the Y.