diff --git a/project/sdl/sdl-1.3/src/video/android/SDL_androidvideo.c b/project/sdl/sdl-1.3/src/video/android/SDL_androidvideo.c index 180857883..aeb65671b 100644 --- a/project/sdl/sdl-1.3/src/video/android/SDL_androidvideo.c +++ b/project/sdl/sdl-1.3/src/video/android/SDL_androidvideo.c @@ -71,8 +71,11 @@ static SDL_ANDROID_ApplicationPutToBackgroundCallback_t appRestoredCallback = ap int SDL_ANDROID_CallJavaSwapBuffers() { - SDL_ANDROID_drawTouchscreenKeyboard(); - SDL_ANDROID_processAndroidTrackballDampening(); + if( !glContextLost ) + { + SDL_ANDROID_drawTouchscreenKeyboard(); + SDL_ANDROID_processAndroidTrackballDampening(); + } if( ! (*JavaEnv)->CallIntMethod( JavaEnv, JavaRenderer, JavaSwapBuffers ) ) return 0; if( glContextLost ) @@ -81,7 +84,6 @@ int SDL_ANDROID_CallJavaSwapBuffers() __android_log_print(ANDROID_LOG_INFO, "libSDL", "OpenGL context recreated, refreshing textures"); SDL_ANDROID_VideoContextRecreated(); appRestoredCallback(); - SDL_PrivateAppActive(1, SDL_APPACTIVE|SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS); } return 1; } @@ -120,6 +122,13 @@ JAVA_EXPORT_NAME(DemoRenderer_nativeGlContextLost) ( JNIEnv* env, jobject thiz SDL_ANDROID_VideoContextLost(); } +JNIEXPORT void JNICALL +JAVA_EXPORT_NAME(DemoRenderer_nativeGlContextRecreated) ( JNIEnv* env, jobject thiz ) +{ + __android_log_print(ANDROID_LOG_INFO, "libSDL", "OpenGL context recreated, sending SDL_ACTIVEEVENT"); + SDL_PrivateAppActive(0, SDL_APPACTIVE|SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS); +} + JNIEXPORT void JNICALL JAVA_EXPORT_NAME(DemoRenderer_nativeInitJavaCallbacks) ( JNIEnv* env, jobject thiz ) { diff --git a/project/src/Video.java b/project/src/Video.java index 148fa9222..7984a39c3 100644 --- a/project/src/Video.java +++ b/project/src/Video.java @@ -89,10 +89,13 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer { public DemoRenderer(Activity _context) { context = _context; - mGlContextLost = false; } public void onSurfaceCreated(GL10 gl, EGLConfig config) { + mGlSurfaceCreated = true; + if( mGlSurfaceCreated && ! mPaused && ! mFirstTimeStart ) + nativeGlContextRecreated(); + mFirstTimeStart = false; } public void onSurfaceChanged(GL10 gl, int w, int h) { @@ -100,6 +103,7 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer { } public void onSurfaceDestroyed() { + mGlSurfaceCreated = false; mGlContextLost = true; nativeGlContextLost(); }; @@ -145,6 +149,7 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer { private native void nativeResize(int w, int h); private native void nativeDone(); private native void nativeGlContextLost(); + public native void nativeGlContextRecreated(); private Activity context = null; @@ -153,6 +158,9 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer { private EGLSurface mEglSurface = null; private EGLContext mEglContext = null; private boolean mGlContextLost = false; + public boolean mGlSurfaceCreated = false; + public boolean mPaused = false; + private boolean mFirstTimeStart = true; } class DemoGLSurfaceView extends GLSurfaceView_SDL { @@ -186,11 +194,15 @@ class DemoGLSurfaceView extends GLSurfaceView_SDL { @Override public void onPause() { super.onPause(); + mRenderer.mPaused = true; }; @Override public void onResume() { super.onResume(); + mRenderer.mPaused = false; + if( mRenderer.mGlSurfaceCreated && ! mRenderer.mPaused ) + mRenderer.nativeGlContextRecreated(); }; @Override