GLThread not starting when calling onResume on GLSurfaceView

630 Views Asked by At

I'm writing a game in OpenGLES 1.1 (Using Android static API (GLES11)), and everytime my game activity goes to background (press Home), it comes back in a black screen.

I know that the textures and resources have been lost, but the main issue is that the GLThread is not running anymore (the game logic runs based on the GLThread)

The error I get from logcat is:

E/GLSurfaceView(2604): eglCreateWindowSurface
E/GLSurfaceView(2604): java.lang.IllegalArgumentException: Make sure the SurfaceView or associated SurfaceHolder has a valid Surface
E/GLSurfaceView(2604):  at com.google.android.gles_jni.EGLImpl._eglCreateWindowSurface(Native Method)
E/GLSurfaceView(2604):  at com.google.android.gles_jni.EGLImpl.eglCreateWindowSurface(EGLImpl.java:92)
E/GLSurfaceView(2604):  at android.opengl.GLSurfaceView$DefaultWindowSurfaceFactory.createWindowSurface(GLSurfaceView.java:808)
E/GLSurfaceView(2604):  at android.opengl.GLSurfaceView$EglHelper.createSurface(GLSurfaceView.java:1077)
E/GLSurfaceView(2604):  at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1471)
E/GLSurfaceView(2604):  at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)

I'm using glSurfaceView.onPause on the activity onPause and the glSurfaceView.onResume on the activity onResume... Can anyone give me a hint or explain what exactly could be causing this error?

1

There are 1 best solutions below

0
On

I ended up recreating the GLSurfaceView everytime the onResume is called (or creating it, when it is called for the first time) ...