alpha texture problem

Hello,

I show 2 triangles with png textures RGBA, it works without alpha activated.

But, when i activate alpha with
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

My all screen become black. But alpha works without texturing.
Someone can help me please ? Thanks

Most probably you do not fill the A of your texture properly the the bendfunc you use.
0.0 means completely transparent, 1.0 (or 255) means opaque.

Quick fix could be to use this instead :
glBlendFunc(GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA);

Thanks, but with

glBlendFunc(GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA);
alpha is replaced by a black color. :frowning:

i tried with

glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);

it works for alpha, but all pixels are transformed, like this : a green pixel from texture_1 is transformed into a light blue pixel when it’s over the blue pixel from texture_0.

Solved,

The problem was from SDL_CreateRGBSurface( … );
to direct copy blits :

SDL_SetAlpha(surface,0,0);
SDL_CreateRGBSurface( … );

This allows all the alpha values from the source surface to be copied to the destination surface during blitting.

Thanks