Recommended Posts

Hi, i have a simple 2d game i am making, I am using ortho mode, and have the depth buffer disabled. I also have several 2d sprites, all squares, but i want to be able to draw them ontop of each other. The pixels are either transparent, ie alpha = 0, or completely opaque, alpha = 255 (as sourced from the bitmap image). What is the easiest possible way to draw these ontop of each other. Right now drawing one ontop of the other will result in black being draw to where the alpha, transparent, pixels should have been.

It loads and applies textures for you. I currently use .tga files, since they support transparency, and GIMP can export them well.

Then, just set the correct mode as JYK said and tada alpha blended textures.

REALLY IMPORTANT NOTE:

you need to re-order your sprites so they are drawn in the order of their distance from the camera, as OPenGL won't automatically do this, and will cause lots of problems whereby two overlapping semitransparent polygons have the wrong thing behind them. Luckily you are doing it in 2d and so its far easier. Turn off depth testing, then draw your sprites starting with the background and so on in descending order of their distance from the screen.