SDL_SetRenderDrawColorFloat(3)

πŸ’– SDL_SetRenderDrawColorFloat(3) πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS section of the manual, and today's main character is SDL_SetRenderDrawColorFloat β€” she's the one who picks the color for all your drawing ops. Rect, Line, Clear? Yeah, all of them. She runs the vibe check on your palette. 🎨✨


✨ NAME ✨

SDL_SetRenderDrawColorFloat β€” set the color used for drawing operations (Rect, Line and Clear). slay.


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_render.h>

bool SDL_SetRenderDrawColorFloat(SDL_Renderer *renderer, float r, float g, float b, float a);

πŸ¦‹ DESCRIPTION πŸ¦‹

So like. This is the function that sets the color for drawing or filling rectangles, lines, and points β€” and also for SDL_RenderClear(). literally the entire aesthetic of your frame, no big deal. 🫢

If you want your rects to be a certain color, this is where you manifest it. Obsessed with her, honestly.


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • renderer β€” the rendering context. it's giving "the whole world we're painting on" energy πŸ’…
  • r β€” the red value used to draw on the rendering target. red!! πŸ“
  • g β€” the green value used to draw on the rendering target. green!! 🌿
  • b β€” the blue value used to draw on the rendering target. blue!! πŸ¦‹
  • a β€” the alpha value used to draw on the rendering target. use SDL_SetRenderDrawBlendMode to specify how the alpha channel is used β€” like, alpha does NOT just do its own thing, you have to tell it what the blend situation is. periodt. 🫧

🌈 RETURN VALUE 🌈

Returns true on success or false on failure. and if it fails?? call SDL_GetError() for more information, bestie β€” she will tell you what went wrong. 😭


πŸ”₯ THREAD SAFETY πŸ”₯

This function should only be called on the main thread. main character energy only, no side quests on other threads. πŸ‘‘


⭐ AVAILABILITY ⭐

This function is available since SDL 3.2.0. so if you're on something older... girl, upgrade. πŸ™ˆ


πŸ’œ SEE ALSO πŸ’œ


and that's the whole page, no cap β€” she ate and left zero crumbs. go forth and color your rectangles. πŸ’…βœ¨

this has been a Simple Directmedia Layer production, brought to you by SDL 3.4.18 β€” mwah, ilysm, go make something pretty πŸŽ€πŸ¦‹πŸ’–

πŸ“¦ where this page comes from