SFML community forums
Help => Graphics => Topic started by: aaroncm on January 14, 2013, 07:49:45 am
-
Hey, I can't find the answer to this anywhere (Well I could but not for 2.0)
How do I simply stretch a, say, 100x100 image to 1024x768.
sf::Texture/Sprites have no setSize() functions so I'm not sure, does it have something to do with views?
Thanks. ;)
-
sf::Sprite::setScale()
You have to calculate a little bit. The sprite's size can be retrieved from the rectangle sf::Sprite::getLocalBounds().
-
Hmm what sort of calculation? I've tried setScale but it seems to stretch the image way beyond the size I'm specifying. But I also can't seem to find any documentation of setScale for 2.0 either, so I'm not sure what it's doing.
Any ideas? :P
Thanks ;D
-
http://www.sfml-dev.org/documentation/2.0/classsf_1_1Sprite.php#a4c48a87f1626047e448f9c1a68ff167e (http://www.sfml-dev.org/documentation/2.0/classsf_1_1Sprite.php#a4c48a87f1626047e448f9c1a68ff167e)
There's where it is in the documentation.
If it helps (because the documentation never fully explains), you can get a number to give Sprite::setScale() if you ask yourself this question:
What do I need to multiply 100x100 by to get 1024x768? Which really means: What's 1024/100, and 768/100? The result will be 10.24 and 7.68, which are the values you can give setScale in this case.
-
Thanks guys, all working now ;D