Textures & surfacesSDL 3.2

SDL_SetTextureBlendMode

Chooses how the texture mixes with what is behind it: transparency, additive glow, none…

Signature

bool SDL_SetTextureBlendMode(SDL_Texture *texture, SDL_BlendMode blendMode);

How it works

SDL_BLENDMODE_BLEND gives normal transparency, so the see-through parts of a PNG show what is behind. SDL_BLENDMODE_ADD adds the colour on top, which suits fire, lasers and light. SDL_BLENDMODE_NONE copies the pixels as they are, ignoring alpha, which is a little faster for opaque backgrounds.

The modes and their formulas are the same as for SDL_SetRenderDrawBlendMode.

Parameters

textureSDL_Texture *

The texture.

blendModeSDL_BlendMode

SDL_BLENDMODE_NONE, _BLEND, _ADD, _MOD…

Return value

true on success; false if the renderer does not support that mode.

Example

example.cpp
1SDL_SetTextureBlendMode(sparkTex, SDL_BLENDMODE_ADD);   // overlapping sparks glow
Official SDL wiki