Android OpenGL combination of SurfaceTexture (external image) and ordinary texture

前端 未结 8 576
深忆病人
深忆病人 2020-12-28 10:09

I would like to mix camera preview SurfaceTexture with some overlay texture. I am using these shaders for processing:

private final String vss =          


        
8条回答
  •  清酒与你
    2020-12-28 10:29

    I might have the same problem as well. after days of trying, I am proposing my solutions here. Hoping this would help others.

    firstly, problem statement. just like Lukáš Jezný, I have one preview texture and one overlay texture. it works fine for nexus 4/5 and most of other types, but shows nothing on OPPO find 5, Lenovo A820, Lenovo A720.

    solution:

    (1)just like Lukáš Jezný, use YUV data and transforming them to RGB in the shader.

    (2)multipass drawing, draw the preview texture to the framebuffer once , and read it, then draw it again to the screen.

    (3)use another program before you use your own program,

        GLES20.glUseProgram(another one);
        GLES20.glUseProgram(your "real" program);
    

    and it just works for OPPO find 5, Lenovo A820, Lenovo A720 and others. No one knows why......

提交回复
热议问题