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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.