How to use Blend to make a polygon transparent?

↘锁芯ラ 提交于 2019-12-18 09:54:07

问题


I have a app that shows two polygons. I need to make progressively invisible one of the polygons, but the other must be visible. Im working with OpenGL ES 1.1. I'm developing for Android, but i think that other platforms will do the same code with some minor changes.

How i can do that?

I know that i must do it with these functions:

    glEnable (GL_BLEND); 
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

But i dont know where i have to put them and how to use them to make my polygon progressively transparent.


回答1:


Looks like the right blend functions there, call them before drawing your translucent polygon. The alpha value is typically supplied with the color or texturemap (Red, Green, Blue, Alpha), and the range for alpha is 0.0 (transparent) to 1.0 (opaque) given the blending function above.

Also note that translucent objects are sensitive to render order: Typically you must draw all your opaque objects first, using the depth buffer as normal. Then, turn on blending and set the depth buffer to read-only, and draw your translucent objects back-to-front (draw the farthest from the camera first). This way the fragment blending happens farthest-to-nearest.



来源:https://stackoverflow.com/questions/9588254/how-to-use-blend-to-make-a-polygon-transparent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!