SDL_FillSurfaceRects(3)

✨ SDL_FillSurfaceRects β€” the SDL3 FUNCTIONS era ✨

okay bestie, sit down, hydrate, because we're about to talk about SDL_FillSurfaceRects(3) β€” yes, the plural one, the one that eats a whole ARRAY of rectangles for breakfast πŸ’…


πŸŽ€ NAME πŸŽ€

SDL_FillSurfaceRects β€” do a fast fill of a whole set of rectangles with one specific color. like, one color, many rects, zero drama. periodt.


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_surface.h>

bool SDL_FillSurfaceRects(SDL_Surface *dst, const SDL_Rect *rects, int count, Uint32 color);

look at her. four arguments. so clean. so iconic. 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

so color has to be a pixel in the format that the surface actually uses, okay? don't just make up numbers. you can generate it with SDL_MapRGB() or SDL_MapRGBA() β€” those are your besties for this. ✨

and here's the tea πŸ“: if that color value has an alpha component in it, then the destination is simply filled with that alpha information. no blending takes place. like, none. zero. the alpha just gets written straight in. not a vibe check, just a fact.

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 gonna go wild outside your clip zone. it knows its boundaries. main character with manners. πŸ‘‘


πŸ’– FUNCTION PARAMETERS πŸ’–

  • dst β€” the SDL_Surface structure that is the drawing target. this is where the paint goes, bestie.
  • rects β€” an array of SDL_Rects representing the rectangles to fill. yes, an array. plural energy. πŸ”₯
  • count β€” the number of rectangles in the array. don't lie to her, she counts. πŸ’€
  • color β€” the color to fill with. the whole point, honestly.

⭐ RETURN VALUE ⭐

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


🌈 THREAD SAFETY 🌈

this function can be called on different threads with different surfaces. so yes, you can parallelize β€” just keep each surface to its own thread, iykyk. 🧚


πŸ‘‘ AVAILABILITY πŸ‘‘

this function is available since SDL 3.2.0. if you're on something older, no she's not there yet. sorry bestie. πŸ’œ


πŸŽ€ SEE ALSO πŸŽ€

  • SDL_FillSurfaceRect(3) β€” the singular version, for when you only have one rect and you're being lowkey about it.

ok that's the whole page, go fill some rectangles, you're gonna slay 🫢✨

Simple Directmedia Layer πŸ’– SDL 3.4.18 β€” mwah, sending you and your surfaces all the love, catch you in the next manpage bestie! πŸŒΈπŸŽ€πŸ¦‹

πŸ“¦ where this page comes from