SDL_SetTextureAlphaModFloat(3)

πŸ’– SDL_SetTextureAlphaModFloat(3) πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, where we talk about making your textures ✨translucent✨. This one's called SDL_SetTextureAlphaModFloat, and it's giving main character energy for real.


✨ NAME ✨

SDL_SetTextureAlphaModFloat β€” set an extra alpha value that gets multiplied into render copy operations. slay


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <SDL3/SDL_render.h>

bool SDL_SetTextureAlphaModFloat(SDL_Texture *texture, float alpha);

🌸 DESCRIPTION 🌸

so here's the tea: when this texture gets rendered, during the copy operation the source alpha value gets modulated by this alpha value. The formula is literally this, no cap:

srcA = srcA * alpha

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

lowkey important: alpha modulation is not always supported by the renderer. if it's not supported, this function will return false. so like, check your returns, bestie. πŸ’…

πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • texture β€” the texture you're updating. the one getting the glow-up.
  • alpha β€” the source alpha 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 information, because she will tell you what went wrong. 😭


πŸ”₯ THREAD SAFETY πŸ”₯

This function should only be called on the main thread. no side-quests, no background threads, just main character behavior. periodt.


🌈 AVAILABILITY 🌈

This function is available since SDL 3.2.0. so if you're on something older, it's not me, it's you. πŸ™ˆ


πŸ‘‘ SEE ALSO πŸ‘‘


Simple Directmedia Layer πŸ’– SDL 3.4.18 β€” mwah, that's the whole page, SDL_SetTextureAlphaModFloat(3) out. go forth and modulate those alphas, bestie 🧚✨

πŸ“¦ where this page comes from