浏览代码

- fixed crash of scr_Flush on shitty versions of Android OpenGL ES drivers

git-svn-id: http://zengl.googlecode.com/svn/branches/0.3.x@1939 6573c10b-8653-0410-9706-d32479e959fb
dr.andru 12 年之前
父节点
当前提交
188653348a

+ 10 - 8
demos/Android/01 - Initialization/src/zengl/android/ZenGL.java

@@ -175,18 +175,20 @@ public class ZenGL extends GLSurfaceView
 		((Activity)getContext()).finish();
 		System.exit( 0 );
 	}
-	
+
 	public void SwapBuffers()
 	{
-	    EGL10 currEGL = (EGL10)EGLContext.getEGL();
+	    try {
+	    	EGL10 currEGL = (EGL10)EGLContext.getEGL();
 
-	    EGLDisplay currDisplay = currEGL.eglGetCurrentDisplay();
-	    if ( currDisplay == EGL10.EGL_NO_DISPLAY ) return;    
+	    	EGLDisplay currDisplay = currEGL.eglGetCurrentDisplay();
+	    	if ( currDisplay == EGL10.EGL_NO_DISPLAY ) return;    
 
-	    EGLSurface currSurface = currEGL.eglGetCurrentSurface( EGL10.EGL_DRAW );
-	    if ( currSurface == EGL10.EGL_NO_SURFACE ) return;
+	    	EGLSurface currSurface = currEGL.eglGetCurrentSurface( EGL10.EGL_DRAW );
+	    	if ( currSurface == EGL10.EGL_NO_SURFACE ) return;
 
-	    currEGL.eglSwapBuffers( currDisplay, currSurface);
+	    	currEGL.eglSwapBuffers( currDisplay, currSurface);
+	    } catch ( Exception e ) { }
 	}
 
 	public void ShowKeyboard()
@@ -270,4 +272,4 @@ public class ZenGL extends GLSurfaceView
 			return true;
 		}
 	}
-}
+}

+ 10 - 8
demos/Android/02 - Resources/src/zengl/android/ZenGL.java

@@ -175,18 +175,20 @@ public class ZenGL extends GLSurfaceView
 		((Activity)getContext()).finish();
 		System.exit( 0 );
 	}
-	
+
 	public void SwapBuffers()
 	{
-	    EGL10 currEGL = (EGL10)EGLContext.getEGL();
+	    try {
+	    	EGL10 currEGL = (EGL10)EGLContext.getEGL();
 
-	    EGLDisplay currDisplay = currEGL.eglGetCurrentDisplay();
-	    if ( currDisplay == EGL10.EGL_NO_DISPLAY ) return;    
+	    	EGLDisplay currDisplay = currEGL.eglGetCurrentDisplay();
+	    	if ( currDisplay == EGL10.EGL_NO_DISPLAY ) return;    
 
-	    EGLSurface currSurface = currEGL.eglGetCurrentSurface( EGL10.EGL_DRAW );
-	    if ( currSurface == EGL10.EGL_NO_SURFACE ) return;
+	    	EGLSurface currSurface = currEGL.eglGetCurrentSurface( EGL10.EGL_DRAW );
+	    	if ( currSurface == EGL10.EGL_NO_SURFACE ) return;
 
-	    currEGL.eglSwapBuffers( currDisplay, currSurface);
+	    	currEGL.eglSwapBuffers( currDisplay, currSurface);
+	    } catch ( Exception e ) { }
 	}
 
 	public void ShowKeyboard()
@@ -270,4 +272,4 @@ public class ZenGL extends GLSurfaceView
 			return true;
 		}
 	}
-}
+}

+ 10 - 8
demos/Android/03 - Input/src/zengl/android/ZenGL.java

@@ -175,18 +175,20 @@ public class ZenGL extends GLSurfaceView
 		((Activity)getContext()).finish();
 		System.exit( 0 );
 	}
