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

Author Topic: RectangleShape vs Sprite?  (Read 10725 times)

0 Members and 1 Guest are viewing this topic.

Yelnats

  • Newbie
  • *
  • Posts: 27
    • View Profile
RectangleShape vs Sprite?
« on: April 27, 2012, 05:55:59 am »
I have used Sprites as my goto for drawing things for a while now, but haven't updated SFML much. Since the release candidate things like textures got added, and it got me thinking about what would be better to use; rectangleshapes or sprites? Are there any performance differences?

And another quick question, is there a way to get the point positions of a rotated rectangleshape? Global positions, so I don't have to calculate them manually but just get them based on how much the shape is rotated. I'm sure there's a way, or else how else are the points stored?
« Last Edit: April 27, 2012, 06:04:21 am by Yelnats »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: RectangleShape vs Sprite?
« Reply #1 on: April 27, 2012, 08:08:23 am »
Quote
what would be better to use
If sf::Sprite was not better than sf::RectangleShape at what it does, it wouldn't exist ;)

Quote
is there a way to get the point positions of a rotated rectangleshape
sf::Vector2f p = shape.getTransform().transformPoint(shape.getPoint(i));
Laurent Gomila - SFML developer

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10936
    • View Profile
    • development blog
    • Email
Re: RectangleShape vs Sprite?
« Reply #2 on: April 27, 2012, 01:12:18 pm »
If sf::Sprite was not better than sf::RectangleShape at what it does, it wouldn't exist ;)

A few month back I've asked the same question and Laurent's answer was a bit more detailed:
Quote
If you want a textured quad, sf::Sprite is better, since that's exactly what it's made for.

A textured quad with sf::Shape would just be a special case of something more generic, and thus less optimized.

But with the new API, both are just high-level helpers on top of vertex arrays anyway. So If you really really want maximum performances, use vertex arrays directly.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Yelnats

  • Newbie
  • *
  • Posts: 27
    • View Profile
Re: RectangleShape vs Sprite?
« Reply #3 on: April 27, 2012, 05:49:24 pm »
Ah, I see. I think I'll switch them to sprites now then.

 

anything