我正在開發一個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