I have a CameraX Preview that provides me with a SurfaceTexture with the camera feed:
Preview preview = new Preview.Builder().build();
preview.setPreviewSurfaceProvider((resolution, surfaceReleaseFuture) -> {
SurfaceTexture surfaceTexture = new SurfaceTexture(0);
surfaceTexture.setDefaultBufferSize(resolution.getWidth(), resolution.getHeight());
final Surface surface = new Surface(surfaceTexture);
// Once surfaceReleaseFuture completes, the Surface and SurfaceTexture
// are no longer used by the camera hence safe to close.
surfaceReleaseFuture.addListener(() -> {
surface.release();
surfaceTexture.release();
}, ContextCompat.getMainExecutor(this.reactContext));
// Return the Surface back in a ListenableFuture
return Futures.immediateFuture(surface);
});
The code is run inside a class extending a GLSurfaceView
on component mount and the concern I have is how can I render the camera feed in onDrawFrame
? I read that I would have to binf GL_TEXTURE_EXTERNAL_OES
for that, but have no idea how to implement that and then render the texture 'fullscreen' on the GLSurfaceView
.