SDL_SetTextureAlphaMod(3)

✨ SDL_SetTextureAlphaMod ✨

okay bestie, welcome to the SDL3 corner of the manual β€” this is the page for SDL_SetTextureAlphaMod(3) and it's giving transparency slay πŸ’…


🌸 NAME 🌸

SDL_SetTextureAlphaMod</purpose> β€” set an extra alpha value that gets multiplied into render copy operations 🫢


πŸŽ€ SYNOPSIS πŸŽ€

#include <SDL3/SDL_render.h>

bool SDL_SetTextureAlphaMod(SDL_Texture *texture, Uint8 alpha);

like, that's the whole vibe. one texture, one alpha, one bool. iconic.


πŸ’– 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, using this exact formula:

srcA = srcA * (alpha / 255)

so yeah, it's a multiplier. your texture's own alpha times this alpha over 255. math but make it ✨fashion✨

⚠️ real talk though: alpha modulation is not always supported by the renderer. if it's not supported, this function will return false. no cap.

πŸ¦‹ FUNCTION PARAMETERS πŸ¦‹

  • texture β€” the texture you're updating, bestie. the glow-up target πŸ’–
  • 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, go call SDL_GetError() for the deets, she'll tell you what went wrong.


🧚 THREAD SAFETY 🧚

🚨 main thread ONLY, bestie. this function should only be called on the main thread. do not be out here threading this. i'm serious. πŸ’€

🌈 AVAILABILITY 🌈

this function is available since SDL 3.2.0 πŸ‘‘ so if you're on something older... upgrade, babe.


πŸ’œ SEE ALSO πŸ’œ

go read those next, iykyk πŸ“


and that's the page!! mwah πŸ’‹ this whole thing lives in Simple Directmedia Layer, SDL 3.4.18, dated SDL_SetTextureAlphaMod(3) β€” k bye, go modulate some alpha, you absolute main character πŸ«Άβœ¨πŸŽ€

πŸ“¦ where this page comes from