我正在开发一个iPad应用程序,OpenFrameworks和OpenGL ES 1.1。我需要显示带有Alpha通道的视频。为了模拟它,我有一个RGB视频(没有任何alpha通道)和另一个只包含alpha通道的视频(在每个RGB通道上,所以白色部分对应于可见部分,黑色对应于不可见)。每个视频都是OpenGL纹理。OpenGL ES 1.1 - 阿尔法面具
在的OpenGL ES 1.1,没有着色器,所以我发现这个解决方案(这里:OpenGL - mask with multiple textures):
glEnable(GL_BLEND);
// Use a simple blendfunc for drawing the background
glBlendFunc(GL_ONE, GL_ZERO);
// Draw entire background without masking
drawQuad(backgroundTexture);
// Next, we want a blendfunc that doesn't change the color of any pixels,
// but rather replaces the framebuffer alpha values with values based
// on the whiteness of the mask. In other words, if a pixel is white in the mask,
// then the corresponding framebuffer pixel's alpha will be set to 1.
glBlendFuncSeparate(GL_ZERO, GL_ONE, GL_SRC_COLOR, GL_ZERO);
// Now "draw" the mask (again, this doesn't produce a visible result, it just
// changes the alpha values in the framebuffer)
drawQuad(maskTexture);
// Finally, we want a blendfunc that makes the foreground visible only in
// areas with high alpha.
glBlendFunc(GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA);
drawQuad(foregroundTexture);
这正是我想做的事情,但glBlendFuncSeparate()不能在OpenGL ES 1.1中存在(或在iOS上)。我试图用glColorMask做到这一点,我发现这个:Can't get masking to work correctly with OpenGL
但它不工作,我猜是因为他的面具纹理文件包含一个'真正的'alpha通道,而不是我的。
glColorAlpha不存在;你的意思是glColorMask? – Calvin1602 2012-07-26 10:05:51
哦,是的,对不起,我刚刚纠正。 – user1554162 2012-07-26 10:07:47
alpha通道从哪里来? – Calvin1602 2012-07-26 10:22:29