I want to create a SurfaceTexture with an OpenGL texture that I can control with a setting similar to this answer . (Quoted here :)
- Creating textures through OpenGL
- Pass this texture to the constructor of the new SurfaceTexture.
- Give this new SurfaceTexture for the camera.
- Make sure you use OES_External (see the documentation for details).
However, creating an OpenGL texture (as in step 1 of the answer) requires an EGL context that requires the EGLSurface to run as the current one, which requires a SurfaceTexture. It seems the only way to create an EGL context is to create a SurfaceView (or another view with SurfaceTexture) and use it to initialize the EGLSurface, and then make the EGLContext stream.
My goal is to create an EGLContext and make it current in the background thread, do some off-screen calculations on the camera preview image (mainly using NDK). I want to create a library and make it as independent of the user interface as possible. Two related questions:
On the Java side, can I create an EGLContext without preprocessing a SurfaceTexture?
On the NDK side, there used to be a private API call to create native windows android_createDisplaySurface() , but it no longer works, and it is a private API. Is there a way to create a surface using NDK?
I am new to using EGL and I donโt understand why you need EGLSurface for EGLContext to make it relevant. In iOS, EAGLContexts are created first, and then framebuffers can be created as needed. Using EGL seems like you always need your own window.
android android-ndk opengl-es egl
user1906
source share