-	
+
 	public void SwapBuffers()
 	{
-	    EGL10 currEGL = (EGL10)EGLContext.getEGL();
+	    try {
+	    	EGL10 currEGL = (EGL10)EGLContext.getEGL();
 
-	    EGLDisplay currDisplay = currEGL.eglGetCurrentDisplay();
-	    if ( currDisplay == EGL10.EGL_NO_DISPLAY ) return;    
+	    	EGLDisplay currDisplay = currEGL.eglGetCurrentDisplay();
+	    	if ( currDisplay == EGL10.EGL_NO_DISPLAY ) return;    
 
-	    EGLSurface currSurface = currEGL.eglGetCurrentSurface( EGL10.EGL_DRAW );
-	    if ( currSurface == EGL10.EGL_NO_SURFACE ) return;
+	    	EGLSurface currSurface = currEGL.eglGetCurrentSurface( EGL10.EGL_DRAW );
+	    	if ( currSurface == EGL10.EGL_NO_SURFACE ) return;
 
-	    currEGL.eglSwapBuffers( currDisplay, currSurface);
+	    	currEGL.eglSwapBuffers( currDisplay, currSurface);
+	    } catch ( Exception e ) { }
 	}
 
 	public void ShowKeyboard()
@@ -270,4 +272,4 @@ public class ZenGL extends GLSurfaceView
 			return true;
 		}
 	}
-}
+}

+ 10 - 8
demos/Android/04 - Screen Settings/src/zengl/android/ZenGL.java

@@ -175,18 +175,20 @@ public class ZenGL extends GLSurfaceView
 		((Activity)getContext()).finish();
 		System.exit( 0 );
 	}
-	
+
 	public void SwapBuffers()
 	{
-	    EGL10 currEGL = (EGL10)EGLContext.getEGL();
+	    try {
+	    	EGL10 currEGL = (EGL10)EGLContext.getEGL();
 
-	    EGLDisplay currDisplay = currEGL.eglGetCurrentDisplay();
-	    if ( currDisplay == EGL10.EGL_NO_DISPLAY ) return;    
+	    	EGLDisplay currDisplay = currEGL.eglGetCurrentDisplay();
+	    	if ( currDisplay == EGL10.EGL_NO_DISPLAY ) return;    
 
-	    EGLSurface currSurface = currEGL.eglGetCurrentSurface( EGL10.EGL_DRAW );
-	    if ( currSurface == EGL10.EGL_NO_SURFACE ) return;
+	    	EGLSurface currSurface = currEGL.eglGetCurrentSurface( EGL10.EGL_DRAW );
+	    	if ( currSurface == EGL10.EGL_NO_SURFACE ) return;
 
-	    currEGL.eglSwapBuffers( currDisplay, currSurface);
+	    	currEGL.eglSwapBuffers( currDisplay, currSurface);
+	    } catch ( Exception e ) { }
 	}
 
 	public void ShowKeyboard()
@@ -270,4 +272,4 @@ public class ZenGL extends GLSurfaceView
 			return true;
 		}
 	}
-}
+}

+ 10 - 8
demos/Android/05 - Primitives/src/zengl/android/ZenGL.java

@@ -175,18 +175,20 @@ public class ZenGL extends GLSurfaceView
 		((Activity)getContext()).finish();
 		System.exit( 0 );
 	}
-	
+
 	public void SwapBuffers()
 	{
-	    EGL10 currEGL = (EGL10)EGLContext.getEGL();
+	    try {
+	    	EGL10 currEGL = (EGL10)EGLContext.getEGL();
 
-	    EGLDisplay currDisplay = currEGL.eglGetCurrentDisplay();
-	    if ( currDisplay == EGL10.EGL_NO_DISPLAY ) return;    
+	    	EGLDisplay currDisplay = currEGL.eglGetCurrentDisplay();
+	    	if ( currDisplay == EGL10.EGL_NO_DISPLAY ) return;    
 
-	    EGLSurface currSurface = currEGL.eglGetCurrentSurface( EGL10.EGL_DRAW );
-	    if ( currSurface == EGL10.EGL_NO_SURFACE ) return;
+	    	EGLSurface currSurface = currEGL.eglGetCurrentSurface( EGL10.EGL_DRAW );
+	    	if ( currSurface == EGL10.EGL_NO_SURFACE ) return;
 
-	    currEGL.eglSwapBuffers( currDisplay, currSurface);
+	    	currEGL.eglSwapBuffers( currDisplay, currSurface);
+	    } catch ( Exception e ) { }
 	}
 
 	public void ShowKeyboard()
