0

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.

genpfault
  • 51,148
  • 11
  • 85
  • 139
annitotrk
  • 41
  • 4
  • There are plenty of code samples available online. [Here's one](https://stackoverflow.com/questions/36703984/rotating-android-camera-preview-by-90-degrees-on-glsurfaceview-using-opengl-2-0). – greeble31 Jan 25 '20 at 14:04
  • Thank you, this works! Due to a different use case and description, I couldn't find it earlier – annitotrk Jan 26 '20 at 11:41
  • Thanks to @greeble31, finally found the answer on thread: https://stackoverflow.com/questions/36703984/rotating-android-camera-preview-by-90-degrees-on-glsurfaceview-using-opengl-2-0 – annitotrk Jan 26 '20 at 11:42

0 Answers0