SDL_FillSurfaceRect(3)

πŸ’– SDL_FillSurfaceRect(3) πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS corner of the man pages, where today's main character is SDL_FillSurfaceRect 🎨✨


🌈 NAME 🌈

SDL_FillSurfaceRect β€” the way to do a fast fill of a rectangle with one specific color. no cap, that's literally the whole job 🫢


✨ SYNOPSIS ✨

#include <SDL3/SDL_surface.h>

bool SDL_FillSurfaceRect(SDL_Surface *dst, const SDL_Rect *rect, Uint32 color);

πŸŽ€ DESCRIPTION πŸŽ€

so color has to be a pixel in the format that the surface is using, okay? like, it's gotta match. you can make one with SDL_MapRGB() or SDL_MapRGBA() and that's the move πŸ’…

and here's the tea: if that color value has an alpha component in it, the destination just gets straight-up filled with that alpha info. no blending happens. none. zero. it's giving "we're not mixing, we're replacing" 😌

also!! if there's a clip rectangle set on the destination (you'd set that with SDL_SetSurfaceClipRect()), then this function fills based on the intersection of the clip rectangle and rect. so it's not just rect on its own β€” it's where rect and the clip overlap 🌸


πŸ¦‹ FUNCTION PARAMETERS πŸ¦‹

  • dst β€” the SDL_Surface structure that is the drawing target. this is the canvas you're painting on 🎨
  • rect β€” the SDL_Rect structure representing the rectangle to fill, or NULL to fill the entire surface. yep, NULL = fill everything, one big vibe ✨
  • color β€” the color to fill with πŸ“

πŸ’œ RETURN VALUE πŸ’œ

returns true on success or false on failure. and if it fails? call SDL_GetError() for more information, bestie, don't just sit there guessing 😭


🧚 THREAD SAFETY 🧚

this function can be called on different threads with different surfaces. so like, parallel vibes are fine β€” just keep the surfaces separate, iykyk πŸ”₯


πŸ‘‘ AVAILABILITY πŸ‘‘

this function is available since SDL 3.2.0. periodt πŸ’…


🌟 SEE ALSO 🌟


ok that's the whole page, you ate that 🫢 go fill some rectangles, they're waiting πŸ’–

Simple Directmedia Layer β€” that's who brought you this, version SDL 3.4.18, and the page itself is SDL_FillSurfaceRect(3). mwah, bye bestie, slay responsibly βœ¨πŸŽ€πŸ’…

πŸ“¦ where this page comes from