SDL_SetRenderDrawColor(3)
π SDL_SetRenderDrawColor π
okay bestie, welcome to the SDL3 FUNCTIONS section of the manual, and we're diving straight into SDL_SetRenderDrawColor(3) β the girl whose whole job is picking the color your renderer draws with. she's iconic, she's simple, she's literally just a color setter. let's go π¨β¨
πΈ NAME πΈ
SDL_SetRenderDrawColor β Set the color used for drawing operations.
π¦ SYNOPSIS π¦
#include <SDL3/SDL_render.h>
bool SDL_SetRenderDrawColor(SDL_Renderer *renderer, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
β¨ DESCRIPTION β¨
so what does she actually do? she sets the color for drawing or filling rectangles, lines, and points β and also for SDL_RenderClear(). that's it. that's the vibe. one function, one job, ate π
think of it as telling your renderer "bestie, THIS is the color we're working with now" and everything you draw after that follows along. main character energy fr fr.
π FUNCTION PARAMETERS π
rendererβ the rendering context. yep, the whole rendering situation you're working with πΌοΈrβ the red value used to draw on the rendering target. π΄gβ the green value used to draw on the rendering target. π’bβ the blue value used to draw on the rendering target. π΅aβ the alpha value used to draw on the rendering target; usuallySDL_ALPHA_OPAQUE(255). and heads up: useSDL_SetRenderDrawBlendModeto specify how the alpha channel is used. lowkey important, don't skip her π
π RETURN VALUE π
returns true on success or false on failure β and if it's giving failure, call SDL_GetError() for more information. she will tell you what went wrong, you just gotta ask π«Ά
π§ THREAD SAFETY π§
okay so this one matters: this function should only be called on the main thread. no cap. don't be out here calling her from a side thread and expecting peace π
β AVAILABILITY β
This function is available since SDL 3.2.0. if you're on anything older, she's not there yet bestie π
π SEE ALSO π
and that's the whole page, gorgeous πΈ thank you for reading, mwah π
this has been Simple Directmedia Layer, SDL 3.4.18, page SDL_SetRenderDrawColor(3) β go set some colors and slay β¨ππ¦
π¦ 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