fixed bug in SDL_ACTIVEEVENT
This commit is contained in:
@@ -71,8 +71,11 @@ static SDL_ANDROID_ApplicationPutToBackgroundCallback_t appRestoredCallback = ap
|
|||||||
|
|
||||||
int SDL_ANDROID_CallJavaSwapBuffers()
|
int SDL_ANDROID_CallJavaSwapBuffers()
|
||||||
{
|
{
|
||||||
SDL_ANDROID_drawTouchscreenKeyboard();
|
if( !glContextLost )
|
||||||
SDL_ANDROID_processAndroidTrackballDampening();
|
{
|
||||||
|
SDL_ANDROID_drawTouchscreenKeyboard();
|
||||||
|
SDL_ANDROID_processAndroidTrackballDampening();
|
||||||
|
}
|
||||||
if( ! (*JavaEnv)->CallIntMethod( JavaEnv, JavaRenderer, JavaSwapBuffers ) )
|
if( ! (*JavaEnv)->CallIntMethod( JavaEnv, JavaRenderer, JavaSwapBuffers ) )
|
||||||
return 0;
|
return 0;
|
||||||
if( glContextLost )
|
if( glContextLost )
|
||||||
@@ -81,7 +84,6 @@ int SDL_ANDROID_CallJavaSwapBuffers()
|
|||||||
__android_log_print(ANDROID_LOG_INFO, "libSDL", "OpenGL context recreated, refreshing textures");
|
__android_log_print(ANDROID_LOG_INFO, "libSDL", "OpenGL context recreated, refreshing textures");
|
||||||
SDL_ANDROID_VideoContextRecreated();
|
SDL_ANDROID_VideoContextRecreated();
|
||||||
appRestoredCallback();
|
appRestoredCallback();
|
||||||
SDL_PrivateAppActive(1, SDL_APPACTIVE|SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS);
|
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -120,6 +122,13 @@ JAVA_EXPORT_NAME(DemoRenderer_nativeGlContextLost) ( JNIEnv* env, jobject thiz
|
|||||||
SDL_ANDROID_VideoContextLost();
|
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
|
JNIEXPORT void JNICALL
|
||||||
JAVA_EXPORT_NAME(DemoRenderer_nativeInitJavaCallbacks) ( JNIEnv* env, jobject thiz )
|
JAVA_EXPORT_NAME(DemoRenderer_nativeInitJavaCallbacks) ( JNIEnv* env, jobject thiz )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -89,10 +89,13 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer {
|
|||||||
public DemoRenderer(Activity _context)
|
public DemoRenderer(Activity _context)
|
||||||
{
|
{
|
||||||
context = _context;
|
context = _context;
|
||||||
mGlContextLost = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
|
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) {
|
public void onSurfaceChanged(GL10 gl, int w, int h) {
|
||||||
@@ -100,6 +103,7 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onSurfaceDestroyed() {
|
public void onSurfaceDestroyed() {
|
||||||
|
mGlSurfaceCreated = false;
|
||||||
mGlContextLost = true;
|
mGlContextLost = true;
|
||||||
nativeGlContextLost();
|
nativeGlContextLost();
|
||||||
};
|
};
|
||||||
@@ -145,6 +149,7 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer {
|
|||||||
private native void nativeResize(int w, int h);
|
private native void nativeResize(int w, int h);
|
||||||
private native void nativeDone();
|
private native void nativeDone();
|
||||||
private native void nativeGlContextLost();
|
private native void nativeGlContextLost();
|
||||||
|
public native void nativeGlContextRecreated();
|
||||||
|
|
||||||
private Activity context = null;
|
private Activity context = null;
|
||||||
|
|
||||||
@@ -153,6 +158,9 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer {
|
|||||||
private EGLSurface mEglSurface = null;
|
private EGLSurface mEglSurface = null;
|
||||||
private EGLContext mEglContext = null;
|
private EGLContext mEglContext = null;
|
||||||
private boolean mGlContextLost = false;
|
private boolean mGlContextLost = false;
|
||||||
|
public boolean mGlSurfaceCreated = false;
|
||||||
|
public boolean mPaused = false;
|
||||||
|
private boolean mFirstTimeStart = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
class DemoGLSurfaceView extends GLSurfaceView_SDL {
|
class DemoGLSurfaceView extends GLSurfaceView_SDL {
|
||||||
@@ -186,11 +194,15 @@ class DemoGLSurfaceView extends GLSurfaceView_SDL {
|
|||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
mRenderer.mPaused = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
mRenderer.mPaused = false;
|
||||||
|
if( mRenderer.mGlSurfaceCreated && ! mRenderer.mPaused )
|
||||||
|
mRenderer.nativeGlContextRecreated();
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user