ZARk
Posts: 3
Joined: Mon Oct 13, 2014 10:39 am

SDL2 Alpha Blending

Mon Oct 27, 2014 8:30 pm

Hello

Is anyone having issues with alpha blending a texture in SDL2 ?

SDL_SetTextureAlphaMod does not return an error.
But it simply doesn't work on screen.
(trying to crossfade two images for a simple slideshow)

HOWEVER, the same code works fine if i force to SOFTWARE renderer. (except it's horribly slow obviously)
I've converted the surface to 32bit RGBa, even using the same PixelFormat as the renderer... but no cigar.
any hints ? ideas ?

ZARk
Posts: 3
Joined: Mon Oct 13, 2014 10:39 am

Re: SDL2 Alpha Blending

Mon Oct 27, 2014 11:35 pm

I'm going to answer myself.
After testing a SDL2 alpha blending example on the net (which worked)

I managed finding the thing that didn't work .

Basically you NEED to ClearScreen , draw backgroundTexture, then on top modulate the alpha for the new texture.

what i did, was
fade in texture 1
fade in texture 2 etc...

What happened was that once i drew texture2 with opacity 0, the screen went black, instead of drawing on top of the previous buffer.
Somehow in SoftwareMode that worked.

Return to “Graphics programming”