I'm rendering my camera preview in android on a SurfaceTexure
. This SurfaceTexture
is bound to target GL_TEXTURE_EXTERNAL_OES
.
I want to copy the texture data from this SurfaceTexture
object to my custom OpenGL texture which is bound to GL_TEXTURE_2D
.
My onFrameAvailable callback is as follows :
@Override
public void onFrameAvailable(final SurfaceTexture surfaceTexture) {
glView.queueEvent(new Runnable() {
@Override
public void run() {
surfaceTexture.updateTexImage();
//TODO: Copy this texture to the custom texture
}
});
}
I have the custom texture object created already.
Can anyone help me with the copying part ?
The usual approach is to bind the texture at a color attachment to an FBO, select that FBO as active and use glCopyTexImage to copy from the FBO into the destination texture.