View Full Version : OpenGL glTexImage2D and Transparency
jedij
01-30-2008, 06:51 AM
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?
monjardin
01-30-2008, 07:29 AM
Loop through all of the pixels and set the alpha value for the green ones.
jedij
01-30-2008, 07:31 AM
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?
Reedbeta
01-30-2008, 08:38 AM
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).
vBulletin, Copyright ©2000-2010, Jelsoft Enterprises Ltd.