如何使用 Blend 使多边形透明? [英] How to use Blend to make a polygon transparent?

查看:10
本文介绍了如何使用 Blend 使多边形透明?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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.

解决方案

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.

这篇关于如何使用 Blend 使多边形透明?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