PDA

View Full Version : gl blending



YoelShoshan
01-28-2009, 06:51 AM
Somehow it seems that my texture pixels alpha is completely ignored when i try to do blending

i do:
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);

// ... render something

The only thing that seems to have an effect is when i use
glColor4ub(255,255,255,50);

and then alpha on the ENTIRE rendered polygon is 50

How do i make it use the alpha values on the pixels?

Thanks!

ZbuffeR
01-28-2009, 07:05 AM
Most probably your RGBA texture is not sent correctly to OpenGL.
Check you image loader, the texture parameters, etc.

_NK47
01-28-2009, 07:14 AM
if you upload images without alpha they get converted to alpha 255 which is completely opaque. most likely your textures are 24bit or if 32bit then alpha channel is 255 through all pixels.
your alpha blending seems to work fine because glColor4ub(255,255,255,50) works.

YoelShoshan
01-28-2009, 09:06 AM
Hi all, and thanks for your replies.

i am using GL_BGRA (I've tried GL_RGBA as well)
and i definitely set "correct" alpha values in the texture.

So it's seems that it's not the issue.



glBindTexture(GL_TEXTURE_2D, g_texid[HAND_TEX]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R,GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 3, img.w, img.h, 0, GL_BGRA, GL_UNSIGNED_BYTE, img.data);

_NK47
01-28-2009, 09:15 AM
your internal format is 3 though.

YoelShoshan
01-28-2009, 09:43 AM
Ok thanks a lot that's probably it.

Thanks!