SDL_SetTextureColorModFloat(3)

πŸ’– SDL_SetTextureColorModFloat(3) πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, this one's called SDL_SetTextureColorModFloat and it's literally the tint-your-texture button but make it ✨float✨


🌸 NAME 🌸

SDL_SetTextureColorModFloat β€” sets an extra color value that gets multiplied into render copy operations 🎨


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <SDL3/SDL_render.h>

bool SDL_SetTextureColorModFloat(SDL_Texture *texture, float r, float g, float b);

✨ DESCRIPTION ✨

so when this texture gets rendered, during the copy operation every source color channel gets modulated by the matching color value, using this formula right here:

srcC = srcC * color

that's it, that's the whole vibe. 🫢

heads up bestie: color modulation is not always supported by the renderer β€” if it isn't, this function returns false. no cap, no tint. 😭

πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • texture β€” the texture to update, obviously, it's the main character here πŸ‘‘
  • r β€” the red color value multiplied into copy operations πŸ“
  • g β€” the green color value multiplied into copy operations 🌈
  • b β€” the blue color value 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. πŸ”


🧚 THREAD SAFETY 🧚

this function should only be called on the main thread. no side quests, no background threads, main character energy only. periodt. πŸ’€


⭐ AVAILABILITY ⭐

this function is available since SDL 3.2.0 β€” so if you're on anything older, she is simply not there yet, sorry babe πŸ™ˆ


πŸ‘‘ SEE ALSO πŸ‘‘

go read those too, they're all part of the same little color-modulation friend group 🫢


and that's the whole page!! brought to you by Simple Directmedia Layer, version SDL 3.4.18 β€” mwah, go tint something cute, ily, bye πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from