SFML community forums

Help => Graphics => Topic started by: Yelnats on April 27, 2012, 05:55:59 am

Title: RectangleShape vs Sprite?
Post by: Yelnats 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?
Title: Re: RectangleShape vs Sprite?
Post by: Laurent 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));
Title: Re: RectangleShape vs Sprite?
Post by: eXpl0it3r 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  (http://en.sfml-dev.org/forums/index.php?topic=6677.msg43914#msg43914)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.
Title: Re: RectangleShape vs Sprite?
Post by: Yelnats on April 27, 2012, 05:49:24 pm
Ah, I see. I think I'll switch them to sprites now then.