diff --git a/build-test.sh b/build-test.sh
index 16070b42..c9a4e755 100644
--- a/build-test.sh
+++ b/build-test.sh
@@ -8,7 +8,7 @@ sh gen-version.sh test build
rm 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
-$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/
/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/*
diff --git a/jni/Application.mk b/jni/Application.mk
index 4fad7304..918e073f 100644
--- a/jni/Application.mk
+++ b/jni/Application.mk
@@ -11,9 +11,10 @@ APP_PLATFORM := android-8
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_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_HARDFP := -D_NDK_MATH_NO_SOFTFP=1 -mhard-float -mfloat-abi=hard -DLOAD_HARDFP -DSOFTFP_LINK
APPLICATIONMK_PATH = $(call my-dir)
diff --git a/jni/src/Xash3D/xash3d b/jni/src/Xash3D/xash3d
index ed8b3ea3..2e01bd5c 160000
--- a/jni/src/Xash3D/xash3d
+++ b/jni/src/Xash3D/xash3d
@@ -1 +1 @@
-Subproject commit ed8b3ea3a6eb80a20a43326c1ccb805f07ba28db
+Subproject commit 2e01bd5c41a21e36a7cfa1238661777fdcae2ff8
diff --git a/src/in/celest/xash3d/XashActivity.java b/src/in/celest/xash3d/XashActivity.java
index b1155710..22055c98 100644
--- a/src/in/celest/xash3d/XashActivity.java
+++ b/src/in/celest/xash3d/XashActivity.java
@@ -150,6 +150,8 @@ public class XashActivity extends Activity {
public static native void nativeString( String text );
public static native void onNativeAccel(float x, float y, float z);
public static native void nativeRunAudioThread();
+ public static native void nativeSetPause(int pause);
+
public static native int setenv(String key, String value, boolean overwrite);
@@ -163,6 +165,10 @@ public class XashActivity extends Activity {
mSurface.SwapBuffers();
}
+ public static void restoreEGL() {
+ mSurface.restoreEGL();
+ }
+
public static void setActivityTitle(String title) {
// Called from SDLMain() thread and can't directly affect the view
mSingleton.sendCommand(COMMAND_CHANGE_TITLE, title);
@@ -302,6 +308,8 @@ View.OnKeyListener {
private EGLContext mEGLContext;
private EGLSurface mEGLSurface;
private EGLDisplay mEGLDisplay;
+ private EGL10 mEGL;
+ private EGLConfig mEGLConfig;
// Sensors
@@ -323,26 +331,36 @@ View.OnKeyListener {
// Called when we have a valid drawing surface
public void surfaceCreated(SurfaceHolder holder) {
//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
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
- XashActivity.nativeQuit();
-
- // Now wait for the SDL thread to quit
- 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");
- }
+ //mEGL.eglWaitGL();
+ mEGL.eglMakeCurrent(mEGLDisplay, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);
+ mEGL.eglDestroySurface(mEGLDisplay, mEGLSurface);
+ // mEGLSurface = null;
}
// Called when the surface is resized
@@ -420,17 +438,52 @@ View.OnKeyListener {
int[] version = new int[2];
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_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_RED_SIZE, 5,
+ EGL10.EGL_GREEN_SIZE, 6,
EGL10.EGL_BLUE_SIZE, 5,
- EGL10.EGL_ALPHA_SIZE, 0,
EGL10.EGL_NONE
};
EGLConfig[] configs = new EGLConfig[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");
return false;
}
@@ -462,6 +515,8 @@ View.OnKeyListener {
mEGLContext = ctx;
mEGLDisplay = dpy;
mEGLSurface = surface;
+ mEGL = egl;
+ mEGLConfig = config;
} catch(Exception e) {
Log.v("SDL", e + "");
@@ -476,15 +531,13 @@ View.OnKeyListener {
// EGL buffer flip
public void SwapBuffers() {
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();
-
- egl.eglSwapBuffers(mEGLDisplay, mEGLSurface);
+ mEGL.eglSwapBuffers(mEGLDisplay, mEGLSurface);
} 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
public boolean onKey(View v, int keyCode, KeyEvent event) {
diff --git a/test/AndroidManifest.xml b/test/AndroidManifest.xml
index f894e0b5..fa9060a8 100644
--- a/test/AndroidManifest.xml
+++ b/test/AndroidManifest.xml
@@ -56,23 +56,23 @@
-
-
+
-
+ -->
diff --git a/src/org/libsdl/app/SDLActivity.java b/unused/org/libsdl/app/SDLActivity.java
similarity index 100%
rename from src/org/libsdl/app/SDLActivity.java
rename to unused/org/libsdl/app/SDLActivity.java