Implement EGL restore
This commit is contained in:
parent
5b0ee9679c
commit
69b11fcf38
6 changed files with 92 additions and 33 deletions
|
@ -8,7 +8,7 @@ sh gen-version.sh test build
|
||||||
rm assets/extras.pak
|
rm assets/extras.pak
|
||||||
python2.7 makepak.py xash-extras assets/extras.pak
|
python2.7 makepak.py xash-extras assets/extras.pak
|
||||||
$AAPT package -m -J gen/ --rename-manifest-package in.celest.xash3d.hl -M AndroidManifest.xml -S test/res -I $ANDROID_JAR
|
$AAPT package -m -J gen/ --rename-manifest-package in.celest.xash3d.hl -M AndroidManifest.xml -S test/res -I $ANDROID_JAR
|
||||||
$JAVA_HOME/bin/javac -d bin/classes -s bin/classes -cp $ANDROID_JAR src/org/libsdl/app/SDLActivity.java gen/in/celest/xash3d/hl/R.java src/in/celest/xash3d/*.java
|
$JAVA_HOME/bin/javac -d bin/classes -s bin/classes -cp $ANDROID_JAR gen/in/celest/xash3d/hl/R.java src/in/celest/xash3d/*.java
|
||||||
$DX --dex --output=bin/classes.dex bin/classes/
|
$DX --dex --output=bin/classes.dex bin/classes/
|
||||||
/mnt/app/apktool/aapt package -f -M test/AndroidManifest.xml -S test/res -I $ANDROID_JAR -F bin/xash3d.apk.unaligned
|
/mnt/app/apktool/aapt package -f -M test/AndroidManifest.xml -S test/res -I $ANDROID_JAR -F bin/xash3d.apk.unaligned
|
||||||
zip bin/xash3d.apk.unaligned assets/*
|
zip bin/xash3d.apk.unaligned assets/*
|
||||||
|
|
|
@ -11,9 +11,10 @@ APP_PLATFORM := android-8
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
CFLAGS_OPT := -O3 -fomit-frame-pointer -ggdb -funsafe-math-optimizations -ftree-vectorize -fgraphite-identity -floop-interchange -funsafe-loop-optimizations -finline-limit=1024
|
CFLAGS_OPT := -O3 -fomit-frame-pointer -ggdb -funsafe-math-optimizations -ftree-vectorize -fgraphite-identity -floop-interchange -funsafe-loop-optimizations -finline-limit=256 -pipe
|
||||||
CFLAGS_OPT_ARM := -mthumb -mfpu=neon -mcpu=cortex-a9 -pipe -mvectorize-with-neon-quad -DVECTORIZE_SINCOS -fPIC
|
CFLAGS_OPT_ARM := -mthumb -mfpu=neon -mcpu=cortex-a9 -pipe -mvectorize-with-neon-quad -DVECTORIZE_SINCOS -fPIC
|
||||||
CFLAGS_OPT_ARMv5 :=-march=armv5te -marm -pipe -msoft-float
|
#CFLAGS_OPT_ARMv5 :=-mcpu=arm1136jf-s -mtune=arm1136jf-s -mthumb -mfpu=vfp -pipe -mfloat-abi=softfp
|
||||||
|
CFLAGS_OPT_ARMv5 := -march=armv5te -mthumb -msoft-float
|
||||||
CFLAGS_OPT_X86 := -mtune=atom -march=atom -mssse3 -mfpmath=sse -funroll-loops -pipe -DVECTORIZE_SINCOS
|
CFLAGS_OPT_X86 := -mtune=atom -march=atom -mssse3 -mfpmath=sse -funroll-loops -pipe -DVECTORIZE_SINCOS
|
||||||
CFLAGS_HARDFP := -D_NDK_MATH_NO_SOFTFP=1 -mhard-float -mfloat-abi=hard -DLOAD_HARDFP -DSOFTFP_LINK
|
CFLAGS_HARDFP := -D_NDK_MATH_NO_SOFTFP=1 -mhard-float -mfloat-abi=hard -DLOAD_HARDFP -DSOFTFP_LINK
|
||||||
APPLICATIONMK_PATH = $(call my-dir)
|
APPLICATIONMK_PATH = $(call my-dir)
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit ed8b3ea3a6eb80a20a43326c1ccb805f07ba28db
|
Subproject commit 2e01bd5c41a21e36a7cfa1238661777fdcae2ff8
|
|
@ -150,6 +150,8 @@ public class XashActivity extends Activity {
|
||||||
public static native void nativeString( String text );
|
public static native void nativeString( String text );
|
||||||
public static native void onNativeAccel(float x, float y, float z);
|
public static native void onNativeAccel(float x, float y, float z);
|
||||||
public static native void nativeRunAudioThread();
|
public static native void nativeRunAudioThread();
|
||||||
|
public static native void nativeSetPause(int pause);
|
||||||
|
|
||||||
public static native int setenv(String key, String value, boolean overwrite);
|
public static native int setenv(String key, String value, boolean overwrite);
|
||||||
|
|
||||||
|
|
||||||
|
@ -163,6 +165,10 @@ public class XashActivity extends Activity {
|
||||||
mSurface.SwapBuffers();
|
mSurface.SwapBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void restoreEGL() {
|
||||||
|
mSurface.restoreEGL();
|
||||||
|
}
|
||||||
|
|
||||||
public static void setActivityTitle(String title) {
|
public static void setActivityTitle(String title) {
|
||||||
// Called from SDLMain() thread and can't directly affect the view
|
// Called from SDLMain() thread and can't directly affect the view
|
||||||
mSingleton.sendCommand(COMMAND_CHANGE_TITLE, title);
|
mSingleton.sendCommand(COMMAND_CHANGE_TITLE, title);
|
||||||
|
@ -302,6 +308,8 @@ View.OnKeyListener {
|
||||||
private EGLContext mEGLContext;
|
private EGLContext mEGLContext;
|
||||||
private EGLSurface mEGLSurface;
|
private EGLSurface mEGLSurface;
|
||||||
private EGLDisplay mEGLDisplay;
|
private EGLDisplay mEGLDisplay;
|
||||||
|
private EGL10 mEGL;
|
||||||
|
private EGLConfig mEGLConfig;
|
||||||
|
|
||||||
// Sensors
|
// Sensors
|
||||||
|
|
||||||
|
@ -323,26 +331,36 @@ View.OnKeyListener {
|
||||||
// Called when we have a valid drawing surface
|
// Called when we have a valid drawing surface
|
||||||
public void surfaceCreated(SurfaceHolder holder) {
|
public void surfaceCreated(SurfaceHolder holder) {
|
||||||
//Log.v("SDL", "surfaceCreated()");
|
//Log.v("SDL", "surfaceCreated()");
|
||||||
|
if( mEGL == null )
|
||||||
|
return;
|
||||||
|
XashActivity.nativeSetPause(0);
|
||||||
|
//mEGL = (EGL10)EGLContext.getEGL();
|
||||||
|
//mEGL.eglWaitNative(EGL10.EGL_CORE_NATIVE_ENGINE, null);
|
||||||
|
|
||||||
|
//mEGL.eglWaitGL();
|
||||||
|
//mEGL.eglDestroyContext(mEGLDisplay, mEGLContext);
|
||||||
|
int EGL_CONTEXT_CLIENT_VERSION=0x3098;
|
||||||
|
int contextAttrs[] = new int[]
|
||||||
|
{
|
||||||
|
EGL_CONTEXT_CLIENT_VERSION, 1,
|
||||||
|
EGL10.EGL_NONE
|
||||||
|
};
|
||||||
|
//mEGLContext = mEGL.eglCreateContext(mEGLDisplay, mEGLConfig, EGL10.EGL_NO_CONTEXT, contextAttrs);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called when we lose the surface
|
// Called when we lose the surface
|
||||||
public void surfaceDestroyed(SurfaceHolder holder) {
|
public void surfaceDestroyed(SurfaceHolder holder) {
|
||||||
//Log.v("SDL", "surfaceDestroyed()");
|
if( mEGL == null )
|
||||||
|
return;
|
||||||
|
XashActivity.nativeSetPause(1);
|
||||||
|
//mEGL = (EGL10)EGLContext.getEGL();
|
||||||
|
// mEGL.eglWaitNative(EGL10.EGL_CORE_NATIVE_ENGINE, null);
|
||||||
|
|
||||||
// Send a quit message to the application
|
//mEGL.eglWaitGL();
|
||||||
XashActivity.nativeQuit();
|
mEGL.eglMakeCurrent(mEGLDisplay, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);
|
||||||
|
mEGL.eglDestroySurface(mEGLDisplay, mEGLSurface);
|
||||||
// Now wait for the SDL thread to quit
|
// mEGLSurface = null;
|
||||||
if (mEngThread != null) {
|
|
||||||
try {
|
|
||||||
mEngThread.join();
|
|
||||||
} catch(Exception e) {
|
|
||||||
Log.v("SDL", "Problem stopping thread: " + e);
|
|
||||||
}
|
|
||||||
mEngThread = null;
|
|
||||||
|
|
||||||
//Log.v("SDL", "Finished waiting for SDL thread");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called when the surface is resized
|
// Called when the surface is resized
|
||||||
|
@ -420,17 +438,52 @@ View.OnKeyListener {
|
||||||
int[] version = new int[2];
|
int[] version = new int[2];
|
||||||
egl.eglInitialize(dpy, version);
|
egl.eglInitialize(dpy, version);
|
||||||
|
|
||||||
int[] configSpec = {
|
int[] configSpec1 = {
|
||||||
|
EGL10.EGL_DEPTH_SIZE, 8,
|
||||||
|
EGL10.EGL_RED_SIZE, 8,
|
||||||
|
EGL10.EGL_GREEN_SIZE, 8,
|
||||||
|
EGL10.EGL_BLUE_SIZE, 8,
|
||||||
|
EGL10.EGL_ALPHA_SIZE, 8,
|
||||||
|
EGL10.EGL_NONE
|
||||||
|
};
|
||||||
|
int[] configSpec2 = {
|
||||||
|
EGL10.EGL_DEPTH_SIZE, 8,
|
||||||
|
EGL10.EGL_RED_SIZE, 5,
|
||||||
|
EGL10.EGL_GREEN_SIZE, 6,
|
||||||
|
EGL10.EGL_BLUE_SIZE, 5,
|
||||||
|
EGL10.EGL_ALPHA_SIZE, 8,
|
||||||
|
EGL10.EGL_NONE
|
||||||
|
};
|
||||||
|
int[] configSpec3 = {
|
||||||
|
EGL10.EGL_DEPTH_SIZE, 8,
|
||||||
|
EGL10.EGL_RED_SIZE, 5,
|
||||||
|
EGL10.EGL_GREEN_SIZE, 6,
|
||||||
|
EGL10.EGL_BLUE_SIZE, 5,
|
||||||
|
EGL10.EGL_ALPHA_SIZE, 1,
|
||||||
|
EGL10.EGL_NONE
|
||||||
|
};
|
||||||
|
int[] configSpec4 = {
|
||||||
|
EGL10.EGL_DEPTH_SIZE, 8,
|
||||||
|
EGL10.EGL_RED_SIZE, 8,
|
||||||
|
EGL10.EGL_GREEN_SIZE, 8,
|
||||||
|
EGL10.EGL_BLUE_SIZE, 8,
|
||||||
|
EGL10.EGL_NONE
|
||||||
|
};
|
||||||
|
int[] configSpec5 = {
|
||||||
EGL10.EGL_DEPTH_SIZE, 8,
|
EGL10.EGL_DEPTH_SIZE, 8,
|
||||||
EGL10.EGL_RED_SIZE, 5,
|
EGL10.EGL_RED_SIZE, 5,
|
||||||
EGL10.EGL_GREEN_SIZE, 6,
|
EGL10.EGL_GREEN_SIZE, 6,
|
||||||
EGL10.EGL_BLUE_SIZE, 5,
|
EGL10.EGL_BLUE_SIZE, 5,
|
||||||
EGL10.EGL_ALPHA_SIZE, 0,
|
|
||||||
EGL10.EGL_NONE
|
EGL10.EGL_NONE
|
||||||
};
|
};
|
||||||
EGLConfig[] configs = new EGLConfig[1];
|
EGLConfig[] configs = new EGLConfig[1];
|
||||||
int[] num_config = new int[1];
|
int[] num_config = new int[1];
|
||||||
if (!egl.eglChooseConfig(dpy, configSpec, configs, 1, num_config) || num_config[0] == 0) {
|
if (!egl.eglChooseConfig(dpy, configSpec1, configs, 1, num_config) || num_config[0] == 0)
|
||||||
|
if (!egl.eglChooseConfig(dpy, configSpec2, configs, 1, num_config) || num_config[0] == 0)
|
||||||
|
if (!egl.eglChooseConfig(dpy, configSpec3, configs, 1, num_config) || num_config[0] == 0)
|
||||||
|
if (!egl.eglChooseConfig(dpy, configSpec4, configs, 1, num_config) || num_config[0] == 0)
|
||||||
|
if (!egl.eglChooseConfig(dpy, configSpec5, configs, 1, num_config) || num_config[0] == 0)
|
||||||
|
{
|
||||||
Log.e("SDL", "No EGL config available");
|
Log.e("SDL", "No EGL config available");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -462,6 +515,8 @@ View.OnKeyListener {
|
||||||
mEGLContext = ctx;
|
mEGLContext = ctx;
|
||||||
mEGLDisplay = dpy;
|
mEGLDisplay = dpy;
|
||||||
mEGLSurface = surface;
|
mEGLSurface = surface;
|
||||||
|
mEGL = egl;
|
||||||
|
mEGLConfig = config;
|
||||||
|
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
Log.v("SDL", e + "");
|
Log.v("SDL", e + "");
|
||||||
|
@ -476,15 +531,13 @@ View.OnKeyListener {
|
||||||
// EGL buffer flip
|
// EGL buffer flip
|
||||||
public void SwapBuffers() {
|
public void SwapBuffers() {
|
||||||
try {
|
try {
|
||||||
EGL10 egl = (EGL10)EGLContext.getEGL();
|
//EGL10 egl = (EGL10)EGLContext.getEGL();
|
||||||
|
|
||||||
egl.eglWaitNative(EGL10.EGL_CORE_NATIVE_ENGINE, null);
|
//egl.eglWaitNative(EGL10.EGL_CORE_NATIVE_ENGINE, null);
|
||||||
|
|
||||||
// drawing here
|
//egl.eglWaitGL();
|
||||||
|
|
||||||
egl.eglWaitGL();
|
mEGL.eglSwapBuffers(mEGLDisplay, mEGLSurface);
|
||||||
|
|
||||||
egl.eglSwapBuffers(mEGLDisplay, mEGLSurface);
|
|
||||||
|
|
||||||
|
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
|
@ -494,6 +547,11 @@ View.OnKeyListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void restoreEGL()
|
||||||
|
{
|
||||||
|
mEGLSurface = mEGL.eglCreateWindowSurface(mEGLDisplay, mEGLConfig, this, null);
|
||||||
|
mEGL.eglMakeCurrent(mEGLDisplay, mEGLSurface, mEGLSurface, mEGLContext);
|
||||||
|
}
|
||||||
|
|
||||||
// Key events
|
// Key events
|
||||||
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
||||||
|
|
|
@ -56,23 +56,23 @@
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name="in.celest.xash3d.FPicker"></activity>
|
<activity android:name="in.celest.xash3d.FPicker"></activity>
|
||||||
|
|
||||||
<activity android:name="org.libsdl.app.SDLActivity"
|
<!--<activity android:name="org.libsdl.app.SDLActivity"
|
||||||
android:screenOrientation="sensorLandscape"
|
android:screenOrientation="sensorLandscape"
|
||||||
android:configChanges="orientation|screenSize"
|
android:configChanges="orientation|screenSize"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:taskAffinity="org.libsdl.app.SDLActivity"
|
android:taskAffinity="org.libsdl.app.SDLActivity"
|
||||||
>
|
>
|
||||||
<!--<intent-filter>
|
<intent-filter>
|
||||||
As user can add now empty shortcut, disable this
|
As user can add now empty shortcut, disable this
|
||||||
<action android:name="org.libsdl.app.SDLActivity"/>
|
<action android:name="org.libsdl.app.SDLActivity"/>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>-->
|
</intent-filter>
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="in.celest.xash3d.START" />
|
<action android:name="in.celest.xash3d.START" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>-->
|
||||||
<activity android:name="in.celest.xash3d.XashActivity"
|
<activity android:name="in.celest.xash3d.XashActivity"
|
||||||
android:screenOrientation="landscape"
|
android:screenOrientation="landscape"
|
||||||
android:label="@string/app_name">
|
android:label="@string/app_name">
|
||||||
|
|
Loading…
Add table
Reference in a new issue