Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copying data from one texture to another - opengl

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 ?

like image 366
omerjerk Avatar asked Oct 25 '25 13:10

omerjerk


1 Answers

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.

like image 130
datenwolf Avatar answered Oct 27 '25 01:10

datenwolf



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!