SFML community forums

Help => Graphics => Topic started by: freetheworld on April 26, 2017, 08:21:17 pm

Title: Bug in scalling up small sprites... or am I doing it wrong
Post by: freetheworld on April 26, 2017, 08:21:17 pm
I don't know; if this has ever been brought up, It's happened like this for me ever since I started using sfml back around 1.4, if it's a bug, or I'm just doing it wrong.

I use the sprite.setScale() to set the size of my sprites no matter what the size of the incoming texture is, but for some reason it doesnt work if the texture is smaller than 32x32

float width = 64;
float height = 64;

sprite.setScale(width / sprite.getLocalBounds().width, height / sprite.getLocalBounds().height);

Funny part is, say I know my texture is 16x16 so I plug the numbers in without using getLocalBounds(), it works fine. ie...

sprite.setScale(width / 16, height / 16);

does exactly what I would expect.
Title: Re: Bug in scalling up small sprites... or am I doing it wrong
Post by: Hapax on April 26, 2017, 09:15:54 pm
I'm having a hard time trying to find a description of what is actually happening and what is going wrong in your post. It might be there but I'm failing to discover it, sorry.
Title: Re: Bug in scalling up small sprites... or am I doing it wrong
Post by: korczurekk on April 26, 2017, 10:44:20 pm
IMHO it looks like sprite.getLocalBounds().width and sprite.getLocalBounds().height somehow have wrong values, could you print them out and post here?
Title: Re: Bug in scalling up small sprites... or am I doing it wrong
Post by: eXpl0it3r on April 27, 2017, 10:35:05 am
Make sure you're calling getLocalBounds after you've set the texture and texture rect.