summaryrefslogtreecommitdiffstats
path: root/src/newt/classes
diff options
context:
space:
mode:
Diffstat (limited to 'src/newt/classes')
-rw-r--r--src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java100
-rw-r--r--src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java50
2 files changed, 106 insertions, 44 deletions
diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java b/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java
new file mode 100644
index 000000000..995a514f3
--- /dev/null
+++ b/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java
@@ -0,0 +1,100 @@
+/**
+ * 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 javax.media.opengl.GLProfile;
+
+import com.jogamp.newt.Window;
+import com.jogamp.newt.opengl.GLWindow;
+
+import jogamp.newt.driver.android.AndroidWindow;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.util.Log;
+
+public class NewtBaseActivity extends Activity {
+ public void setContentView(Window window) {
+ if(window instanceof GLWindow) {
+ window = ((GLWindow)window).getWindow();
+ }
+ if(window instanceof AndroidWindow) {
+ super.setContentView(((AndroidWindow)window).getView());
+ } else {
+ throw new IllegalArgumentException("Given NEWT Window is not an Android Window: "+window.getClass());
+ }
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ Log.d(MD.TAG, "onCreate");
+ super.onCreate(savedInstanceState);
+
+ // register application context
+ jogamp.common.os.android.StaticContext.setContext(getApplicationContext());
+
+ // init GLProfile
+ GLProfile.initSingleton(true);
+ }
+
+ @Override
+ public void onStart() {
+ Log.d(MD.TAG, "onStart");
+ super.onStart();
+ }
+
+ @Override
+ public void onRestart() {
+ Log.d(MD.TAG, "onRestart");
+ super.onRestart();
+ }
+
+ @Override
+ public void onResume() {
+ Log.d(MD.TAG, "onResume");
+ super.onResume();
+ }
+
+ @Override
+ public void onPause() {
+ Log.d(MD.TAG, "onPause");
+ super.onPause();
+ }
+
+ @Override
+ public void onStop() {
+ Log.d(MD.TAG, "onStop");
+ super.onStop();
+ }
+
+ @Override
+ public void onDestroy() {
+ Log.d(MD.TAG, "onDestroy");
+ super.onDestroy();
+ }
+}
diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java
index 79065897e..4c9ccfbcd 100644
--- a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java
+++ b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java
@@ -34,6 +34,7 @@ import com.jogamp.newt.NewtFactory;
import com.jogamp.newt.Display;
import com.jogamp.newt.Screen;
import com.jogamp.newt.ScreenMode;
+import com.jogamp.newt.Window;
import com.jogamp.newt.event.ScreenModeListener;
import com.jogamp.newt.opengl.GLWindow;
import jogamp.newt.driver.android.test.GearsGL2ES1;
@@ -46,13 +47,14 @@ import android.content.res.Configuration;
import android.os.Bundle;
import android.util.Log;
import android.view.SurfaceView;
+import android.view.View;
-public class NewtVersionActivity extends Activity {
+public class NewtVersionActivity extends NewtBaseActivity {
GLWindow glWindow = null;
Animator animator = null;
+
@Override
public void onCreate(Bundle savedInstanceState) {
- Log.d(MD.TAG, "onCreate - S");
super.onCreate(savedInstanceState);
System.setProperty("nativewindow.debug", "all");
@@ -62,27 +64,14 @@ public class NewtVersionActivity extends Activity {
System.setProperty("jogamp.debug.NativeLibrary", "true");
// System.setProperty("jogamp.debug.NativeLibrary.Lookup", "true");
- // register application context
- jogamp.common.os.android.StaticContext.setContext(getApplicationContext());
-
- // init GLProfile
- GLProfile.initSingleton(true);
-
// create GLWindow (-> incl. underlying NEWT Display, Screen & Window)
GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES1));
glWindow = GLWindow.create(caps);
-
- {
- // use AndroidWindow's inner SurfaceView for this content view
- SurfaceView view = ((AndroidWindow) glWindow.getWindow()).getView();
- setContentView(view);
- }
+ setContentView(glWindow);
glWindow.addGLEventListener(new GearsGL2ES1(1));
glWindow.getWindow().getScreen().addScreenModeListener(new ScreenModeListener() {
- public void screenModeChangeNotify(ScreenMode sm) {
- }
-
+ public void screenModeChangeNotify(ScreenMode sm) { }
public void screenModeChanged(ScreenMode sm, boolean success) {
System.err.println("ScreenMode Changed: "+sm);
}
@@ -95,49 +84,23 @@ public class NewtVersionActivity extends Activity {
}
@Override
- public void onStart() {
- Log.d(MD.TAG, "onStart - S");
- super.onStart();
- Log.d(MD.TAG, "onStart - X");
- }
-
- @Override
- public void onRestart() {
- Log.d(MD.TAG, "onRestart - S");
- super.onRestart();
- Log.d(MD.TAG, "onRestart - X");
- }
-
- @Override
public void onResume() {
- Log.d(MD.TAG, "onResume - S");
super.onResume();
if(null != animator) {
animator.start();
}
- Log.d(MD.TAG, "onResume - X");
}
@Override
public void onPause() {
- Log.d(MD.TAG, "onPause - S");
super.onPause();
if(null != animator) {
animator.pause();
}
- Log.d(MD.TAG, "onPause - X");
- }
-
- @Override
- public void onStop() {
- Log.d(MD.TAG, "onStop - S");
- super.onStop();
- Log.d(MD.TAG, "onStop - X");
}
@Override
public void onDestroy() {
- Log.d(MD.TAG, "onDestroy - S");
super.onDestroy();
if(null != animator) {
animator.stop();
@@ -145,6 +108,5 @@ public class NewtVersionActivity extends Activity {
if(null != glWindow) {
glWindow.destroy();
}
- Log.d(MD.TAG, "onDestroy - X");
}
}