我还没有找到一个合适的方式来显示的摄像头preVIEW一个OpenGL覆盖OON顶部,
I still haven't found a proper way to show an opengl overlay oon top of camera preview,
有一个黑客,你叫
setContentView(GLSurfaceView)
addContentView(MyCameraSurfaceView)
但它不能正常工作 - 即当您切换到anouther活动并返回,OpenGL的层心不是显示在相机preVIEW
but it doesn't work properly - i.e. when you switch to anouther activity and go back, the opengl layer isnt displayed over camera preview.
有很多教程并用上述方法的样本,但它只是没有按预期正常工作
there are a lot of tutorials and samples which use the above method, but it simply doesn't work as expected
没有人知道他们是如何做到这一点的拉亚
does anyone know how they do it in layar
它看起来像我已经找到了解决我的问题 - 它的 setZOrderMediaOverlay
功能,我的继承人code:
It looks like I've found the solution to my problem - its setZOrderMediaOverlay
function, heres my code:
private void initViews()
{
mFrame = new FrameLayout(this);
initCameraView();
initGLView();
setContentView( mFrame );
}
private void initGLView()
{
mRenderer = new MyGLRenderer( this );
mGLView = new GLSurfaceView(this);
mGLView.setZOrderMediaOverlay(true);
mGLView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
mGLView.setRenderer(mRenderer);
mGLView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
mFrame.addView( mGLView );
}
private void initCameraView()
{
mCameraSurfaceView = new CameraSurfaceView(this);
mFrame.addView(mCameraSurfaceView);
}