summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java53
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java129
2 files changed, 88 insertions, 94 deletions
diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java b/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java
index 995a514f3..358fcc994 100644
--- a/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java
+++ b/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java
@@ -35,16 +35,32 @@ import com.jogamp.newt.opengl.GLWindow;
import jogamp.newt.driver.android.AndroidWindow;
import android.app.Activity;
+import android.content.Context;
import android.os.Bundle;
import android.util.Log;
public class NewtBaseActivity extends Activity {
+ boolean isInvokedByExternalActivity = false;
+ Activity extActivity = this;
+
+ public void setIsInvokedByExternalActivity(Activity extActivity) {
+ this.extActivity = extActivity;
+ this.isInvokedByExternalActivity = null != extActivity;
+ }
+ public boolean getIsInvokedByExternalActivity() {
+ return null != extActivity;
+ }
+
public void setContentView(Window window) {
if(window instanceof GLWindow) {
window = ((GLWindow)window).getWindow();
}
if(window instanceof AndroidWindow) {
- super.setContentView(((AndroidWindow)window).getView());
+ if(isInvokedByExternalActivity) {
+ extActivity.setContentView(((AndroidWindow)window).getView());
+ } else {
+ super.setContentView(((AndroidWindow)window).getView());
+ }
} else {
throw new IllegalArgumentException("Given NEWT Window is not an Android Window: "+window.getClass());
}
@@ -53,10 +69,13 @@ public class NewtBaseActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
Log.d(MD.TAG, "onCreate");
- super.onCreate(savedInstanceState);
-
- // register application context
- jogamp.common.os.android.StaticContext.setContext(getApplicationContext());
+ if(!isInvokedByExternalActivity) {
+ super.onCreate(savedInstanceState);
+ // register application context
+ jogamp.common.os.android.StaticContext.setContext(getApplicationContext());
+ } else {
+ jogamp.common.os.android.StaticContext.setContext(extActivity.getApplicationContext());
+ }
// init GLProfile
GLProfile.initSingleton(true);
@@ -65,36 +84,48 @@ public class NewtBaseActivity extends Activity {
@Override
public void onStart() {
Log.d(MD.TAG, "onStart");
- super.onStart();
+ if(!isInvokedByExternalActivity) {
+ super.onStart();
+ }
}
@Override
public void onRestart() {
Log.d(MD.TAG, "onRestart");
- super.onRestart();
+ if(!isInvokedByExternalActivity) {
+ super.onRestart();
+ }
}
@Override
public void onResume() {
Log.d(MD.TAG, "onResume");
- super.onResume();
+ if(!isInvokedByExternalActivity) {
+ super.onResume();
+ }
}
@Override
public void onPause() {
Log.d(MD.TAG, "onPause");
- super.onPause();
+ if(!isInvokedByExternalActivity) {
+ super.onPause();
+ }
}
@Override
public void onStop() {
Log.d(MD.TAG, "onStop");
- super.onStop();
+ if(!isInvokedByExternalActivity) {
+ super.onStop();
+ }
}
@Override
public void onDestroy() {
Log.d(MD.TAG, "onDestroy");
- super.onDestroy();
+ if(!isInvokedByExternalActivity) {
+ super.onDestroy();
+ }
}
}
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java
index 785590fd7..f2e82f4ab 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java
@@ -25,116 +25,79 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-package com.jogamp.android.launcher;
+package com.jogamp.opengl.test.android;
-import java.lang.reflect.Method;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLProfile;
-import dalvik.system.PathClassLoader;
+import jogamp.newt.driver.android.NewtBaseActivity;
+
+import com.jogamp.newt.ScreenMode;
+import com.jogamp.newt.event.ScreenModeListener;
+import com.jogamp.newt.opengl.GLWindow;
+
+import com.jogamp.opengl.test.junit.jogl.demos.es1.GearsES1;
+import com.jogamp.opengl.util.Animator;
-import android.app.Activity;
-import android.content.pm.PackageManager;
import android.os.Bundle;
-import android.widget.TextView;
import android.util.Log;
+import android.widget.TextView;
-public class NEWTLauncherGearsActivity extends Activity {
- static final String TAG = "JoglLauncherActivity";
+public class NEWTGearsES1Activity extends NewtBaseActivity {
+ GLWindow glWindow = null;
+ Animator animator = null;
TextView tv = null;
+ static String TAG = "NEWTGearsES1Activity";
@Override
public void onCreate(Bundle savedInstanceState) {
- Log.d(TAG, "onCreate - S");
+ Log.d(TAG, "onCreate - 0");
super.onCreate(savedInstanceState);
- String packageGlueGen = "com.jogamp.common";
- String apkGlueGen = null;
- String packageJogl = "javax.media.opengl";
- String apkJogl = null;
+ // create GLWindow (-> incl. underlying NEWT Display, Screen & Window)
+ GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES1));
+ Log.d(TAG, "req caps: "+caps);
+ glWindow = GLWindow.create(caps);
+ setContentView(glWindow);
+
+ glWindow.addGLEventListener(new GearsES1(1));
+ glWindow.getWindow().getScreen().addScreenModeListener(new ScreenModeListener() {
+ public void screenModeChangeNotify(ScreenMode sm) { }
+ public void screenModeChanged(ScreenMode sm, boolean success) {
+ System.err.println("ScreenMode Changed: "+sm);
+ }
+ });
+ glWindow.setVisible(true);
+ animator = new Animator(glWindow);
+ // animator.setUpdateFPSFrames(60, System.err);
- 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());
-
- try {
- Class clazzMD= Class.forName(clazzMDName, true, pathClassLoader);
- Log.d(TAG, "MD: "+clazzMD);
- mdGetInfo = clazzMD.getMethod("getInfo");
- } 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);
- } else {
- tv.setText("mdInfo n/a");
- }
- setContentView(tv);
Log.d(TAG, "onCreate - X");
}
@Override
- public void onStart() {
- Log.d(TAG, "onStart - S");
- super.onStart();
- Log.d(TAG, "onStart - X");
- }
-
- @Override
- public void onRestart() {
- Log.d(TAG, "onRestart - S");
- super.onRestart();
- Log.d(TAG, "onRestart - X");
- }
-
- @Override
public void onResume() {
- Log.d(TAG, "onResume - S");
super.onResume();
- Log.d(TAG, "onResume - X");
+ if(null != animator) {
+ animator.start();
+ }
}
@Override
public void onPause() {
- Log.d(TAG, "onPause - S");
+ if(null != animator) {
+ animator.pause();
+ }
super.onPause();
- Log.d(TAG, "onPause - X");
- }
-
- @Override
- public void onStop() {
- Log.d(TAG, "onStop - S");
- super.onStop();
- Log.d(TAG, "onStop - X");
}
@Override
public void onDestroy() {
- Log.d(TAG, "onDestroy - S");
- super.onDestroy();
- Log.d(TAG, "onDestroy - X");
+ if(null != animator) {
+ animator.stop();
+ }
+ if(null != glWindow) {
+ glWindow.destroy();
+ }
+ super.onDestroy();
}
}