2012-09-30 66 views
1

我有一個使用GLSurfaceView的選項卡式應用程序。如果我第一次選擇標籤,視圖就會被創建並顯示出來。如果我選中它兩次,那麼表面就會被破壞,但不是新創建的。調用方法onStop()onResume()。如果我按下按鈕,表面就會被破壞。當我再次打開應用程序時,一個新的表面正在創建。GLSurfaceView onResume - 選項卡式應用程序創建上下文

我現在的問題是:爲什麼eglContext不能創建,當我想第二次顯示視圖?爲什麼沒有創建新的GLThread?或者我怎麼能強制EGLSurfaceGLThread的娛樂?在我的三星Galaxy Mini上它不起作用。在我的三星Galaxy SII上它可以工作。我搜索了這個問題,發現GLSurfaceView中有一個錯誤,但沒有解決問題。

感謝一些有用的答案,原諒我的英語:-)

回答

1

難道你得到了IllegalArgumentException

10-08 18:05:36.490: E/GLSurfaceView(3440): eglCreateWindowSurface 
10-08 18:05:36.490: E/GLSurfaceView(3440): java.lang.IllegalArgumentException: Make sure the SurfaceView or associated SurfaceHolder has a valid Surface 
10-08 18:05:36.490: E/GLSurfaceView(3440): at com.google.android.gles_jni.EGLImpl._eglCreateWindowSurface(Native Method) 
10-08 18:05:36.490: E/GLSurfaceView(3440): at com.google.android.gles_jni.EGLImpl.eglCreateWindowSurface(EGLImpl.java:90) 
10-08 18:05:36.490: E/GLSurfaceView(3440): at android.opengl.GLSurfaceView$DefaultWindowSurfaceFactory.createWindowSurface(GLSurfaceView.java:798) 
10-08 18:05:36.490: E/GLSurfaceView(3440): at android.opengl.GLSurfaceView$EglHelper.createSurface(GLSurfaceView.java:1065) 
10-08 18:05:36.490: E/GLSurfaceView(3440): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1433) 
10-08 18:05:36.490: E/GLSurfaceView(3440): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1216) 

如果是的話,你應該修補GLSurfaceView

來自:

   if (createEglSurface) { 
        if (LOG_SURFACE) { 
         Log.w("GLThread", "egl createSurface"); 
        } 
        gl = (GL10) mEglHelper.createSurface(getHolder()); 
        if (gl == null) { 
         // Couldn't create a surface. Quit quietly. 
         break; 
        } 
        sGLThreadManager.checkGLDriver(gl); 
        createEglSurface = false; 
       } 

到:

   if (createEglSurface) { 
        if (LOG_SURFACE) { 
         Log.w("GLThread", "egl createSurface"); 
        } 
        gl = (GL10) mEglHelper.createSurface(getHolder()); 
        if (gl == null) { 
         // If we escape, GLThread ends up. Don't escape. 
         continue; 
        } 
        sGLThreadManager.checkGLDriver(gl); 
        createEglSurface = false; 
       } 

創建我GLSurfaceView class和修補它像上面。

它被凍結在果凍豆中。另請參閱此commit

相關問題