mirror of
https://github.com/yawut/SDL.git
synced 2026-09-08 00:56:24 -05:00
Fixes #1422, restores GL context automatically under Android
This commit is contained in:
@@ -68,17 +68,17 @@ public class SDLActivity extends Activity {
|
||||
}
|
||||
|
||||
// Events
|
||||
protected void onPause() {
|
||||
/*protected void onPause() {
|
||||
Log.v("SDL", "onPause()");
|
||||
super.onPause();
|
||||
SDLActivity.nativePause();
|
||||
// Don't call SDLActivity.nativePause(); here, it will be called by SDLSurface::surfaceDestroyed
|
||||
}
|
||||
|
||||
protected void onResume() {
|
||||
Log.v("SDL", "onResume()");
|
||||
super.onResume();
|
||||
SDLActivity.nativeResume();
|
||||
}
|
||||
// Don't call SDLActivity.nativeResume(); here, it will be called via SDLSurface::surfaceChanged->SDLActivity::startApp
|
||||
}*/
|
||||
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
@@ -249,12 +249,15 @@ public class SDLActivity extends Activity {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!egl.eglMakeCurrent(SDLActivity.mEGLDisplay, surface, surface, SDLActivity.mEGLContext)) {
|
||||
Log.e("SDL", "Old EGL Context doesnt work, trying with a new one");
|
||||
createEGLContext();
|
||||
if (egl.eglGetCurrentContext() != SDLActivity.mEGLContext) {
|
||||
if (!egl.eglMakeCurrent(SDLActivity.mEGLDisplay, surface, surface, SDLActivity.mEGLContext)) {
|
||||
Log.e("SDL", "Failed making EGL Context current");
|
||||
return false;
|
||||
Log.e("SDL", "Old EGL Context doesnt work, trying with a new one");
|
||||
// TODO: Notify the user via a message that the old context could not be restored, and that textures need to be manually restored.
|
||||
createEGLContext();
|
||||
if (!egl.eglMakeCurrent(SDLActivity.mEGLDisplay, surface, surface, SDLActivity.mEGLContext)) {
|
||||
Log.e("SDL", "Failed making EGL Context current");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
SDLActivity.mEGLSurface = surface;
|
||||
@@ -426,7 +429,6 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
|
||||
public void surfaceCreated(SurfaceHolder holder) {
|
||||
Log.v("SDL", "surfaceCreated()");
|
||||
holder.setType(SurfaceHolder.SURFACE_TYPE_GPU);
|
||||
SDLActivity.createEGLSurface();
|
||||
enableSensor(Sensor.TYPE_ACCELEROMETER, true);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user