summaryrefslogtreecommitdiffstats
path: root/maven/jp4da/jp4da-desktop/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'maven/jp4da/jp4da-desktop/src/main/java')
-rw-r--r--maven/jp4da/jp4da-desktop/src/main/java/com/io7m/examples/jp4da/DesktopExample.java56
1 files changed, 56 insertions, 0 deletions
diff --git a/maven/jp4da/jp4da-desktop/src/main/java/com/io7m/examples/jp4da/DesktopExample.java b/maven/jp4da/jp4da-desktop/src/main/java/com/io7m/examples/jp4da/DesktopExample.java
new file mode 100644
index 0000000..d7df081
--- /dev/null
+++ b/maven/jp4da/jp4da-desktop/src/main/java/com/io7m/examples/jp4da/DesktopExample.java
@@ -0,0 +1,56 @@
+package com.io7m.examples.jp4da;
+
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLProfile;
+
+import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.util.FPSAnimator;
+
+public class DesktopExample implements Runnable
+{
+ public static void main(
+ final String args[])
+ {
+ final DesktopExample de = new DesktopExample(new Example());
+ de.run();
+ }
+
+ private final GLWindow window;
+ private final FPSAnimator animator;
+
+ private DesktopExample(
+ final GLEventListener gle)
+ {
+ final GLProfile pro = GLProfile.get(GLProfile.GL2GL3);
+ final GLCapabilities cap = new GLCapabilities(pro);
+
+ this.window = GLWindow.create(cap);
+ this.window.setSize(640, 480);
+ this.window.setTitle("Test1");
+ this.window.addGLEventListener(gle);
+ this.window.setVisible(true);
+
+ this.animator = new FPSAnimator(60);
+ this.animator.setUpdateFPSFrames(60, System.err);
+ this.animator.add(this.window);
+ this.animator.start();
+ }
+
+ @Override public void run()
+ {
+ try {
+ while (this.animator.isAnimating() && this.window.isVisible()) {
+ Thread.sleep(100);
+ }
+
+ this.animator.stop();
+ this.window.destroy();
+
+ System.err.println("Exiting...");
+ } catch (final InterruptedException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+}