Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Why is there no TriangleShape?  (Read 11550 times)

0 Members and 1 Guest are viewing this topic.

Allptraum

  • Newbie
  • *
  • Posts: 7
    • View Profile
Why is there no TriangleShape?
« 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?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Why is there no TriangleShape?
« Reply #1 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.
Laurent Gomila - SFML developer

Allptraum

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Why is there no TriangleShape?
« Reply #2 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...

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10815
    • View Profile
    • development blog
    • Email
Re: Why is there no TriangleShape?
« Reply #3 on: December 09, 2020, 01:28:42 pm »
As Laurent said, for such situations you can directly use a sf::VertexArray :)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Hapax

  • Hero Member
  • *****
  • Posts: 3351
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Why is there no TriangleShape?
« Reply #4 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.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*