From 76da2b16bcb7b760660a9cf91cf6457acf526a6b Mon Sep 17 00:00:00 2001 From: Mark Raynsford Date: Sun, 2 Dec 2012 22:46:30 +0000 Subject: Initial jp4da setup --- .../java/com/io7m/examples/jp4da/MainActivity.java | 67 ++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 maven/jp4da/jp4da-android/src/main/java/com/io7m/examples/jp4da/MainActivity.java (limited to 'maven/jp4da/jp4da-android/src/main') diff --git a/maven/jp4da/jp4da-android/src/main/java/com/io7m/examples/jp4da/MainActivity.java b/maven/jp4da/jp4da-android/src/main/java/com/io7m/examples/jp4da/MainActivity.java new file mode 100644 index 0000000..9a9dd77 --- /dev/null +++ b/maven/jp4da/jp4da-android/src/main/java/com/io7m/examples/jp4da/MainActivity.java @@ -0,0 +1,67 @@ +package com.io7m.examples.jp4da; + +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; + +import jogamp.newt.driver.android.NewtBaseActivity; +import android.os.Bundle; + +import com.jogamp.newt.ScreenMode; +import com.jogamp.newt.event.MouseAdapter; +import com.jogamp.newt.event.MouseEvent; +import com.jogamp.newt.event.ScreenModeListener; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.util.Animator; + +public class MainActivity extends NewtBaseActivity +{ + @Override public void onCreate( + final Bundle state) + { + super.onCreate(state); + + final GLCapabilities caps = + new GLCapabilities(GLProfile.get(GLProfile.GLES2)); + final GLWindow gl_window = GLWindow.create(caps); + gl_window.setFullscreen(true); + + this.setContentView(this.getWindow(), gl_window); + + gl_window.addMouseListener(new MouseAdapter() { + @Override public void mousePressed( + final MouseEvent e) + { + if (e.getPressure() > 2f) { // show Keyboard + ((com.jogamp.newt.Window) e.getSource()).setKeyboardVisible(true); + } + } + }); + + final Example example = new Example(); + + // demo.enableAndroidTrace(true); + gl_window.addGLEventListener(example); + gl_window.getScreen().addScreenModeListener(new ScreenModeListener() { + @SuppressWarnings("unused") public void screenModeChangeNotify( + final ScreenMode sm) + { + // Nothing. + } + + @SuppressWarnings("unused") public void screenModeChanged( + final ScreenMode sm, + final boolean success) + { + System.err.println("ScreenMode Changed: " + sm); + } + }); + + final Animator animator = new Animator(gl_window); + this.setAnimator(animator); + + gl_window.setVisible(true); + animator.setUpdateFPSFrames(60, System.err); + animator.resetFPSCounter(); + gl_window.resetFPSCounter(); + } +} -- cgit v1.2.3