The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.
SDL
Simple Directmedia Layer Forums
SDL_RenderCopy alpha-blending strangeness
geoffp
Joined: 03 Oct 2016
Posts: 3
Posted: Tue Oct 04, 2016 9:35 pm
Here's a strange thing: if an ARGB pixel with value 0x01ffffff (white, but nearly transparent) is
rendered onto a pixel with value 0 (completely transparent) by SDL_RenderCopy with default settings,
the rather surprising result is 0xff000000 (opaque black).
How can two nearly transparent pixels combine to make an opaque one?
Have I discovered a bug, or just my own ineptitude?
The effect is different with SDL_BlitSurface, which seems to stick to the formula for alpha-blending
given in SDL_blendmode.h :
dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA))
dstA = srcA + (dstA * (1-srcA))