View Full Version : cut off background of image

03-06-2001, 01:55 AM
I'm making a menu and i want that it will be transporent, but i have a problem:
i use glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) - it make it transporent,
but i see the background of image?

Can you explane me how to cut off background of image(bmp or tga)?
(with out glBlendFunc(GL_SRC_ALPHA, GL_ONE) or which make the same effect.)


03-06-2001, 02:30 AM
If you want to make it transparent in some places only you have to use alpha test.
Look fo glEnable(GL_ALPHA_TEST) in your preferred OpenGL help system or search on these forums.

03-06-2001, 03:26 AM
sorry but "glAlphaFunc" it doesn't work
I think that you didn't understand me. I try to explane

i have a bmp file with picture


* - background(which black or other color)
0 - other picsels(picture)

I want to don't see "*" on texture(it will be fully transparent)
and "0" will be transporent for 70%.

03-06-2001, 03:56 AM
You have to specify an alpha channel for the alpha test to work.

To do this, when you load your texture as a RGB 24bpp bitmap, copy it to a buffer which has a RGBA 32 bpp depth. Copy RGB to RGB and for A put 0 if R=G=B=0 (black) and 1 otherwise. Then create a RGBA texture.
Then specify a value of say 0.5 for the alphatest's trigger value and draw your textured geometry with alphatest enabled.

If you want to make the rest of the texture 70% transparent, do as above but when the pixel's color is not black, put 0.3 for the A component instead of 1.
Then use blending instead of the alphatest (Probably the best blend function for that is glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)).

Alternatively, you can use a targa bitmap which already has the alpha channel and load it as the RGBA texture.

03-06-2001, 12:37 PM
Can you sent me a simple code with tga load and fully transporent background?

03-06-2001, 03:32 PM
I'll try to find something in some of my old code tomorrow.
Now I'm going to sleep, it's 0.30 here http://www.opengl.org/discussion_boards/ubb/smile.gif

03-07-2001, 01:29 AM
Thank you!!!!!!!!
If you find it sent to