问题描述
我要建一个Android应用程序,它利用OpenGL的优势。按照现在的情况,背景为 GLSurfaceView
动态我的code生成,并加载作为纹理和绘制 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.
我知道这是一个棘手,很可能是不可行的,但是任何输入AP preciated。先谢谢了。
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的透明背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!