SFML community forums

Help => Graphics => Topic started by: achpile on July 19, 2013, 09:30:16 am

Title: Scale sprites with repeating instead of stretching
Post by: achpile on July 19, 2013, 09:30:16 am
Hi. I'm new in SFML, but have experience in OpenGL.
Well... Is there a way to fill background with some sprite in SFML v1.6?

For example sprite size is 512x512, screen size is 1024x768.

If I resize it to screen size, the texture coordinates will still be the (0, 0) - (1, 1) and the sprite streches.
How can I resize sprite with changing texture coordinates to (0, 0) - (2, 1.5) to fill all the background without "for" statements etc.?

I've read about sf::RenderTexture and method setRepeated(bool), but it is in SFML v2.0
Title: Re: Scale sprites with repeating instead of stretching
Post by: Laurent on July 19, 2013, 09:42:20 am
This is not possible with SFML 1.6. But you should seriously consider switching to SFML 2.0.
Title: Re: Scale sprites with repeating instead of stretching
Post by: achpile on July 19, 2013, 09:51:43 am
Thanks a lot, Laurent! I'll do it right now.
And your project is awesome!  ;)
Title: Re: Scale sprites with repeating instead of stretching
Post by: achpile on July 19, 2013, 10:58:58 am
Sorry, but how to use it?

I'm doing this:

BackgroundTexture.loadFromFile("data/img/gui/mainmenu/bg.jpg");
BackgroundTexture.setRepeated(true);
Background.setSize(sf::Vector2f(1024,768));
Background.setTexture(&BackgroundTexture);

but the image is still scaling instead of repeating
Title: Re: Scale sprites with repeating instead of stretching
Post by: achpile on July 19, 2013, 11:03:21 am
Sorry, just found an answer... setTextureRect. Anyway thank you very much!!!