Android OpenGL ES 透明背景 [英] Android OpenGL ES Transparent Background
问题描述
我正在构建一个利用 OpenGL 的 Android 应用.就目前而言,GLSurfaceView
的背景是由我的代码动态生成的,并作为纹理加载并使用 glDrawTexfOES
绘制.这是好的",但我可以简单地将图像更平滑地显示到它自己的表面(没有 OpenGL).有什么方法可以使 GLSurfaceView
的背景透明?我听说过一些传言说这可以通过 setEGLConfigChooser
来完成,但我还没有找到任何确认.最终,我想取一个正在绘制的表面并将 GLSurfaceView
放在它上面以实现分层效果.
I'm building an Android app that takes advantage of OpenGL. As it stands, the background for the GLSurfaceView
is dynamically generated by my code and loaded in as a texture and drawn with glDrawTexfOES
. Which is "ok", but I can simply display the image much more smoothly to its own surface (without OpenGL). Is there any way that I can make the background of a GLSurfaceView
transparent? I've heard some rumors that this can be done with setEGLConfigChooser
, but I haven't found any confirmation. Ultimately, I'd like to take a surface which I'm drawing to and put the GLSurfaceView
over it to achieve a layered effect.
我知道这是一个棘手的问题,而且很可能是不可行的,但任何意见都值得赞赏.提前致谢.
I know this is a tricky and is quite possibly infeasible, but any input is appreciated. Thanks in advance.
推荐答案
我做了一些简单的改变来让它工作.
Just some simple changes that I did to get this to work.
在我的 GLSurfaceView.Renderer
上:
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
gl.glDisable(GL10.GL_DITHER);
gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT,
GL10.GL_FASTEST);
gl.glClearColor(0,0,0,0);
gl.glEnable(GL10.GL_CULL_FACE);
gl.glShadeModel(GL10.GL_SMOOTH);
gl.glEnable(GL10.GL_DEPTH_TEST);
}
在我的 GLSurfaceView
上:
setEGLConfigChooser(8, 8, 8, 8, 16, 0);
getHolder().setFormat(PixelFormat.TRANSLUCENT);
这篇关于Android OpenGL ES 透明背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!