I ran into the problem of being unable to reuse the current EGLContext when trying to display what was on the screen in GLSurfaceView on an off-screen EGLPixelBufferSurface. From what I can tell, the problem is using the static method
EGLContext.getEgl()
is that it creates an EGL instance by default - this will mean that the associated EGLContext is equivalent to EGL10.EGL_NO_CONTEXT.
Furthermore, in Android, an EGLContext can only be associated with one thread (Android developer Romain Guy says here ). Therefore, to properly use
EGL.getCurrentContext()
you will need to have a pre-existing EGL instance and call the getCurrentContext() method on the thread that created the EGLContext.
NOTE. Android now handles saving EGLContext when GLThread is paused / resumed in the GLSurfaceView class (look at the setPreserveEGLContextOnPause(boolean preserveOnPause) method).
John thompson
source share