View Full Version : Blending a simple pic

01-10-2002, 03:44 AM
I would like to now how i can blend my pic so that the black on my pic won't be visable.

My problem: I would like to make a tree, i have a nice pic for it. But the outside of the pic is black. I also have a mask of the pic. I would like to know how i can easily get rid of the black in my pic? I seen it done in projects with blending and i just would like to know how this is done. In simple explanation :-)

Rob The Bloke
01-10-2002, 04:28 AM
Use an alpha channel on the image to act as a mask. Load the image as a 32bit RGBA image and enable bledining as follows:

// draw polygon with texture applied here

01-10-2002, 05:56 AM
Well i see that i was missing RGBA in my texture load, but when i add the line:"look GL_RGBA"

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8 , image1->sizeX, image1->sizeY, 0, GL_RGBA, GL_UNSIGNED_BYTE, image1->data);

in stead of:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8 , image1->sizeX, image1->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, image1->data);

i am getting a unhandeld exception access violation.So there is another problem :-(

01-10-2002, 09:04 AM
He meant that you should conver the image data from RGB to RGBA (after you loaded it from file, but before uploaded to OpenGL), copying each RGB value from the old image to the new image, and fill the alpha channel with one or zero, depending on if the color of the pixel is black or not.

The upload it like this: glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, ..., GL_RGBA, UNSIGNED_BYTE, newData);

01-10-2002, 09:22 AM
Oke tnx guys i got it working, not very nice for now. But it will do. Tnx very much!