SDL_RenderTextureRotated(3)

✨ SDL_RenderTextureRotated ✨

okay bestie, gather round, because this is the SDL3 FUNCTIONS girlie you've been waiting for: SDL_RenderTextureRotated(3). she copies a chunk of your source texture onto the current rendering target β€” but with rotation and flipping, and at subpixel precision no less. she's giving main character energy fr fr. πŸ’…


πŸ¦‹ NAME πŸ¦‹

SDL_RenderTextureRotated β€” copy a portion of the source texture to the current rendering target, with rotation and flipping, at subpixel precision. no cap, that's literally the whole job and she ate. πŸ’–


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_render.h>

bool SDL_RenderTextureRotated(SDL_Renderer *renderer, SDL_Texture *texture,
                         const SDL_FRect *srcrect, const SDL_FRect *dstrect,
                         double angle, const SDL_FPoint *center,
                         SDL_FlipMode flip);

πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • renderer β€” the renderer which should copy parts of a texture. she's the one doing the actual work, the backbone, the moment. πŸ‘‘
  • texture β€” the source texture. the thing you're copying from. your origin story. ✨
  • srcrect β€” a pointer to the source rectangle, or NULL for the entire texture. like, all of it, every last pixel, no crumbs left behind. πŸ“
  • dstrect β€” a pointer to the destination rectangle, or NULL for the entire rendering target. same energy: give her nothing and she'll take up the whole canvas. 🌈
  • angle β€” an angle in degrees that indicates the rotation that will be applied to dstrect, rotating it in a clockwise direction. clockwise bestie, not counter, iykyk. πŸ•
  • center β€” a pointer to a point indicating the point around which dstrect will be rotated. and listen: if it's NULL, rotation will be done around dstrect.w/2, dstrect.h/2. so the pivot defaults to the middle of your destination rect. cute. 🎯
  • flip β€” an SDL_FlipMode value stating which flipping actions should be performed on the texture. mirror mirror on the wall πŸͺž

πŸ’– RETURN VALUE πŸ’–

Returns true on success or false on failure. and if it fails? don't just sit there spiraling β€” call SDL_GetError() for more information. she will tell you what went wrong, bestie, communication is key. 😭


πŸ”₯ THREAD SAFETY πŸ”₯

This function should only be called on the main thread. periodt. do not try to be sneaky on a worker thread, she is not about that life. πŸ’€


πŸ‘‘ AVAILABILITY πŸ‘‘

This function is available since SDL 3.2.0. so if you're on something older, that's a vibe check you're failing, upgrade babes. 🫢


🧚 SEE ALSO 🧚

  • SDL_RenderTexture(3) β€” the no-rotation, no-flip sibling. still iconic, just less dramatic. πŸ’œ

lowkey reminder: srcrect and dstrect can be NULL, center can be NULL, but your main-thread energy can never be NULL. slay responsibly. πŸ’…

and that's the whole page, bestie!! brought to you by the fine folks at Simple Directmedia Layer, from the SDL 3.4.18 era, and filed under the very official manual name SDL_RenderTextureRotated(3). mwah, go rotate something gorgeous. πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from