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

Author Topic: Bug in scalling up small sprites... or am I doing it wrong  (Read 1792 times)

0 Members and 1 Guest are viewing this topic.

freetheworld

  • Newbie
  • *
  • Posts: 4
    • View Profile
Bug in scalling up small sprites... or am I doing it wrong
« 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.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Bug in scalling up small sprites... or am I doing it wrong
« Reply #1 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.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

korczurekk

  • Full Member
  • ***
  • Posts: 150
    • View Profile
    • Email
Re: Bug in scalling up small sprites... or am I doing it wrong
« Reply #2 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?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Bug in scalling up small sprites... or am I doing it wrong
« Reply #3 on: April 27, 2017, 10:35:05 am »
Make sure you're calling getLocalBounds after you've set the texture and texture rect.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/