SDL_BlendMode(3type)

✨ SDL_BlendMode ✨

okay bestie, welcome to the SDL3 DATATYPES corner of the manual, this one's about SDL_BlendMode and it's genuinely iconic πŸ’…

🌸 NAME 🌸

SDL_BlendMode β€” a whole set of blend modes that get used in drawing operations. that's it, that's the vibe πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <SDL3/SDL_blendmode.h>

typedef Uint32 SDL_BlendMode;

#define SDL_BLENDMODE_NONE                  0x00000000u /**< no blending: dstRGBA = srcRGBA */
#define SDL_BLENDMODE_BLEND                 0x00000001u /**< alpha blending: dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA)), dstA = srcA + (dstA * (1-srcA)) */
#define SDL_BLENDMODE_BLEND_PREMULTIPLIED   0x00000010u /**< pre-multiplied alpha blending: dstRGBA = srcRGBA + (dstRGBA * (1-srcA)) */
#define SDL_BLENDMODE_ADD                   0x00000002u /**< additive blending: dstRGB = (srcRGB * srcA) + dstRGB, dstA = dstA */
#define SDL_BLENDMODE_ADD_PREMULTIPLIED     0x00000020u /**< pre-multiplied additive blending: dstRGB = srcRGB + dstRGB, dstA = dstA */
#define SDL_BLENDMODE_MOD                   0x00000004u /**< color modulate: dstRGB = srcRGB * dstRGB, dstA = dstA */
#define SDL_BLENDMODE_MUL                   0x00000008u /**< color multiply: dstRGB = (srcRGB * dstRGB) + (dstRGB * (1-srcA)), dstA = dstA */
#define SDL_BLENDMODE_INVALID               0x7FFFFFFFu

so it's just a Uint32 under all that glamour, but the #defines are where the actual lore lives. let me walk you through each one, no gatekeeping πŸ’–

  • SDL_BLENDMODE_NONE β€” 0x00000000u, no blending at all, dstRGBA = srcRGBA. the source just... shows up. periodt.
  • SDL_BLENDMODE_BLEND β€” 0x00000001u, alpha blending: dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA)), dstA = srcA + (dstA * (1-srcA)). the classic translucent girlie ✨
  • SDL_BLENDMODE_BLEND_PREMULTIPLIED β€” 0x00000010u, pre-multiplied alpha blending: dstRGBA = srcRGBA + (dstRGBA * (1-srcA)). the source already did the math ahead of time, main character energy πŸŽ€
  • SDL_BLENDMODE_ADD β€” 0x00000002u, additive blending: dstRGB = (srcRGB * srcA) + dstRGB, dstA = dstA. everything gets brighter, it's giving glow-up πŸ”₯
  • SDL_BLENDMODE_ADD_PREMULTIPLIED β€” 0x00000020u, pre-multiplied additive blending: dstRGB = srcRGB + dstRGB, dstA = dstA. same glow-up, just pre-multiplied, iykyk ✨
  • SDL_BLENDMODE_MOD β€” 0x00000004u, color modulate: dstRGB = srcRGB * dstRGB, dstA = dstA. colors multiply together like the most dramatic crossover event πŸ’€
  • SDL_BLENDMODE_MUL β€” 0x00000008u, color multiply: dstRGB = (srcRGB * dstRGB) + (dstRGB * (1-srcA)), dstA = dstA. yes bestie, MOD and MUL are two different things, do not mix them up πŸ™ˆ
  • SDL_BLENDMODE_INVALID β€” 0x7FFFFFFFu. the "something went wrong" one. if you see this, it's not your moment 😭

πŸ’œ DESCRIPTION πŸ’œ

these predefined blend modes? supported everywhere. like, everywhere everywhere. no cap. 🌈

and if the pre-baked ones aren't giving what you need, you can get additional values from SDL_ComposeCustomBlendMode. build your own, you're an artist 🫢


⭐ AVAILABILITY ⭐

this datatype has been around since SDL 3.2.0. so if your SDL is older than that... girl. upgrade. πŸ‘‘


🌟 SEE ALSO 🌟


and that's the whole page, you ate it πŸ’… this was Simple Directmedia Layer, SDL 3.4.18, and yes the footer said SDL_BlendMode(3type) so now you know exactly where you are. bye babes, go blend responsibly πŸ¦‹πŸŽ€πŸ’–

πŸ“¦ where this page comes from