通过创建FBO传递数据,不涉及到内存拷贝,速度更快。
if (mFrameBuffers_new[0] <= 0) {
GLES20.glGenFramebuffers(1, mFrameBuffers_new, 0);
if (mFrameBuffers_new[0] <= 0) {
Log.e(TAG, "Failed to glGenFramebuffers, error code: " + GLES20.glGetError());
return;
}
}
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, mFrameBuffers_new[0]);
GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, beautyTextureId, 0);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, renderContext.outputVideoFrame.texId);
GLES20.glCopyTexSubImage2D(GLES20.GL_TEXTURE_2D, 0, 0, 0, 0, 0, renderContext.outputVideoFrame.width,renderContext.outputVideoFrame.height);