SDL_RenderTexture(3)

πŸ’– SDL_RenderTexture πŸ’–

okay so bestie, welcome to the SDL3 FUNCTIONS corner of the manual, and today's main character is SDL_RenderTexture(3). she copies a lil slice of a texture onto whatever your renderer is currently drawing to, and she does it at subpixel precision β€” yes, subpixel, she's fancy like that. ✨


🌸 NAME 🌸

SDL_RenderTexture β€” copy a portion of the texture to the current rendering target at subpixel precision. no cap, that's literally her whole job and she eats every time. πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <SDL3/SDL_render.h>

bool SDL_RenderTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, const SDL_FRect *dstrect);

πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • renderer β€” the renderer that's gonna be doing the copying, i.e. the one who should copy parts of a texture. she's the stage, the texture is the performer. πŸ‘‘
  • texture β€” the source texture. the OG. the one getting snipped. πŸ–ΌοΈ
  • srcrect β€” a pointer to the source rectangle, or NULL for the entire texture. like, do you want a lil piece or the whole thing? your call, bestie. βœ‚οΈ
  • dstrect β€” a pointer to the destination rectangle, or NULL for the entire rendering target. this is where it lands. NULL means she's taking up the whole target, main character energy fr fr. 🌈

⭐ RETURN VALUE ⭐

Returns true on success or false on failure β€” and if it's a false, don't just sit there guessing, call SDL_GetError() for more information. she'll tell you what went wrong, i promise. 😭


πŸ’€ THREAD SAFETY πŸ’€

This function should only be called on the main thread. do not, and i mean do not, try to be cute and call her from 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… yeah, that's a vibe check you're failing, babe. πŸ’œ


πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole page, bestie!! 🫢 this lil masterpiece comes to you courtesy of Simple Directmedia Layer, version SDL 3.4.18 β€” obsessed with her, honestly. go forth and render, and remember: false means check SDL_GetError(). mwah. πŸ’–πŸŽ€πŸŒΈ

πŸ“¦ where this page comes from