2012-06-26 71 views
3

在OpenGL中爲了達到合適的透明度效果,我應該使用glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA),但是使用該混合函數,glClearColor中的alpha參數變得毫無意義。當我在glClearColor中更改一個alpha參數時,我仍然得到相同的效果。我何時可以在glClearColor中使用alpha參數?我能達到什麼樣的效果?glBlendFunc和glClearColor alpha參數

+0

你試圖達到什麼樣的效果? – trumpetlicks

回答

8

glClearColor設置顏色(和alpha值)RGBA幀緩衝區將被清除爲glClear(GL_COLOR_BUFFER_BIT)。幀緩衝區alpha值將與GL_DST_ALPHAGL_ONE_MINUS_DST_ALPHA混合函數一起考慮。

但是,您的常規屏幕上的窗口framebuffer通常不會攜帶alpha值。 Notable exceptions exist of course, for example transparent windows with the background shining through, but they're a bit tedious to set up, and will still receive all mouse events, even if over "transparent" areas.

具有alpha通道的幀緩衝區大部分是感興趣的als 渲染到紋理目標。

所以在你的情況下,清晰的顏色對你沒有特別的興趣。你更可能對glColor4f的第四個參數或帶alpha通道的紋理感興趣。