Is there way to detect if opengl context was disposed when user has pressed home
button?Currently I always recreate whole glSurface in onResume
method.Also there is setPreserveEGLContextOnPause
which might keep context alive.I'd like to use it to not recreate glSurface each time.The question is how to detect if I need to recreate it?
Asked
Active
Viewed 758 times
0
1 Answers
1
Check if eglGetCurrentContext()
returns EGL_NO_CONTEXT
.
I'd like to use it to not recreate glSurface each time
Note this is bad practise - it means that your process hogs more memory when it's not in use. In many cases this just means Android will simply kill your process completely if the foreground process needs more memory.

solidpixel
- 10,688
- 1
- 20
- 33
-
What scope this method belongs to?I've checked GLES20 and GLSurfaceView its not there.Anyway I solved problem with ready flag which is set within onSurfaceCreated if this method called twice - I release all resources and recreate everything from scratch. – undefined Dec 10 '16 at 07:45
-
android.opengl.EGL14; EGL14.eglGetCurrentContext(); – solidpixel Dec 10 '16 at 18:05
-
Thanks but this feature requires api level 17 while we're targeted on 16.So I'd stay on my current solution. – undefined Dec 12 '16 at 08:02