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

前端 未结 8 521
深忆病人
深忆病人 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:49

    It appears to be a bug in OpenGl implementation. The same code worked fine on Samsung Note and not on nexus 4. It appears that getUniformLocation breaks on some devices for all variables that are located past samplerExternalOES.

    it also appears that compiler sorts uniform variables alphabeticaly, so the solution that made it work on both devices was to rename your samplerExternalEoz to be zzzTexture or something.

    0 讨论(0)
  • 2020-12-28 10:52

    The method on the above save lots of my time. Thank you guru:

    GLES20.glUniform1i(sTextureHandle, 1);
    GLES20.glActiveTexture(GLES20.GL_TEXTURE1);
    GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES,
        sTextureId);
    

    For your 2D texture:

    GLES20.glUniform1i(filterTextureHandle, 0);
    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, filterTextureID);
    

    Change the texture index is a good way to solve this.

    0 讨论(0)
提交回复
热议问题