@@ -270,4 +272,4 @@ public class ZenGL extends GLSurfaceView
 			return true;
 		}
 	}
-}
+}

+ 10 - 8
demos/Android/06 - Text/src/zengl/android/ZenGL.java

@@ -175,18 +175,20 @@ public class ZenGL extends GLSurfaceView
 		((Activity)getContext()).finish();
 		System.exit( 0 );
 	}
-	
+
 	public void SwapBuffers()
 	{
-	    EGL10 currEGL = (EGL10)EGLContext.getEGL();
+	    try {
+	    	EGL10 currEGL = (EGL10)EGLContext.getEGL();
 
-	    EGLDisplay currDisplay = currEGL.eglGetCurrentDisplay();
-	    if ( currDisplay == EGL10.EGL_NO_DISPLAY ) return;    
+	    	EGLDisplay currDisplay = currEGL.eglGetCurrentDisplay();
+	    	if ( currDisplay == EGL10.EGL_NO_DISPLAY ) return;    
 
-	    EGLSurface currSurface = currEGL.eglGetCurrentSurface( EGL10.EGL_DRAW );
-	    if ( currSurface == EGL10.EGL_NO_SURFACE ) return;
+	    	EGLSurface currSurface = currEGL.eglGetCurrentSurface( EGL10.EGL_DRAW );
+	    	if ( currSurface == EGL10.EGL_NO_SURFACE ) return;
 
-	    currEGL.eglSwapBuffers( currDisplay, currSurface);
+	    	currEGL.eglSwapBuffers( currDisplay, currSurface);
+	    } catch ( Exception e ) { }
 	}
 
 	public void ShowKeyboard()
@@ -270,4 +272,4 @@ public class ZenGL extends GLSurfaceView
 			return true;
 		}
 	}
-}
+}

+ 10 - 8
demos/Android/07 - Sprites/src/zengl/android/ZenGL.java

@@ -175,18 +175,20 @@ public class ZenGL extends GLSurfaceView
 		((Activity)getContext()).finish();
 		System.exit( 0 );
 	}
-	
+
 	public void SwapBuffers()
 	{
-	    EGL10 currEGL = (EGL10)EGLContext.getEGL();
+	    try {
+	    	EGL10 currEGL = (EGL10)EGLContext.getEGL();
 
-	    EGLDisplay currDisplay = currEGL.eglGetCurrentDisplay();
-	    if ( currDisplay == EGL10.EGL_NO_DISPLAY ) return;    
+	    	EGLDisplay currDisplay = currEGL.eglGetCurrentDisplay();
+	    	if ( currDisplay == EGL10.EGL_NO_DISPLAY ) return;    
 
-	    EGLSurface currSurface = currEGL.eglGetCurrentSurface( EGL10.EGL_DRAW );
-	    if ( currSurface == EGL10.EGL_NO_SURFACE ) return;
+	    	EGLSurface currSurface = currEGL.eglGetCurrentSurface( EGL10.EGL_DRAW );
+	    	if ( currSurface == EGL10.EGL_NO_SURFACE ) return;
 
-	    currEGL.eglSwapBuffers( currDisplay, currSurface);
+	    	currEGL.eglSwapBuffers( currDisplay, currSurface);
+	    } catch ( Exception e ) { }
 	}
 
 	public void ShowKeyboard()
@@ -270,4 +272,4 @@ public class ZenGL extends GLSurfaceView
 			return true;
 		}
 	}
-}
+}

+ 10 - 8
demos/Android/08 - Sprite Engine/src/zengl/android/ZenGL.java

@@ -175,18 +175,20 @@ public class ZenGL extends GLSurfaceView
 		((Activity)getContext()).finish();
 		System.exit( 0 );
 	}
