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; usually SDL_ALPHA_OPAQUE (255). and heads up: use SDL_SetRenderDrawBlendMode to 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