View Full Version : Transparency

08-08-2001, 05:05 PM

I was wondering how can I use transparency with OpenGL. Because I am fairly new to OpenGL and want to make a 2d tile based game. So the maps used will be multilayered and the 2nd layer, 3rd layer and so on should not show the black ( or any other color around them. for example suppose its a tree and the background is euh.. background is Pink. So all the pixel that are pink shouldn't be seen. it should use the color already present at that location ) I used to use Allegro but now i am using OpenGL; I am not sure if blending will do the trick...

[This message has been edited by Akash (edited 08-08-2001).]

08-08-2001, 05:09 PM
I forgot to mention that I draw a texture mapped quad for the tiles.

08-08-2001, 05:17 PM
what u need to do is add an alpha channel to your texture either in a painting program eg gimp or alternatively when u laod the image for each pixel check to see if the colour of it is black if so make the alpha of that pixel 0 else make it 1 then use
glEnable( GL_ALPHA_TEST )
glAlphaFunc( GL_NOTEQUAL, 0 );

08-09-2001, 11:02 PM
hey akash...

zed is right... to clarify he means something like this as his second solution:

for (0 to numpixels)
if (pixe.color==pink)

you'll need to do some setting up before you can use blending in OpenGL.

Good luck yaar.

If you have any questions e-mail me at ngill@imsa.edu

[This message has been edited by ngill (edited 08-10-2001).]

08-10-2001, 07:55 AM
Thx a lot guys; i think i know what your trying to say. I will try if not i'll post another msg... laterz