-	
+
 	public void SwapBuffers()
 	{
-	    EGL10 currEGL = (EGL10)EGLContext.getEGL();
+	    try {
+	    	EGL10 currEGL = (EGL10)EGLContext.getEGL();
 
-	    EGLDisplay currDisplay = currEGL.eglGetCurrentDisplay();
-	    if ( currDisplay == EGL10.EGL_NO_DISPLAY ) return;    
+	    	EGLDisplay currDisplay = currEGL.eglGetCurrentDisplay();
+	    	if ( currDisplay == EGL10.EGL_NO_DISPLAY ) return;    
 
-	    EGLSurface currSurface = currEGL.eglGetCurrentSurface( EGL10.EGL_DRAW );
-	    if ( currSurface == EGL10.EGL_NO_SURFACE ) return;
+	    	EGLSurface currSurface = currEGL.eglGetCurrentSurface( EGL10.EGL_DRAW );
+	    	if ( currSurface == EGL10.EGL_NO_SURFACE ) return;
 
-	    currEGL.eglSwapBuffers( currDisplay, currSurface);
+	    	currEGL.eglSwapBuffers( currDisplay, currSurface);
+	    } catch ( Exception e ) { }
 	}
 
 	public void ShowKeyboard()
@@ -270,4 +272,4 @@ public class ZenGL extends GLSurfaceView
 			return true;
 		}
 	}
-}
+}

+ 10 - 8
demos/Android/09 - Sprite Engine(Classes)/src/zengl/android/ZenGL.java

@@ -175,18 +175,20 @@ public class ZenGL extends GLSurfaceView
 		((Activity)getContext()).finish();
 		System.exit( 0 );
 	}
-	
+
 	public void SwapBuffers()
 	{
-	    EGL10 currEGL = (EGL10)EGLContext.getEGL();
+	    try {
+	    	EGL10 currEGL = (EGL10)EGLContext.getEGL();
 
-	    EGLDisplay currDisplay = currEGL.eglGetCurrentDisplay();
-	    if ( currDisplay == EGL10.EGL_NO_DISPLAY ) return;    
+	    	EGLDisplay currDisplay = currEGL.eglGetCurrentDisplay();
+	    	if ( currDisplay == EGL10.EGL_NO_DISPLAY ) return;    
 
-	    EGLSurface currSurface = currEGL.eglGetCurrentSurface( EGL10.EGL_DRAW );
-	    if ( currSurface == EGL10.EGL_NO_SURFACE ) return;
+	    	EGLSurface currSurface = currEGL.eglGetCurrentSurface( EGL10.EGL_DRAW );
+	    	if ( currSurface == EGL10.EGL_NO_SURFACE ) return;
 
-	    currEGL.eglSwapBuffers( currDisplay, currSurface);
+	    	currEGL.eglSwapBuffers( currDisplay, currSurface);
+	    } catch ( Exception e ) { }
 	}
 
 	public void ShowKeyboard()
@@ -270,4 +272,4 @@ public class ZenGL extends GLSurfaceView
 			return true;
 		}
 	}
-}
+}

+ 10 - 8
demos/Android/10 - Tiles/src/zengl/android/ZenGL.java

@@ -175,18 +175,20 @@ public class ZenGL extends GLSurfaceView
 		((Activity)getContext()).finish();
 		System.exit( 0 );
 	}
-	
+
 	public void SwapBuffers()
 	{
-	    EGL10 currEGL = (EGL10)EGLContext.getEGL();
+	    try {
+	    	EGL10 currEGL = (EGL10)EGLContext.getEGL();
 
-	    EGLDisplay currDisplay = currEGL.eglGetCurrentDisplay();
-	    if ( currDisplay == EGL10.EGL_NO_DISPLAY ) return;    
+	    	EGLDisplay currDisplay = currEGL.eglGetCurrentDisplay();
+	    	if ( currDisplay == EGL10.EGL_NO_DISPLAY ) return;    
 
-	    EGLSurface currSurface = currEGL.eglGetCurrentSurface( EGL10.EGL_DRAW );
-	    if ( currSurface == EGL10.EGL_NO_SURFACE ) return;
+	    	EGLSurface currSurface = currEGL.eglGetCurrentSurface( EGL10.EGL_DRAW );
+	    	if ( currSurface == EGL10.EGL_NO_SURFACE ) return;
 
-	    currEGL.eglSwapBuffers( currDisplay, currSurface);
+	    	currEGL.eglSwapBuffers( currDisplay, currSurface);
+	    } catch ( Exception e ) { }
 	}
 
 	public void ShowKeyboard()
