SDL_ClearSurface(3)

✨ SDL_ClearSurface β€” bestie edition πŸ’…

okay so this is SDL_ClearSurface(3), a lil function from the SDL3 FUNCTIONS gang, and it's here to wipe a surface clean with a color β€” but like, with floating point precision. fancy. we love that for us. πŸŽ€


🌸 NAME 🌸

SDL_ClearSurface β€” Clear a surface with a specific color, with floating point precision.


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <SDL3/SDL_surface.h>

bool SDL_ClearSurface(SDL_Surface *surface, float r, float g, float b, float a);

πŸ’– DESCRIPTION πŸ’–

so here's the tea, bestie: this function handles all surface formats. every single one. it does not care. it's giving main character energy that way. ✨

it also ignores any clip rectangle. like, the clip rect is literally not invited to this party. set it, don't set it, doesn't matter β€” this function is not looking at it. πŸ™ˆ

if the surface is YUV, the color is assumed to be in the sRGB colorspace. otherwise (not YUV, just vibing), the color is assumed to be in the colorspace of the surface itself. no cap. 🫢


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • surface β€” the SDL_Surface to clear. this is the one getting the glow-up. πŸ‘‘
  • r β€” the red component of the pixel, normally in the range 0-1. yes, 0-1, not 0-255. it's float o'clock. πŸ“
  • g β€” the green component of the pixel, normally in the range 0-1. πŸ’š
  • b β€” the blue component of the pixel, normally in the range 0-1. πŸ’™
  • a β€” the alpha component of the pixel, normally in the range 0-1. translucency era. 🌫️

⭐ RETURN VALUE ⭐

Returns true on success or false on failure. if it fails, call SDL_GetError() for more information β€” that's your little gossip source telling you what went wrong. 😭


πŸ”₯ THREAD SAFETY πŸ”₯

This function can be called on different threads with different surfaces. so like, multitask, queen. just keep the surfaces separate, okay? different surface per thread, no fighting. πŸ’…


🌈 AVAILABILITY 🌈

This function is available since SDL 3.2.0. so if you're on something older... bestie, upgrade. πŸ¦‹


and that's the whole page, periodt. brought to you by Simple Directmedia Layer, SDL 3.4.18, dated SDL_ClearSurface(3). go clear something gorgeous. πŸ’œπŸŽ€βœ¨

πŸ“¦ where this page comes from