PDA

View Full Version : OpenGL ES Texture Transparency



Spade42
02-16-2011, 07:19 PM
I'm working on learning OpenGL ES to expand my iPhone development capabilities, but I'm running into some problems with transparent textures that I can't seem to figure out through Google.

Here are some pics:
http://www.fullofepicwin.com/randomFiles/IMG_0785.PNG
http://www.fullofepicwin.com/randomFiles/IMG_0786.PNG

I'm using this blend function:
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);

The object in the front seems to work exactly the way I want, but the other three objects are acting much differently.

As you can see, the transparency of the small circle only seems to work when it is over the small D-Pad square, of which no transparency can be seen. This seems really strange as all objects are creating in exactly the same way, but are being displayed differently.

Thanks in advance for your help, I could surely use it :p

mobeen
02-16-2011, 09:09 PM
Hi,
Try the basic belnd eq. but also make sure that u render them in back to front order.


glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

Spade42
02-16-2011, 10:03 PM
That certainly did fix the problem, the strange behavior was indeed due to the order in which I drew my objects, thanks a lot for the help! This also helps me to understand how transparency actually works, by taking each transparent pixel and using the selected blend function to mix it with whatever is in the buffer at that moment.

Thanks again! You'll probably be seeing a lot of posts from me in the future, I promise to return the favor once I know what I'm doing :P