SDL_RotateSurface(3)
π« SDL_RotateSurface(3) β the SDL3 FUNCTIONS glow-up
okay bestie, welcome to the SDL_RotateSurface page, part of the SDL3 FUNCTIONS lineup π
β¨ NAME β¨
SDL_RotateSurface β hands you back a copy of a surface, rotated clockwise by some number of degrees. yes, a copy. we don't touch the original, we're not monsters π
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_surface.h>
SDL_Surface * SDL_RotateSurface(SDL_Surface *surface, float angle);
π¦ DESCRIPTION π¦
okay so the rotation angle? it can be negative and that's not a bug, that's on purpose β negative = counter-clockwise. we love options π
When the rotation isn't a multiple of 90 degrees, the resulting surface is bigger than the original. no cap. and the background gets filled in with the colorkey, if there is one available, or with RGBA 255/255/255/0 if there isn't. that's just how she pads π«Ά
now here's the part that's giving β¨spicy mathβ¨: if surface has the SDL_PROP_SURFACE_ROTATION_FLOAT property set on it, the new copy will have the adjusted value set. like β if the rotation property is 90 and angle was 30, the new surface will have a property value of 60. (that is: to be upright vs gravity, this surface needs to rotate 60 more degrees.) love that for her π
β οΈ but bestie, note this: further rotations on the new surface in this example will produce unexpected results, since the image will have resized and padded to accommodate the not-90 degree angle. like, she's changed shape. she's not who she was. π
π FUNCTION PARAMETERS π
surfaceβ the surface to rotate. that's the one getting the glow-up.angleβ the rotation angle, in degrees. yes, degrees. not radians. we keep it simple here π
π RETURN VALUE π
Returns a rotated copy of the surface π or NULL on failure π β in which case, call SDL_GetError() for more information. she'll tell you what went wrong.
π§ THREAD SAFETY π§
This function can be called on different threads with different surfaces. so like, parallel vibes, no drama, as long as everybody's got their own surface π
β AVAILABILITY β
This function is available since SDL 3.4.0. not that old, but already iconic.
and that's the whole page, bestie π huge thank you to Simple Directmedia Layer for shipping this one in SDL 3.4.18 β go rotate something pretty, you've got this πβ¨
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms