SDL_SetTextureColorMod(3)

πŸ’– SDL_SetTextureColorMod πŸ’–

okay bestie, so this is a page from the SDL3 FUNCTIONS manual β€” the whole thing lives in SDL_SetTextureColorMod(3) β€” and it's literally the cutest little function for tinting your textures. let's get into it πŸŽ€


✨ NAME ✨

SDL_SetTextureColorMod β€” slap an extra color value on there that gets multiplied into render copy operations. it's giving tint, it's giving glow-up πŸ’…


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_render.h>

bool SDL_SetTextureColorMod(SDL_Texture *texture, Uint8 r, Uint8 g, Uint8 b);

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea πŸ“: when this texture gets rendered, during the copy operation each source color channel gets modulated by the matching color value. the formula is right here, no cap:

srcC = srcC * (color / 255)

and the reddest flag of them all 🚩: color modulation is not always supported by the renderer. if it's not supported, this function will return false. periodt.


πŸ‘‘ FUNCTION PARAMETERS πŸ‘‘

  • texture β€” the texture you're updating, bestie. the main character of this whole operation.
  • r β€” the red color value that gets multiplied into copy operations.
  • g β€” the green color value that gets multiplied into copy operations.
  • b β€” the blue color value that gets multiplied into copy operations.

⭐ RETURN VALUE ⭐

returns true on success or false on failure 🫢 and if it fails, call SDL_GetError() for more info β€” she'll tell you what went wrong, iykyk.


🧚 THREAD SAFETY 🧚

lowkey important: this function should only be called on the main thread. no sneaky side-thread shenanigans πŸ™ˆ

🌈 AVAILABILITY 🌈

this function is available since SDL 3.2.0. iconic behavior honestly.


πŸ’œ SEE ALSO πŸ’œ


okay that's the whole page, bestie!! stay hydrated, modulate responsibly, and remember β€” this was brought to you by Simple Directmedia Layer ✨ version SDL 3.4.18 ✨ the SDL_SetTextureColorMod(3) page itself. mwah, love u, bye πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from