SDL_UpdateWindowSurfaceRects(3)

πŸ’– SDL_UpdateWindowSurfaceRects(3) πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, where we're talking about SDL_UpdateWindowSurfaceRects β€” the lil glow-up function that copies areas of the window surface to the screen. no cap. ✨


🌸 NAME 🌸

SDL_UpdateWindowSurfaceRects β€” copy areas of the window surface to the screen. it's giving "tell the screen what changed, but only the bits you care about." πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <SDL3/SDL_video.h>

bool SDL_UpdateWindowSurfaceRects(SDL_Window *window, const SDL_Rect *rects, int numrects);

✨ DESCRIPTION ✨

so like, this is the function you reach for when you've changed portions of the surface and you want those changes to actually show up on the screen. that's the whole vibe. πŸ’…

fun fact: this function is equivalent to the SDL 1.2 API SDL_UpdateRects(). the legacy icon. πŸ‘‘

⚠️ okay important thing, no skipping: this function will update _at least_ the rectangles you specify. but pls pls pls understand that's only intended as an optimization β€” in practice it might update more of the screen (or literally all of the screen!! 😭) depending on what method SDL uses to send pixels to the system. so it's a "at least" situation, never a "exactly this much" situation. iykyk.

πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • window β€” the window to update. that's your main character. πŸͺŸ
  • rects β€” an array of SDL_Rect structures representing areas of the surface to copy, in pixels. yes bestie, in pixels, don't forget. πŸ“
  • numrects β€” the number of rectangles. count 'em. πŸ”’

🌈 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, fr fr. πŸ™ˆ


🧚 THREAD SAFETY 🧚

this function should only be called on the main thread. do not try to be cute and call it from a side thread, it's not that girl. 🚫🧡


⭐ AVAILABILITY ⭐

this function is available since SDL 3.2.0. so if you're on something older... it's giving nothing, sorry. πŸ’€


🫢 SEE ALSO 🫢

go read those too, they're iconic in their own right. πŸ”₯


Simple Directmedia Layer β€” SDL 3.4.18 πŸ¦‹ that's the source and the version, and this page was dated alongside SDL_UpdateWindowSurfaceRects(3). mwah, love u, go update some rects responsibly πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from