OpenGL glTexImage2D and Transparency

2a2350c5896cd4dd94b3d874f7627254
0
jedij 101 Jan 30, 2008 at 14:51

Im using glTexImage2D to create a texture. Where im having a problem is that my clear color is green and the texture keeps that color for the background in the created image. I was wondering if theres any way to make the background color transparent so that the only thing that shows is the black and blue lines that I want to show?

3 Replies

Please log in or register to post a reply.

6f0a333c785da81d479a0f58c2ccb203
0
monjardin 102 Jan 30, 2008 at 15:29

Loop through all of the pixels and set the alpha value for the green ones.

2a2350c5896cd4dd94b3d874f7627254
0
jedij 101 Jan 30, 2008 at 15:31

@monjardin

Loop through all of the pixels and set the alpha value for the green ones.

can you give me an example of how to do this?

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 168 Jan 30, 2008 at 16:38

Do you understand how texture images are laid out in memory? Assuming you’re using GL_RGBA format, each pixel is just four bytes, one each for red, green, blue, and alpha. You just need to get a pointer to the image data and make a loop that goes through each pixel, examines the color components and determines if it’s green, and if so sets the alpha of that pixel to zero (the alpha of the opaque pixels should be 255).