PDA

View Full Version : alpha texture problem



alexxandre
02-03-2012, 03:34 AM
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

ZbuffeR
02-03-2012, 07:42 AM
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);

killwin
02-03-2012, 01:55 PM
Thanks, but with

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

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.

alexxandre
02-05-2012, 03:42 AM
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