Sorry, I'm pretty new at SFML (though I tried it once a few years ago and never got any traction). I am sure I am just misunderstanding this feature, but here goes. I tried to get the code down to the simplest version of the problem.
From the documentation, it seemed that if the shape was set to be larger than the texture or selected texture rect, and setRepeated was set to true, it would tile it repeatedly, but for me it just stretches. Here's some code that I believe outlines my problem along with the output screenshotted:
#include <SFML/Graphics.hpp>
int main()
{
sf::Texture tex;
if(!tex.loadFromFile("crossed lines.png"))
{
}
tex.setRepeated(true);
sf::RectangleShape rect1;
sf::Vector2f rectsize1(50, 50);
rect1.setSize(rectsize1);
rect1.setTexture(&tex, false);
rect1.setPosition(0, 0);
sf::RectangleShape rect2;
sf::Vector2f rectsize2(100, 100);
rect2.setSize(rectsize2);
rect2.setTexture(&tex, false);
rect2.setPosition(100, 100);
sf::RenderWindow window(sf::VideoMode(800, 600), "My window");
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear(sf::Color::White);
window.draw(rect1);
window.draw(rect2);
window.display();
}
return 0;
}
The output is attached.
So I guess my question is, how can I get this to repeat over rect2 instead of just stretch it?