title: Android: Is it possible to create a SurfaceTexture without a SurfaceView?
body: <p>I want to create a <strong>SurfaceTexture</strong> with an OpenGL texture that I can manage, in a setup similar to <a href="https://stackoverflow.com/a/8717505/1762681">this answer</a>. (Quoted here:)</p>
  
  <blockquote>
    <ol>
    <li>Create a texture through OpenGL</li>
    <li>Pass this texture to the constructor of new SurfaceTexture. </li>
    <li>Give this new SurfaceTexture to the camera.</li>
    <li>Make sure you are using OES_External (see documentation for
    details).</li>
    </ol>
  </blockquote>
  
  <p>However, creating an OpenGL texture (as in step 1 of the answer), requires an <strong>EGL context</strong>, which requires a EGLSurface to be made current, which requires a SurfaceTexture. It seems the only way of creating the EGL context is by creating a SurfaceView (or another view that has a SurfaceTexture), and use it to initialise the EGLSurface and then make the EGLContext current.</p>
  
  <p>My objective is to create an EGLContext and make it current in a background thread, to do some offscreen computation on the camera preview image (mostly using the NDK). I want to create a library, and make it as independent of the UI as possible. Two related questions:</p>
  
  <p>On the Java side, is it possible to create an EGLContext without having a SurfaceTexture created beforehand?</p>
  
  <p>On the NDK side, there used to be a private API call to create native windows <code>android_createDisplaySurface()</code>, but it doesn't work anymore, and well, it's a private API. Is there any way of creating a surface with the NDK?</p>
  
  <p>I'm quite new to using EGL, and I fail to understand why you need an EGLSurface for an EGLContext to be made current. In iOS, EAGLContexts can be created first, and then framebuffers can be created as needed. Using EGL it seems you always need a native window.</p>