@@ -270,4 +272,4 @@ public class ZenGL extends GLSurfaceView
 			return true;
 		}
 	}
-}
+}

+ 10 - 8
demos/Android/11 - Grid/src/zengl/android/ZenGL.java

@@ -175,18 +175,20 @@ public class ZenGL extends GLSurfaceView
 		((Activity)getContext()).finish();
 		System.exit( 0 );
 	}
-	
+
 	public void SwapBuffers()
 	{
-	    EGL10 currEGL = (EGL10)EGLContext.getEGL();
+	    try {
+	    	EGL10 currEGL = (EGL10)EGLContext.getEGL();
 
-	    EGLDisplay currDisplay = currEGL.eglGetCurrentDisplay();
-	    if ( currDisplay == EGL10.EGL_NO_DISPLAY ) return;    
+	    	EGLDisplay currDisplay = currEGL.eglGetCurrentDisplay();
+	    	if ( currDisplay == EGL10.EGL_NO_DISPLAY ) return;    
 
-	    EGLSurface currSurface = currEGL.eglGetCurrentSurface( EGL10.EGL_DRAW );
-	    if ( currSurface == EGL10.EGL_NO_SURFACE ) return;
+	    	EGLSurface currSurface = currEGL.eglGetCurrentSurface( EGL10.EGL_DRAW );
+	    	if ( currSurface == EGL10.EGL_NO_SURFACE ) return;
 
-	    currEGL.eglSwapBuffers( currDisplay, currSurface);
+	    	currEGL.eglSwapBuffers( currDisplay, currSurface);
+	    } catch ( Exception e ) { }
 	}
 
 	public void ShowKeyboard()
@@ -270,4 +272,4 @@ public class ZenGL extends GLSurfaceView
 			return true;
 		}
 	}
-}
+}

+ 10 - 8
demos/Android/12 - Render into Texture/src/zengl/android/ZenGL.java

@@ -175,18 +175,20 @@ public class ZenGL extends GLSurfaceView
 		((Activity)getContext()).finish();
 		System.exit( 0 );
 	}
-	
+
 	public void SwapBuffers()
 	{
-	    EGL10 currEGL = (EGL10)EGLContext.getEGL();
+	    try {
+	    	EGL10 currEGL = (EGL10)EGLContext.getEGL();
 
-	    EGLDisplay currDisplay = currEGL.eglGetCurrentDisplay();
-	    if ( currDisplay == EGL10.EGL_NO_DISPLAY ) return;    
+	    	EGLDisplay currDisplay = currEGL.eglGetCurrentDisplay();
+	    	if ( currDisplay == EGL10.EGL_NO_DISPLAY ) return;    
 
-	    EGLSurface currSurface = currEGL.eglGetCurrentSurface( EGL10.EGL_DRAW );
-	    if ( currSurface == EGL10.EGL_NO_SURFACE ) return;
+	    	EGLSurface currSurface = currEGL.eglGetCurrentSurface( EGL10.EGL_DRAW );
+	    	if ( currSurface == EGL10.EGL_NO_SURFACE ) return;
 
-	    currEGL.eglSwapBuffers( currDisplay, currSurface);
+	    	currEGL.eglSwapBuffers( currDisplay, currSurface);
+	    } catch ( Exception e ) { }
 	}
 
 	public void ShowKeyboard()
@@ -270,4 +272,4 @@ public class ZenGL extends GLSurfaceView
 			return true;
 		}
 	}
-}
+}

+ 10 - 8
demos/Android/13 - Particles/src/zengl/android/ZenGL.java

