在OpenGL中,为了达到适当的透明效果,我应该使用glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA),但是使用该混合函数,glClearColor中的alpha参数变得毫无意义。当我在glClearColor中更改alpha参数时,我仍然会得到相同的效果。什么时候可以在glClearColor中使用alpha参数?我能达到什么样的效果?
发布于 2012-06-26 23:30:18
glClearColor设置将使用glClear(GL_COLOR_BUFFER_BIT)清除为RGBA帧缓冲区的颜色(和Alpha值)。GL_DST_ALPHA或GL_ONE_MINUS_DST_ALPHA混合函数将考虑帧缓冲区alpha值。
但是,您的常规屏幕窗口帧缓冲区通常不会携带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通道的帧缓冲区主要用于渲染到纹理目标。
因此,在您的情况下,清晰的颜色对您没有特别的兴趣。您可能更感兴趣的是glColor4f或带有alpha通道的纹理的第四个参数。
发布于 2020-01-19 13:08:10
不透明度是Alpha,而不是透明度,这意味着当它为0时,你根本看不到它。当它为1时,您可以完全看到它。你可以看到它的一半功率,如果它是0.5f。
https://stackoverflow.com/questions/11210607
复制相似问题