透明质感的OpenGL ES的Android版 [英] Transparent texture in OpenGL ES for Android
问题描述
我想设定一个纹理的透明度在OpenGL四,与混合功能的发挥并没有帮助也没有对谷歌任何东西。有什么建议?
I'm trying to set the transparency of a texture on a quad in opengl, playing with the blend functions didn't help neither did anything on google. Any suggestions?
推荐答案
我也有类似的问题,采用一体成型的code表示工作正常,另一个没有。大量的日志记录和调试后,我发现,差异有一行code。
I had a similar problem, with one piece of code that worked correctly and another that didn't. After a lot of logging and debugging, I found that the difference was one line of code.
在code,它已经工作阿尔法,我在呼唤我的设置渲染之前,下面的。
In the code that had working alpha, I was calling the following before setting my renderer.
setEGLConfigChooser(false)
如果这样做没有帮助,这里有几个其他的指针...
If that doesn't help, here are a couple of other pointers...
请确保您启用了混合的在的加载纹理。
Make sure that you've enabled blending before you load the texture.
例如:
// Enable blending using premultiplied alpha.
gl.glEnable(GL10.GL_BLEND);
gl.glBlendFunc(GL10.GL_ONE, GL10.GL_ONE_MINUS_SRC_ALPHA);
...,并确保您使用的实际生成纹理位图有一个alpha组成部分。
...and make sure that the bitmap that you're using to generate the texture actually has an alpha component.
这篇关于透明质感的OpenGL ES的Android版的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!