I want to draw a semi transparent(say , alpha = 0.5) polygon in openGL-es 2.0 . How to do that?. Few things i tried. 1.I made gl_Fragcolor.w= 0.5 in fragment shader. 2.Disabled Depth related things.
I don know how to enable blending in openGL-es 2.0. I read it somewhere it is implemented automatically. is it so?. Any small help is appreciated.
You have to enable alpha blending. For a faq on how to do that: https://www.khronos.org/opengl/wiki/Transparency_Sorting .
To enable the effect you want:
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Note that enabling alpha blending will hurt performance somewhat - so only do it on the triangles that must have alpha blending enabled.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With