SFML community forums

General => Feature requests => Topic started by: Allptraum on December 09, 2020, 10:20:45 am

Title: Why is there no TriangleShape?
Post by: Allptraum on December 09, 2020, 10:20:45 am
Sure, you could just use a ConvexShape, but by this logic we wouldn't need RectangleShape either...

Would there be any interest in this feature?
Title: Re: Why is there no TriangleShape?
Post by: Laurent on December 09, 2020, 10:49:58 am
Why no hexagon, pentagon, octagon, ...? There has to be a limit ;)

And, as highlighted in the tutorial, regular polygons can be obtained easily with sf::CircleShape:
https://www.sfml-dev.org/tutorials/2.5/graphics-shape.php#built-in-shape-types

Not that triangles can also be constructed with a sf::VertexArray of type "Triangles". This is lower level and will offer better performances.
Title: Re: Why is there no TriangleShape?
Post by: Allptraum on December 09, 2020, 12:15:05 pm
Why no hexagon, pentagon, octagon, ...? There has to be a limit ;)

And, as highlighted in the tutorial, regular polygons can be obtained easily with sf::CircleShape:
https://www.sfml-dev.org/tutorials/2.5/graphics-shape.php#built-in-shape-types

Not that triangles can also be constructed with a sf::VertexArray of type "Triangles". This is lower level and will offer better performances.

For equilateral triangles, yes. But not if you want a triangle to cover three specific points. But this might actually be too much of a nieche shape to have it's own class.

Maybe something for some kind of extension...
Title: Re: Why is there no TriangleShape?
Post by: eXpl0it3r on December 09, 2020, 01:28:42 pm
As Laurent said, for such situations you can directly use a sf::VertexArray :)
Title: Re: Why is there no TriangleShape?
Post by: Hapax on December 09, 2020, 06:24:16 pm
It's also worth noting that the provided shapes are quite strictly bound by a 2D rectangular area and can only be in one form within it. Triangles can be in many forms within that rectangular area.