PDA

View Full Version : Transparency problem



betwixt
03-14-2010, 06:44 PM
I want to make HUD partially transparent and some planes in game also, but I must be doing something wrong. I try do do this by setting the color before drawing a plane to glColor4f(1f,0,0,0.5f);
http://betwixt.kirves.pri.ee/Stuff/clip.JPG
Where the green plane is drawn with orthographic projection, the red one in perspective projection and that brown thing is a 3d model.

This way those plane are not transparent to the other objects in the scene, but to the background they are.

Do You know what could be the reasons why this might happen?

betwixt
03-14-2010, 07:29 PM
I turned on blending and set the function to gl_src_minus_alpha and now in perspective everything is ok, but it's still the same on ortho projection.

gl.glEnable(GL10.GL_BLEND);
gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);

Ehsan Kamrani
03-14-2010, 09:09 PM
When using the blending, the order of drawing the objects is important. For example , you must draw your green plane "after" drawing the 3D model.