SDL_SetSurfaceColorMod(3)

✨ SDL_SetSurfaceColorMod ✨

okay bestie, so like... you know how when you blit a surface you can tint it? this is that function. it's a SDL3 FUNCTIONS girlie, header file SDL3/SDL_surface.h, and she's here to let you multiply a color into every blit. no cap. πŸ’…


🌸 NAME 🌸

SDL_SetSurfaceColorMod β€” set an additional color value multiplied into blit operations. literally that's it, that's the whole vibe πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <SDL3/SDL_surface.h>

bool SDL_SetSurfaceColorMod(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b);

πŸ’– DESCRIPTION πŸ’–

so the tea is: when this surface gets blitted, during the blit operation each source color channel is modulated by the appropriate color value β€” and the formula is giving:

srcC = srcC * (color / 255)

that's it. that's the math. iconic behavior fr fr 🌈


🫢 FUNCTION PARAMETERS 🫢

  • surface β€” the SDL_Surface structure to update. the main character, the one we're touching πŸ’œ
  • r β€” the red color value multiplied into blit operations.
  • g β€” the green color value multiplied into blit operations.
  • b β€” the blue color value multiplied into blit operations.

πŸ‘‘ RETURN VALUE πŸ‘‘

Returns true on success or false on failure; call SDL_GetError() for more information. so if it flops, go ask SDL_GetError() what happened, she always knows 😭


🧚 THREAD SAFETY 🧚

This function can be called on different threads with different surfaces. so like, share the load babes, just keep your surfaces separate ✨


⭐ AVAILABILITY ⭐

This function is available since SDL 3.2.0. she's new-ish but she's thriving πŸ’…


πŸ”₯ SEE ALSO πŸ”₯


and that's the whole page bestie πŸŽ€ go modulate some colors, you're gonna eat πŸ’–

this lil writeup is from the Simple Directmedia Layer girlies, version SDL 3.4.18, dated SDL_SetSurfaceColorMod(3) β€” mwah, love u, bye πŸ¦‹

πŸ“¦ where this page comes from