diff options
Diffstat (limited to 'src/newt/classes')
-rw-r--r-- | src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java | 28 | ||||
-rw-r--r-- | src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java | 49 |
2 files changed, 26 insertions, 51 deletions
diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java b/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java index 358fcc994..9a2a0ea2c 100644 --- a/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java +++ b/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java @@ -31,15 +31,18 @@ import javax.media.opengl.GLProfile; import com.jogamp.newt.Window; import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.util.Animator; 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 { + AndroidWindow window = null; + Animator animator = null; + boolean isInvokedByExternalActivity = false; Activity extActivity = this; @@ -56,16 +59,21 @@ public class NewtBaseActivity extends Activity { window = ((GLWindow)window).getWindow(); } if(window instanceof AndroidWindow) { + this.window = (AndroidWindow)window; if(isInvokedByExternalActivity) { - extActivity.setContentView(((AndroidWindow)window).getView()); + extActivity.setContentView(this.window.getView()); } else { - super.setContentView(((AndroidWindow)window).getView()); + super.setContentView(this.window.getView()); } } else { throw new IllegalArgumentException("Given NEWT Window is not an Android Window: "+window.getClass()); } } + public void setAnimator(Animator animator) { + this.animator = animator; + } + @Override public void onCreate(Bundle savedInstanceState) { Log.d(MD.TAG, "onCreate"); @@ -103,11 +111,17 @@ public class NewtBaseActivity extends Activity { if(!isInvokedByExternalActivity) { super.onResume(); } + if(null != animator) { + animator.start(); + } } @Override public void onPause() { Log.d(MD.TAG, "onPause"); + if(null != animator) { + animator.pause(); + } if(!isInvokedByExternalActivity) { super.onPause(); } @@ -124,6 +138,14 @@ public class NewtBaseActivity extends Activity { @Override public void onDestroy() { Log.d(MD.TAG, "onDestroy"); + if(null != animator) { + animator.stop(); + animator = null; + } + if(null != window) { + window.destroy(); + window = null; + } if(!isInvokedByExternalActivity) { 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 5842a285d..d37901793 100644 --- a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java +++ b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java @@ -30,17 +30,13 @@ package jogamp.newt.driver.android; import com.jogamp.common.GlueGenVersion; import com.jogamp.common.os.Platform; import com.jogamp.common.util.VersionUtil; -import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.JoglVersion; -import com.jogamp.opengl.util.Animator; import android.os.Bundle; import android.util.Log; import android.widget.TextView; public class NewtVersionActivity extends NewtBaseActivity { - GLWindow glWindow = null; - Animator animator = null; TextView tv = null; @Override @@ -57,50 +53,7 @@ public class NewtVersionActivity extends NewtBaseActivity { tv = new TextView(this); tv.setText(VersionUtil.getPlatformInfo()+Platform.NEWLINE+GlueGenVersion.getInstance()+Platform.NEWLINE+JoglVersion.getInstance()+Platform.NEWLINE); setContentView(tv); - /** - // create GLWindow (-> incl. underlying NEWT Display, Screen & Window) - GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES1)); - 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); */ - - Log.d(MD.TAG, "onCreate - X"); - } - - @Override - public void onResume() { - super.onResume(); - if(null != animator) { - animator.start(); - } - } - @Override - public void onPause() { - super.onPause(); - if(null != animator) { - animator.pause(); - } - } - - @Override - public void onDestroy() { - super.onDestroy(); - if(null != animator) { - animator.stop(); - } - if(null != glWindow) { - glWindow.destroy(); - } + Log.d(MD.TAG, "onCreate - X"); } } |