小编Der*_*man的帖子

Opengl透明背景和相机预览不喜欢纹理

我一直致力于创建一个opengl相机叠加层,并成功地将一个带有透明背景的3d立方体放在相机预览上,但添加纹理时会出现问题.

纹理自我出现几秒钟然后整个opengl立方体消失,只留下相机预览运行.

这是我添加相机和opengl视图的地方

  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);


        glView = new GLLayer(this);

        mPreview = new CamLayer(this);

        camera = new CameraSurfaceView(this);
        setContentView(glView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
        addContentView(camera, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); // does not work when texture added

}
Run Code Online (Sandbox Code Playgroud)

这个类给了我所有的麻烦,我使用方法bindCameraTexture动态地使用位图重新构造多维数据集,这与透明的后轮一起工作.

public GLLayer(Context c) {
    super(c);

    this.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
    this.setRenderer(this);
    this.getHolder().setFormat(PixelFormat.TRANSLUCENT);//sets the backround to transparent
}

public void onDrawFrame(GL10 gl) {
    onDrawFrameCounter++;

    drawFrame(mBitmap);
    mSecs += 1;
    drawFrameAt(mBitmap, mSecs);

    gl.glEnable(GL10.GL_TEXTURE_2D);
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);

    bindCameraTexture(gl,mBitmap);

    gl.glLoadIdentity();
    GLU.gluLookAt(gl, 0, 0, 4.2f, 0, 0, …
Run Code Online (Sandbox Code Playgroud)

camera android textures overlay opengl-es

8
推荐指数
1
解决办法
4402
查看次数

标签 统计

android ×1

camera ×1

opengl-es ×1

overlay ×1

textures ×1