SDL_RenderClear(3)

✨ SDL_RenderClear(3) ✨

okay so bestie, we're diving into the SDL3 FUNCTIONS section of the manual and this one is genuinely so useful it's giving main character energy πŸ’… it's called SDL_RenderClear and yes, we're gonna clear the whole entire rendering target with the drawing color. slay.


🌸 NAME 🌸

SDL_RenderClear β€” clear the current rendering target with the drawing color. that's it, that's the vibe πŸ’–


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <SDL3/SDL_render.h>

bool SDL_RenderClear(SDL_Renderer *renderer);

πŸ’œ DESCRIPTION πŸ’œ

so what does it actually do? it clears the entire rendering target, no cap. and when I say entire, I mean it literally ignores the viewport and the clip rectangle β€” those boundaries? not invited to this party πŸ™ˆ the whole target gets wiped, periodt.

⚠️ also important, bestie: clearing will set/fill all the pixels of the rendering target to the current renderer draw color. so make sure you invoke SDL_SetRenderDrawColor() when needed, otherwise you're gonna be out here clearing into whatever color was already set and being confused. we've all been there. it's giving tragic. don't do that to yourself πŸŽ€

πŸ“ FUNCTION PARAMETERS πŸ“

  • renderer β€” the rendering context. that's your renderer bestie, the one you already made. hand it over πŸ’–

⭐ RETURN VALUE ⭐

returns true on success or false on failure. and if it fails?? call SDL_GetError() for more info β€” she will tell you what went wrong, i promise 🫢


πŸ”₯ THREAD SAFETY πŸ”₯

this function should only be called on the main thread. yes, only. no side-quest threads on this one, bestie. main character thread only, no exceptions πŸ‘‘

🌈 AVAILABILITY 🌈

this function is available since SDL 3.2.0. iconic. historic. we love to see it ✨


🧚 SEE ALSO 🧚


and that's the whole page bestie, you ate that πŸ’– this little manual moment comes to you from Simple Directmedia Layer (the SDL girlies 🫢), SDL 3.4.18, filed under SDL_RenderClear(3). go forth and clear your render target, i'm obsessed with you πŸ’œπŸŽ€

πŸ“¦ where this page comes from