openGL 中的混合问题(颜色条示例)
任何人都可以提供一些线索来解释为什么当我尝试渲染下面的颜色条四边形时
它看起来像这样:
这是我的渲染代码:
gl.glEnable(GL.GL_BLEND);
gl.glBlendFunc(GL.GL_ONE, GL.GL_ZERO);
gl.glBlendEquation(GL.GL_FUNC_ADD);
gl.glEnable(GL.GL_ALPHA_TEST);
gl.glAlphaFunc(GL.GL_GREATER, 0.01f);
// do the drawing...
gl.glDisable(GL.GL_TEXTURE_2D);
gl.glDisable(GL.GL_ALPHA_TEST);
我确信解决方案很简单,我只是在胡思乱想但这只是那些日子之一! 感谢您的帮助!
Can anyone give some clues as to why when I try to render the color bar quad below
It appears like this:
Here is my rendering code:
gl.glEnable(GL.GL_BLEND);
gl.glBlendFunc(GL.GL_ONE, GL.GL_ZERO);
gl.glBlendEquation(GL.GL_FUNC_ADD);
gl.glEnable(GL.GL_ALPHA_TEST);
gl.glAlphaFunc(GL.GL_GREATER, 0.01f);
// do the drawing...
gl.glDisable(GL.GL_TEXTURE_2D);
gl.glDisable(GL.GL_ALPHA_TEST);
I'm sure the solution is simple and I'm just having a brainfart but it's just one of those days!
Thanks for the help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您想要执行哪种混合?要简单地绘制没有任何颜色混合或 Alpha 通道的东西,您甚至不必使用
GL_BLEND
或GL_ALPHA_TEST
(将两者禁用)。GL_BLEND
用于定义如何添加不同的颜色“层”(通常是如何应用 Alpha 通道),而GL_ALPHA_TEST
则决定要遵循/忽略哪些 Alpha 值。渲染四边形时还要检查顶点颜色(尝试渲染没有纹理的单色四边形,例如使用洋红色)。然而,看看你的图像,我猜你以某种方式禁用了红色通道的绘制(
glColorMask()
) - 尽管有黄色,这让我感到困惑。What kind of blending are you trying to perform? To simply draw something without any color mixing or alpha channels you don't even have to play around with
GL_BLEND
orGL_ALPHA_TEST
(leave both disabled).GL_BLEND
is used to define how to add different "layers" of color (usually on how to apply alpha channels) whileGL_ALPHA_TEST
decides what alpha values to respect/ignore. Also check your vertex colors when rendering the quad (try to render a unicolor quad without texture, e.g. using magenta).However looking at your images I'd guess you somehow disabled drawing to your red color channel (
glColorMask()
) - although there's yellow, which confuses me.当我导入 PNG 文件时,RGBA 交换出现问题。
There was a problem with RGBA getting swapped around when I imported the PNG file.