在OpenGL中混合3层背景

时间:2012-07-14 04:03:13

标签: c++ opengl blending

用于实现以下效果的glBlendfunc()参数是什么:

0)背景,不透明。

1)first_layer,只有一种颜色。

2)半透明球体,与first_layer混合但不与背景混合......

修改

以下是我希望展示我想要实现的效果图。

This is the original - sphere over background

This is the desired effect - green color between sphere and background and sphere is blended with color but not background

1 个答案:

答案 0 :(得分:0)

基于简要描述,听起来你可以将第2层(球体)混合到第1层(first_layer)上,然后在第0层(背景)上面进行blit。第一次混合应该可以使用通常的alpha混合参数:

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

然而,glBlendFunc已经过时了。目前,桌面和移动支持着色器上的OpenGL,可以更轻松地实现您想要的效果。