難道你得到了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。