summaryrefslogtreecommitdiffstats
path: root/maven/jp4da/jp4da-desktop/src
diff options
context:
space:
mode:
authorMark Raynsford <[email protected]>2012-12-02 22:46:30 +0000
committerMark Raynsford <[email protected]>2012-12-02 22:46:30 +0000
commit76da2b16bcb7b760660a9cf91cf6457acf526a6b (patch)
tree42d9e13ec8fc24a84a70e80b67153b7ba3834aec /maven/jp4da/jp4da-desktop/src
parentf24ce52d7fa62072df918b404cac1b090f92fc45 (diff)
Initial jp4da setup
Diffstat (limited to 'maven/jp4da/jp4da-desktop/src')
-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);
+ }
+ }
+}