SFML community forums
Help => Graphics => Topic started by: Imbue on May 16, 2009, 01:35:29 am
-
I'm using a packed texture to hold my sprites, and some sprites are rotated.
Is there anyway to set the SubRect of the sprite so it reads in the rotated image correctly? I thought I could just reverse the top and bottom of the sub rect to make it work, but it seems to have no effect.
I know I can load the rotated image and then rotate the sprite, but then I'd have to keep adding 90 to any SetRotations I do later; it'd be a messy solution.
Thanks.
-
Why not rotating the picture whit photoshop/... ?
-
I'm packing several images into one texture for better performance. Currently I'm not rotating them, but if I rotate some of them in this packed texture I can fit more in each texture.
-
The resource manager that I created for my framework uses loading images from byte arrays. As a bonus I can decrypt encrypted images and place the bytes of the whole atlas or its parts in memory in any order I wish while loading them from the resource storage. Maybe this is a possible way for you to go? The drawback here is two-stage image processing (load to memory and convert-decrypt if necessary, and then get them on demand) instead of direct loading from a file.
-
This is more like a hack, but:
You could make a class that inherits from sf::Sprite and do a fixup on angle or flip, based on the rotation you define for the image.
If you rewrite FlipX/Y and SetRotation you could add this functionality easily.
Not the best solution but it could work.
Something like:
HackSprite::SetImageRotation(float rot) { ImgRot=rot; }
HackSprite::SetRotation(float rot) { Sprite::SetRotation(rot-ImgRot); }
Regards
-MartÃn
-
I'll probably just modify or subclass sf::Sprite. A rotated sub-rect is just a small change in the texture coordinates in the Render function. That's how FlipX and FlipY work.
It would be nice if SFML supported this. I know a lot of texture atlases support rotating sprites to save space.
Thanks.