Textures & surfacesSDL 3.2

SDL_RenderTextureRotated

Like SDL_RenderTexture, plus rotation around a point and horizontal/vertical mirroring.

Signature

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);

How it works

The angle is in DEGREES, clockwise on screen (because y points down). The center is relative to dstrect's top-left corner; NULL rotates around the middle of dstrect.

Flipping is how one sprite facing right also walks left: draw it with SDL_FLIP_HORIZONTAL.

Parameters

rendererSDL_Renderer *

The renderer.

textureSDL_Texture *

The texture to draw.

srcrectconst SDL_FRect *

Part of the texture, or NULL.

dstrectconst SDL_FRect *

Where to draw, or NULL.

angledouble

Rotation in degrees, clockwise.

centerconst SDL_FPoint *

Pivot relative to dstrect, or NULL for its center.

flipSDL_FlipMode

Mirroring.

Common values

SDL_FLIP_NONE
As is.
SDL_FLIP_HORIZONTAL
Mirror left-right.
SDL_FLIP_VERTICAL
Mirror top-bottom.

Return value

true on success, false on failure.

Example

example.cpp
1double degrees = ship.angleRadians * 180.0 / SDL_PI_D;
2SDL_RenderTextureRotated(renderer, shipTex, nullptr, &ship.rect, degrees, nullptr,
3                         ship.facingLeft ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE);
Official SDL wiki