alpha blending bug?

Please can you help:

if I draw two rectangles with alpha values of say 0.2 in the same function, one behind the other you cannot see the second one through the first. However if these rectangles are draw in different parts of the code you can.

What the hells going on?

You must draw your triangles in back to front order to get “proper” blending. When you draw the closet triangle first, the Z-buffer is also updated, and when drawing the second triangle, it will fail the depthtest because it’s behind the first object. But the fact that it SHOULD be visible through the previous triangle is something the depthtest function is unaware of, because of the way OpenGL is designed.

Usually it works like this: First draw opaque triangles (order does not matter here), then draw tranlucent triangles in back to front order.