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
|
||||
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/*
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 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) {
|
||||
|
|
|
@ -56,23 +56,23 @@
|
|||
</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:configChanges="orientation|screenSize"
|
||||
android:label="@string/app_name"
|
||||
android:taskAffinity="org.libsdl.app.SDLActivity"
|
||||
>
|
||||
<!--<intent-filter>
|
||||
<intent-filter>
|
||||
As user can add now empty shortcut, disable this
|
||||
<action android:name="org.libsdl.app.SDLActivity"/>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>-->
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="in.celest.xash3d.START" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</activity>-->
|
||||
<activity android:name="in.celest.xash3d.XashActivity"
|
||||
android:screenOrientation="landscape"
|
||||
android:label="@string/app_name">
|
||||
|
|
Loading…
Add table
Reference in a new issue