@@ -175,18 +175,20 @@ public class ZenGL extends GLSurfaceView
 		((Activity)getContext()).finish();
 		System.exit( 0 );
 	}
-	
+
 	public void SwapBuffers()
 	{
-	    EGL10 currEGL = (EGL10)EGLContext.getEGL();
+	    try {
+	    	EGL10 currEGL = (EGL10)EGLContext.getEGL();
 
-	    EGLDisplay currDisplay = currEGL.eglGetCurrentDisplay();
-	    if ( currDisplay == EGL10.EGL_NO_DISPLAY ) return;    
+	    	EGLDisplay currDisplay = currEGL.eglGetCurrentDisplay();
+	    	if ( currDisplay == EGL10.EGL_NO_DISPLAY ) return;    
 
-	    EGLSurface currSurface = currEGL.eglGetCurrentSurface( EGL10.EGL_DRAW );
-	    if ( currSurface == EGL10.EGL_NO_SURFACE ) return;
+	    	EGLSurface currSurface = currEGL.eglGetCurrentSurface( EGL10.EGL_DRAW );
+	    	if ( currSurface == EGL10.EGL_NO_SURFACE ) return;
 
-	    currEGL.eglSwapBuffers( currDisplay, currSurface);
+	    	currEGL.eglSwapBuffers( currDisplay, currSurface);
+	    } catch ( Exception e ) { }
 	}
 
 	public void ShowKeyboard()
@@ -270,4 +272,4 @@ public class ZenGL extends GLSurfaceView
 			return true;
 		}
 	}
-}
+}

+ 10 - 8
demos/Android/14 - Sound/src/zengl/android/ZenGL.java

@@ -175,18 +175,20 @@ public class ZenGL extends GLSurfaceView
 		((Activity)getContext()).finish();
 		System.exit( 0 );
 	}
-	
+
 	public void SwapBuffers()
 	{
-	    EGL10 currEGL = (EGL10)EGLContext.getEGL();
+	    try {
+	    	EGL10 currEGL = (EGL10)EGLContext.getEGL();
 
-	    EGLDisplay currDisplay = currEGL.eglGetCurrentDisplay();
-	    if ( currDisplay == EGL10.EGL_NO_DISPLAY ) return;    
+	    	EGLDisplay currDisplay = currEGL.eglGetCurrentDisplay();
+	    	if ( currDisplay == EGL10.EGL_NO_DISPLAY ) return;    
 
-	    EGLSurface currSurface = currEGL.eglGetCurrentSurface( EGL10.EGL_DRAW );
-	    if ( currSurface == EGL10.EGL_NO_SURFACE ) return;
+	    	EGLSurface currSurface = currEGL.eglGetCurrentSurface( EGL10.EGL_DRAW );
+	    	if ( currSurface == EGL10.EGL_NO_SURFACE ) return;
 
-	    currEGL.eglSwapBuffers( currDisplay, currSurface);
+	    	currEGL.eglSwapBuffers( currDisplay, currSurface);
+	    } catch ( Exception e ) { }
 	}
 
 	public void ShowKeyboard()
@@ -270,4 +272,4 @@ public class ZenGL extends GLSurfaceView
 			return true;
 		}
 	}
-}
+}

+ 10 - 8
demos/Android/15 - Video/src/zengl/android/ZenGL.java

@@ -175,18 +175,20 @@ public class ZenGL extends GLSurfaceView
 		((Activity)getContext()).finish();
 		System.exit( 0 );
 	}
