Hi there,
I've a problem : I need a giant circle to have a texture that is repeated inside of it. Let say the circle radius is 1024px, my texture is 512x512px. The problem is the texture does not repeat itself (with
texture.setRepeated(true)) and is stretched to fit the circle size (so the texture is "zoomed").
I do not have this problem with a sprite of 1024x1024, the texture is well repeated.
I do not understand because sf::Sprite and sf::Shape both inherit from sf::Transformable
Minimal code :
int main()
{
sf::RenderWindow window(sf::VideoMode(2048, 1024), "Ant");
sf::Texture ground; // ground is 512x512
ground.setSmooth(true);
ground.setRepeated(true);
ground.loadFromFile("ground.png");
float radius = 1024;
sf::CircleShape planet;
planet.setOrigin(radius, radius);
planet.setTexture(&ground);
planet.setRadius(radius);
planet.setPointCount(radius*180);
planet.setPosition(1024, 512);
// It works with a sprite
/*sf::Sprite spr;
spr.setTextureRect(sf::IntRect(0,0,2048,2048));
spr.setTexture(ground);*/
// on fait tourner le programme jusqu'à ce que la fenêtre soit fermée
while (window.isOpen())
{
// on inspecte tous les évènements de la fenêtre qui ont été émis depuis la précédente itération
sf::Event event;
while (window.pollEvent(event))
{
// évènement "fermeture demandée" : on ferme la fenêtre
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(planet);
//window.draw(spr);
window.display();
}
return 0;
}
Any ideas, remarks,
insults ?
Edit and Note : I've tried many different things such as add a planet.setTextureRect(), but nothing makes it
[attachment deleted by admin]