Jogamp
Bug 682 - Relocating javax.media.opengl.* -> com.jogamp.opengl.* (Part 2)
[jogl-demos.git] / maven / jp4da / jp4da-android / src / main / java / com / io7m / examples / jp4da / MainActivity.java
CommitLineData
76da2b16
MR
1package com.io7m.examples.jp4da;
2
60675480
SG
3import com.jogamp.opengl.GLCapabilities;
4import com.jogamp.opengl.GLProfile;
76da2b16
MR
5
6import jogamp.newt.driver.android.NewtBaseActivity;
7import android.os.Bundle;
8
9import com.jogamp.newt.ScreenMode;
10import com.jogamp.newt.event.MouseAdapter;
11import com.jogamp.newt.event.MouseEvent;
12import com.jogamp.newt.event.ScreenModeListener;
13import com.jogamp.newt.opengl.GLWindow;
14import com.jogamp.opengl.util.Animator;
15
16public class MainActivity extends NewtBaseActivity
17{
18 @Override public void onCreate(
19 final Bundle state)
20 {
21 super.onCreate(state);
22
23 final GLCapabilities caps =
24 new GLCapabilities(GLProfile.get(GLProfile.GLES2));
25 final GLWindow gl_window = GLWindow.create(caps);
26 gl_window.setFullscreen(true);
27
28 this.setContentView(this.getWindow(), gl_window);
29
30 gl_window.addMouseListener(new MouseAdapter() {
31 @Override public void mousePressed(
32 final MouseEvent e)
33 {
34 if (e.getPressure() > 2f) { // show Keyboard
35 ((com.jogamp.newt.Window) e.getSource()).setKeyboardVisible(true);
36 }
37 }
38 });
39
40 final Example example = new Example();
41
42 // demo.enableAndroidTrace(true);
43 gl_window.addGLEventListener(example);
44 gl_window.getScreen().addScreenModeListener(new ScreenModeListener() {
45 @SuppressWarnings("unused") public void screenModeChangeNotify(
46 final ScreenMode sm)
47 {
48 // Nothing.
49 }
50
51 @SuppressWarnings("unused") public void screenModeChanged(
52 final ScreenMode sm,
53 final boolean success)
54 {
55 System.err.println("ScreenMode Changed: " + sm);
56 }
57 });
58
59 final Animator animator = new Animator(gl_window);
60 this.setAnimator(animator);
61
62 gl_window.setVisible(true);
63 animator.setUpdateFPSFrames(60, System.err);
64 animator.resetFPSCounter();
65 gl_window.resetFPSCounter();
66 }
67}
http://JogAmp.org git info: FAQ, tutorial and man pages.