-	
+
 	public void SwapBuffers()
 	{
-	    EGL10 currEGL = (EGL10)EGLContext.getEGL();
+	    try {
+	    	EGL10 currEGL = (EGL10)EGLContext.getEGL();
 
-	    EGLDisplay currDisplay = currEGL.eglGetCurrentDisplay();
-	    if ( currDisplay == EGL10.EGL_NO_DISPLAY ) return;    
+	    	EGLDisplay currDisplay = currEGL.eglGetCurrentDisplay();
+	    	if ( currDisplay == EGL10.EGL_NO_DISPLAY ) return;    
 
-	    EGLSurface currSurface = currEGL.eglGetCurrentSurface( EGL10.EGL_DRAW );
-	    if ( currSurface == EGL10.EGL_NO_SURFACE ) return;
+	    	EGLSurface currSurface = currEGL.eglGetCurrentSurface( EGL10.EGL_DRAW );
+	    	if ( currSurface == EGL10.EGL_NO_SURFACE ) return;
 
-	    currEGL.eglSwapBuffers( currDisplay, currSurface);
+	    	currEGL.eglSwapBuffers( currDisplay, currSurface);
+	    } catch ( Exception e ) { }
 	}
 
 	public void ShowKeyboard()
@@ -270,4 +272,4 @@ public class ZenGL extends GLSurfaceView
 			return true;
 		}
 	}
-}
+}

+ 10 - 8
demos/Android/16 - Physics/src/zengl/android/ZenGL.java

@@ -175,18 +175,20 @@ public class ZenGL extends GLSurfaceView
 		((Activity)getContext()).finish();
 		System.exit( 0 );
 	}
-	
+
 	public void SwapBuffers()
 	{
-	    EGL10 currEGL = (EGL10)EGLContext.getEGL();
+	    try {
+	    	EGL10 currEGL = (EGL10)EGLContext.getEGL();
 
-	    EGLDisplay currDisplay = currEGL.eglGetCurrentDisplay();
-	    if ( currDisplay == EGL10.EGL_NO_DISPLAY ) return;    
+	    	EGLDisplay currDisplay = currEGL.eglGetCurrentDisplay();
+	    	if ( currDisplay == EGL10.EGL_NO_DISPLAY ) return;    
 
-	    EGLSurface currSurface = currEGL.eglGetCurrentSurface( EGL10.EGL_DRAW );
-	    if ( currSurface == EGL10.EGL_NO_SURFACE ) return;
+	    	EGLSurface currSurface = currEGL.eglGetCurrentSurface( EGL10.EGL_DRAW );
+	    	if ( currSurface == EGL10.EGL_NO_SURFACE ) return;
 
-	    currEGL.eglSwapBuffers( currDisplay, currSurface);
+	    	currEGL.eglSwapBuffers( currDisplay, currSurface);
+	    } catch ( Exception e ) { }
 	}
 
 	public void ShowKeyboard()
@@ -270,4 +272,4 @@ public class ZenGL extends GLSurfaceView
 			return true;
 		}
 	}
-}
+}

+ 10 - 8
headers/android/zengl/android/ZenGL.java

@@ -175,18 +175,20 @@ public class ZenGL extends GLSurfaceView
 		((Activity)getContext()).finish();
 		System.exit( 0 );
 	}
-	
+
 	public void SwapBuffers()
 	{
-	    EGL10 currEGL = (EGL10)EGLContext.getEGL();
+	    try {
+	    	EGL10 currEGL = (EGL10)EGLContext.getEGL();
 
-	    EGLDisplay currDisplay = currEGL.eglGetCurrentDisplay();
-	    if ( currDisplay == EGL10.EGL_NO_DISPLAY ) return;    
+	    	EGLDisplay currDisplay = currEGL.eglGetCurrentDisplay();
+	    	if ( currDisplay == EGL10.EGL_NO_DISPLAY ) return;    
 
-	    EGLSurface currSurface = currEGL.eglGetCurrentSurface( EGL10.EGL_DRAW );
-	    if ( currSurface == EGL10.EGL_NO_SURFACE ) return;
+	    	EGLSurface currSurface = currEGL.eglGetCurrentSurface( EGL10.EGL_DRAW );
+	    	if ( currSurface == EGL10.EGL_NO_SURFACE ) return;
 
-	    currEGL.eglSwapBuffers( currDisplay, currSurface);
+	    	currEGL.eglSwapBuffers( currDisplay, currSurface);
+	    } catch ( Exception e ) { }
 	}
 
 	public void ShowKeyboard()
@@ -270,4 +272,4 @@ public class ZenGL extends GLSurfaceView
 			return true;
 		}
 	}
-}
+}