Blending a simple pic

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 :slight_smile:

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:

glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
// draw polygon with texture applied here
glDisable(GL_BLEND);

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 :frowning:

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);

Oke tnx guys i got it working, not very nice for now. But it will do. Tnx very much!