summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--make/build.xml7
-rw-r--r--make/scripts/crosstest-launch-android-activity.sh17
-rw-r--r--src/android/com/jogamp/android/launcher/ClassLoaderUtil.java82
-rw-r--r--src/android/com/jogamp/android/launcher/NEWTLauncherVersionActivity.java40
-rw-r--r--src/newt/classes/jogamp/newt/driver/android/MD.java29
-rw-r--r--src/newt/classes/jogamp/newt/driver/android/NEWTSurfaceView.java62
-rw-r--r--src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java9
-rw-r--r--src/newt/classes/jogamp/newt/driver/android/SurfaceCallback.java54
8 files changed, 199 insertions, 101 deletions
diff --git a/make/build.xml b/make/build.xml
index d6214685f..971406f06 100644
--- a/make/build.xml
+++ b/make/build.xml
@@ -129,6 +129,7 @@
<path refid="nativewindow_core_atoms.classpath"/>
<path refid="jogl_all-mobile_atoms.classpath"/>
<path refid="newt_all-android_atoms.classpath"/>
+ <fileset dir="${build.gluegen}" includes="gluegen-rt.jar"/> <!-- JAU hack in gluegen -->
</zips>
</archives>
</jar>
@@ -147,6 +148,9 @@
</target>
<target name="android.package" depends="init,gluegen.cpptasks.detect.os,android.package.skip.check" if="isAndroid" unless="android.package.skip">
+ <copy todir="${lib}">
+ <fileset dir="${build.gluegen}/obj" includes="libgluegen-rt.so"/> <!-- JAU hack in gluegen -->
+ </copy>
<aapt.signed
jarbuilddir="${jar}"
jarbasename="jogl.all-android"
@@ -157,6 +161,9 @@
jarmanifest.path="${build.jogl}/manifest.mf"
version.code="${jogl_int_version}"
version.name="${jogl.version.plus}" />
+ <delete includeEmptyDirs="true" quiet="true" failonerror="false">
+ <fileset dir="${lib}" includes="libgluegen-rt.so" />
+ </delete>
</target>
<target name="android.launcher" depends="init,gluegen.cpptasks.detect.os" if="isAndroid">
diff --git a/make/scripts/crosstest-launch-android-activity.sh b/make/scripts/crosstest-launch-android-activity.sh
new file mode 100644
index 000000000..c67cbfa11
--- /dev/null
+++ b/make/scripts/crosstest-launch-android-activity.sh
@@ -0,0 +1,17 @@
+#! /bin/sh
+
+#adb uninstall com.jogamp.common
+#adb install ../../gluegen/build-android-armv7/gluegen-rt.apk
+
+adb uninstall javax.media.opengl
+adb install ../build-android-armv7/jar/jogl.all-android.apk
+
+adb shell "setprop log.redirect-stdio true ; setprop log.redirect-stderr true ; \
+ am start -a android.intent.action.MAIN -n javax.media.opengl/jogamp.newt.driver.android.NewtVersionActivity"
+
+#adb uninstall com.jogamp.android.launcher
+#adb install ../build-android-armv7/android/jar/jogllauncher.apk
+
+#adb shell "setprop log.redirect-stdio true ; setprop log.redirect-stderr true ; \
+# am start -a android.intent.action.MAIN -n com.jogamp.android.launcher/com.jogamp.android.launcher.NEWTLauncherVersionActivity"
+
diff --git a/src/android/com/jogamp/android/launcher/ClassLoaderUtil.java b/src/android/com/jogamp/android/launcher/ClassLoaderUtil.java
new file mode 100644
index 000000000..746fad745
--- /dev/null
+++ b/src/android/com/jogamp/android/launcher/ClassLoaderUtil.java
@@ -0,0 +1,82 @@
+/**
+ * Copyright 2011 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.android.launcher;
+
+import java.io.File;
+
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.util.Log;
+import dalvik.system.DexClassLoader;
+
+public class ClassLoaderUtil {
+ private static final String TAG = "JogampClassLoader";
+
+ public static final String packageGlueGen = "com.jogamp.common";
+ public static final String packageJogl = "javax.media.opengl";
+
+ public static final String dexPathName= "jogampDex";
+ public static final String libPathName = "/data/data/com.jogamp.common/lib/:/data/data/javax.media.opengl/lib/";
+
+ public static synchronized ClassLoader createJogampClassLoaderSingleton(Context ctx, boolean debugOn) {
+ Log.d(TAG, "S");
+
+ if(debugOn) {
+ System.setProperty("jogl.debug", "all");
+ System.setProperty("jogamp.debug.JNILibLoader", "true");
+ System.setProperty("jogamp.debug.NativeLibrary", "true");
+ }
+
+ String apkGlueGen = null;
+ String apkJogl = null;
+
+ try {
+ apkGlueGen = ctx.getPackageManager().getApplicationInfo(packageGlueGen,0).sourceDir;
+ apkJogl = ctx.getPackageManager().getApplicationInfo(packageJogl,0).sourceDir;
+ } catch (PackageManager.NameNotFoundException e) {
+ Log.d(TAG, "error: "+e, e);
+ }
+ if(null == apkGlueGen || null == apkJogl) {
+ Log.d(TAG, "not found: gluegen <"+apkGlueGen+">, jogl <"+apkJogl+">");
+ return null;
+ }
+
+ final String cp = apkGlueGen + ":" + apkJogl ;
+ Log.d(TAG, "cp: " + cp);
+
+ final File dexPath = ctx.getDir(dexPathName, Context.MODE_WORLD_READABLE);
+
+ ClassLoader cl = new DexClassLoader(cp, dexPath.getAbsolutePath(), libPathName, ctx.getClassLoader());
+ Log.d(TAG, "cl: " + cl);
+ // setAPKClassLoader(dexLoader);
+
+ return cl;
+ }
+
+}
diff --git a/src/android/com/jogamp/android/launcher/NEWTLauncherVersionActivity.java b/src/android/com/jogamp/android/launcher/NEWTLauncherVersionActivity.java
index 468beed0b..c07b502fb 100644
--- a/src/android/com/jogamp/android/launcher/NEWTLauncherVersionActivity.java
+++ b/src/android/com/jogamp/android/launcher/NEWTLauncherVersionActivity.java
@@ -29,6 +29,7 @@ package com.jogamp.android.launcher;
import java.lang.reflect.Method;
+import dalvik.system.DexClassLoader;
import dalvik.system.PathClassLoader;
import android.app.Activity;
@@ -46,46 +47,21 @@ public class NEWTLauncherVersionActivity extends Activity {
Log.d(TAG, "onCreate - S");
super.onCreate(savedInstanceState);
- String packageGlueGen = "com.jogamp.common";
- String apkGlueGen = null;
- String packageJogl = "javax.media.opengl";
- String apkJogl = null;
-
String clazzMDName= "jogamp.newt.driver.android.MD";
- Method mdGetInfo = null;
-
- try {
- apkGlueGen = getPackageManager().getApplicationInfo(packageGlueGen,0).sourceDir;
- apkJogl = getPackageManager().getApplicationInfo(packageJogl,0).sourceDir;
- } catch (PackageManager.NameNotFoundException e) {
- Log.d(TAG, "error: "+e, e);
- }
- if(null == apkGlueGen || null == apkJogl) {
- Log.d(TAG, "not found: gluegen <"+apkGlueGen+">, jogl <"+apkJogl+">");
- } else {
- String cp = apkGlueGen + ":" + apkJogl ;
- Log.d(TAG, "cp: " + cp);
-
- // add path to apk that contains classes you wish to load
- PathClassLoader pathClassLoader = new dalvik.system.PathClassLoader(
- cp,
- ClassLoader.getSystemClassLoader());
-
+ String mdInfo = null;
+
+ ClassLoader cl = ClassLoaderUtil.createJogampClassLoaderSingleton(this, true);
+ if(null != cl) {
try {
- Class clazzMD= Class.forName(clazzMDName, true, pathClassLoader);
+ Class clazzMD= Class.forName(clazzMDName, true, cl);
Log.d(TAG, "MD: "+clazzMD);
- mdGetInfo = clazzMD.getMethod("getInfo");
+ Method mdGetInfo = clazzMD.getMethod("getInfo");
+ mdInfo = (String) mdGetInfo.invoke(null);
} catch (Exception e) {
Log.d(TAG, "error: "+e, e);
}
}
- String mdInfo = null;
- try {
- mdInfo = (String) mdGetInfo.invoke(null);
- } catch (Exception e) {
- Log.d(TAG, "error: "+e, e);
- }
tv = new TextView(this);
if(null != mdInfo) {
tv.setText(mdInfo);
diff --git a/src/newt/classes/jogamp/newt/driver/android/MD.java b/src/newt/classes/jogamp/newt/driver/android/MD.java
index 9a2ed9824..06f787233 100644
--- a/src/newt/classes/jogamp/newt/driver/android/MD.java
+++ b/src/newt/classes/jogamp/newt/driver/android/MD.java
@@ -27,6 +27,11 @@
*/
package jogamp.newt.driver.android;
+import java.util.List;
+
+import javax.media.opengl.GLDrawableFactory;
+import javax.media.opengl.GLProfile;
+
import com.jogamp.common.GlueGenVersion;
import com.jogamp.common.os.Platform;
import com.jogamp.common.util.VersionUtil;
@@ -36,9 +41,25 @@ public class MD {
public static final String TAG = "JogAmp.NEWT";
public static String getInfo() {
- return VersionUtil.getPlatformInfo()+Platform.NEWLINE+
- GlueGenVersion.getInstance()+Platform.NEWLINE+
- JoglVersion.getInstance()+Platform.NEWLINE+
- Platform.NEWLINE;
+
+ StringBuffer sb = new StringBuffer();
+
+ sb.append(VersionUtil.getPlatformInfo()).append(Platform.NEWLINE)
+ .append(GlueGenVersion.getInstance()).append(Platform.NEWLINE)
+ .append(JoglVersion.getInstance()).append(Platform.NEWLINE)
+ .append(Platform.NEWLINE);
+
+ final GLDrawableFactory factory = GLDrawableFactory.getEGLFactory();
+ final List/*<GLCapabilitiesImmutable>*/ availCaps = factory.getAvailableCapabilities(null);
+ for(int i=0; i<availCaps.size(); i++) {
+ sb.append(availCaps.get(i)).append(Platform.NEWLINE);
+ }
+
+ return sb.toString();
}
+
+ public static void main(String args[]) {
+
+ System.err.println(getInfo());
+ }
}
diff --git a/src/newt/classes/jogamp/newt/driver/android/NEWTSurfaceView.java b/src/newt/classes/jogamp/newt/driver/android/NEWTSurfaceView.java
index 0a2cfcf05..8d163f874 100644
--- a/src/newt/classes/jogamp/newt/driver/android/NEWTSurfaceView.java
+++ b/src/newt/classes/jogamp/newt/driver/android/NEWTSurfaceView.java
@@ -27,19 +27,69 @@
*/
package jogamp.newt.driver.android;
+import javax.media.opengl.GLProfile;
+import javax.microedition.khronos.egl.EGL10;
+import javax.microedition.khronos.egl.EGLContext;
+import javax.microedition.khronos.egl.EGLDisplay;
+
import android.content.Context;
+import android.util.Log;
+import android.view.Surface;
+import android.view.SurfaceHolder;
import android.view.SurfaceView;
+import android.view.SurfaceHolder.Callback2;
-public class NEWTSurfaceView extends SurfaceView {
+public class NEWTSurfaceView extends SurfaceView implements Callback2 {
- SurfaceCallback scb;
-
public NEWTSurfaceView(Context context) {
super(context);
- scb = new SurfaceCallback();
- this.getHolder().addCallback(scb);
+
+ System.setProperty("jogl.debug", "all");
+ System.setProperty("jogamp.debug.JNILibLoader", "true");
+ System.setProperty("jogamp.debug.NativeLibrary", "true");
+ System.setProperty("jogamp.debug.NativeLibrary.Lookup", "true");
+ getHolder().addCallback(this);
}
- public void doSomething() {
+ boolean created = false;
+
+ public final boolean isCreated() {
+ return created;
+ }
+
+ public void surfaceCreated(SurfaceHolder holder) {
+ Surface surface = getHolder().getSurface();
+
+ /**
+ EGL10 mEgl = (EGL10) EGLContext.getEGL();
+
+ EGLDisplay mEglDisplay = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
+
+ if (mEglDisplay == EGL10.EGL_NO_DISPLAY) {
+ throw new RuntimeException("eglGetDisplay failed");
+ }
+ Log.d(MD.TAG, "EGL XXXXXX " + mEgl + ", " + mEglDisplay);
+ */
+ Log.d(MD.TAG, "YYYYYYYYYY ");
+ Log.d(MD.TAG, "surfaceCreated - 0 - isValid: "+surface.isValid());
+ GLProfile.initSingleton(true);
+ Log.d(MD.TAG, "surfaceCreated - 1");
+ Log.d(MD.TAG, MD.getInfo());
+ Log.d(MD.TAG, "surfaceCreated - X");
+ created = true;
+ }
+
+ public void surfaceChanged(SurfaceHolder holder, int format, int width,
+ int height) {
+ Log.d(MD.TAG, "surfaceChanged: f "+Integer.toString(format)+", "+width+"x"+height);
+ }
+
+ public void surfaceDestroyed(SurfaceHolder holder) {
+ Log.d(MD.TAG, "surfaceDestroyed");
+ created = false;
+ }
+
+ public void surfaceRedrawNeeded(SurfaceHolder holder) {
+ Log.d(MD.TAG, "surfaceRedrawNeeded");
}
}
diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java
index b9452e44b..011c0c223 100644
--- a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java
+++ b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java
@@ -33,15 +33,14 @@ import android.widget.TextView;
import android.util.Log;
public class NewtVersionActivity extends Activity {
- TextView tv = null;
-
+ NEWTSurfaceView nsv = null;
+
@Override
public void onCreate(Bundle savedInstanceState) {
Log.d(MD.TAG, "onCreate - S");
super.onCreate(savedInstanceState);
- tv = new TextView(this);
- tv.setText("need launcher");
- setContentView(tv);
+ nsv = new NEWTSurfaceView(this);
+ setContentView(nsv);
Log.d(MD.TAG, "onCreate - X");
}
diff --git a/src/newt/classes/jogamp/newt/driver/android/SurfaceCallback.java b/src/newt/classes/jogamp/newt/driver/android/SurfaceCallback.java
deleted file mode 100644
index f953fe41d..000000000
--- a/src/newt/classes/jogamp/newt/driver/android/SurfaceCallback.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * Copyright 2011 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-package jogamp.newt.driver.android;
-
-import jogamp.common.os.android.MD;
-import android.view.SurfaceHolder;
-import android.view.SurfaceHolder.Callback2;
-import android.util.Log;
-
-public class SurfaceCallback implements Callback2 {
-
- public void surfaceCreated(SurfaceHolder holder) {
- Log.d(MD.TAG, "surfaceCreated");
- }
-
- public void surfaceChanged(SurfaceHolder holder, int format, int width,
- int height) {
- Log.d(MD.TAG, "surfaceChanged: f "+Integer.toString(format)+", "+width+"x"+height);
- }
-
- public void surfaceDestroyed(SurfaceHolder holder) {
- Log.d(MD.TAG, "surfaceDestroyed");
- }
-
- public void surfaceRedrawNeeded(SurfaceHolder holder) {
- Log.d(MD.TAG, "surfaceRedrawNeeded");
- }
-
-}