summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-04-26 07:54:11 +0200
committerSven Gothel <[email protected]>2011-04-26 07:54:11 +0200
commit2da29975e345fd3554436027f59b6f46ace22bcb (patch)
treefcf4890feb9c123a8558bbb747dd7f8c442b4223 /src
parent360b86f4b5d0e440863c1749fe990e39fbabc51c (diff)
Graph Demos: Add F4 key to exit; Proper exit sequence w/ animator.stop() after window is destroyed to exit the JVM
Diffstat (limited to 'src')
-rwxr-xr-xsrc/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo01.java22
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo02.java22
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo01.java30
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo02.java22
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java8
-rwxr-xr-xsrc/test/com/jogamp/opengl/test/junit/graph/demos/ui/UINewtDemo01.java22
6 files changed, 108 insertions, 18 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo01.java
index a7534dc01..7b9278591 100755
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo01.java
@@ -36,6 +36,10 @@ import com.jogamp.graph.curve.Region;
import com.jogamp.graph.curve.opengl.RenderState;
import com.jogamp.graph.curve.opengl.Renderer;
import com.jogamp.graph.geom.opengl.SVertex;
+import com.jogamp.newt.event.KeyAdapter;
+import com.jogamp.newt.event.KeyEvent;
+import com.jogamp.newt.event.WindowAdapter;
+import com.jogamp.newt.event.WindowEvent;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.util.glsl.ShaderState;
@@ -60,7 +64,7 @@ public class GPURegionNewtDemo01 {
caps.setNumSamples(4); // 2 samples is not enough ..
System.out.println("Requested: " + caps);
- GLWindow window = GLWindow.create(caps);
+ final GLWindow window = GLWindow.create(caps);
window.setPosition(10, 10);
window.setSize(800, 400);
window.setTitle("GPU Curve Region Newt Demo 01 - r2t0 msaa1");
@@ -74,9 +78,23 @@ public class GPURegionNewtDemo01 {
window.setVisible(true);
//FPSAnimator animator = new FPSAnimator(60);
- Animator animator = new Animator();
+ final Animator animator = new Animator();
animator.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err);
animator.add(window);
+
+ window.addKeyListener(new KeyAdapter() {
+ public void keyPressed(KeyEvent arg0) {
+ if(arg0.getKeyCode() == KeyEvent.VK_F4) {
+ window.destroy();
+ }
+ }
+ });
+ window.addWindowListener(new WindowAdapter() {
+ public void windowDestroyed(WindowEvent e) {
+ animator.stop();
+ }
+ });
+
animator.start();
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo02.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo02.java
index 9353e0c06..98978b39b 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo02.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo02.java
@@ -36,6 +36,10 @@ import com.jogamp.graph.curve.Region;
import com.jogamp.graph.curve.opengl.RenderState;
import com.jogamp.graph.curve.opengl.Renderer;
import com.jogamp.graph.geom.opengl.SVertex;
+import com.jogamp.newt.event.KeyAdapter;
+import com.jogamp.newt.event.KeyEvent;
+import com.jogamp.newt.event.WindowAdapter;
+import com.jogamp.newt.event.WindowEvent;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.util.glsl.ShaderState;
@@ -60,7 +64,7 @@ public class GPURegionNewtDemo02 {
caps.setAlphaBits(4);
System.out.println("Requested: " + caps);
- GLWindow window = GLWindow.create(caps);
+ final GLWindow window = GLWindow.create(caps);
window.setPosition(10, 10);
window.setSize(800, 400);
window.setTitle("GPU Curve Region Newt Demo 02 - r2t1 msaa0");
@@ -74,9 +78,23 @@ public class GPURegionNewtDemo02 {
window.setVisible(true);
//FPSAnimator animator = new FPSAnimator(60);
- Animator animator = new Animator();
+ final Animator animator = new Animator();
animator.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err);
animator.add(window);
+
+ window.addKeyListener(new KeyAdapter() {
+ public void keyPressed(KeyEvent arg0) {
+ if(arg0.getKeyCode() == KeyEvent.VK_F4) {
+ window.destroy();
+ }
+ }
+ });
+ window.addWindowListener(new WindowAdapter() {
+ public void windowDestroyed(WindowEvent e) {
+ animator.stop();
+ }
+ });
+
animator.start();
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo01.java
index 219438146..41761dbc0 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo01.java
@@ -36,6 +36,10 @@ import com.jogamp.graph.curve.Region;
import com.jogamp.graph.curve.opengl.RenderState;
import com.jogamp.graph.curve.opengl.Renderer;
import com.jogamp.graph.geom.opengl.SVertex;
+import com.jogamp.newt.event.KeyAdapter;
+import com.jogamp.newt.event.KeyEvent;
+import com.jogamp.newt.event.WindowAdapter;
+import com.jogamp.newt.event.WindowEvent;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.util.glsl.ShaderState;
@@ -53,22 +57,36 @@ public class GPUTextNewtDemo01 {
caps.setNumSamples(4); // 2 samples is not enough ..
System.out.println("Requested: "+caps);
- GLWindow window = GLWindow.create(caps);
+ final GLWindow window = GLWindow.create(caps);
window.setPosition(10, 10);
window.setSize(800, 400);
window.setTitle("GPU Text Newt Demo 01 - r2t0 msaa1");
- RenderState rs = Renderer.createRenderState(new ShaderState(), SVertex.factory());
+ final RenderState rs = Renderer.createRenderState(new ShaderState(), SVertex.factory());
GPUTextGLListener0A textGLListener = new GPUTextGLListener0A(rs, Region.SINGLE_PASS, 0, DEBUG, TRACE);
textGLListener.attachInputListenerTo(window);
window.addGLEventListener(textGLListener);
-
window.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err);
- window.setVisible(true);
- // FPSAnimator animator = new FPSAnimator(10);
- Animator animator = new Animator();
+
+ final Animator animator = new Animator();
animator.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err);
animator.add(window);
+
+ window.addKeyListener(new KeyAdapter() {
+ public void keyPressed(KeyEvent arg0) {
+ if(arg0.getKeyCode() == KeyEvent.VK_F4) {
+ window.destroy();
+ }
+ }
+ });
+ window.addWindowListener(new WindowAdapter() {
+ public void windowDestroyed(WindowEvent e) {
+ animator.stop();
+ }
+ });
+
+ window.setVisible(true);
+ // FPSAnimator animator = new FPSAnimator(10);
animator.start();
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo02.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo02.java
index cbe597508..6626ca2ad 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo02.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo02.java
@@ -36,6 +36,10 @@ import com.jogamp.graph.curve.opengl.RenderState;
import com.jogamp.graph.curve.opengl.Renderer;
import com.jogamp.graph.curve.opengl.TextRenderer;
import com.jogamp.graph.geom.opengl.SVertex;
+import com.jogamp.newt.event.KeyAdapter;
+import com.jogamp.newt.event.KeyEvent;
+import com.jogamp.newt.event.WindowAdapter;
+import com.jogamp.newt.event.WindowEvent;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.util.glsl.ShaderState;
@@ -62,7 +66,7 @@ public class GPUTextNewtDemo02 {
caps.setAlphaBits(4);
System.out.println("Requested: "+caps);
- GLWindow window = GLWindow.create(caps);
+ final GLWindow window = GLWindow.create(caps);
window.setPosition(10, 10);
window.setSize(800, 400);
@@ -77,9 +81,23 @@ public class GPUTextNewtDemo02 {
window.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err);
window.setVisible(true);
// FPSAnimator animator = new FPSAnimator(60);
- Animator animator = new Animator();
+ final Animator animator = new Animator();
animator.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err);
animator.add(window);
+
+ window.addKeyListener(new KeyAdapter() {
+ public void keyPressed(KeyEvent arg0) {
+ if(arg0.getKeyCode() == KeyEvent.VK_F4) {
+ window.destroy();
+ }
+ }
+ });
+ window.addWindowListener(new WindowAdapter() {
+ public void windowDestroyed(WindowEvent e) {
+ animator.stop();
+ }
+ });
+
animator.start();
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java
index 5811bc916..3f7ddfcef 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java
@@ -241,22 +241,22 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
return;
}
- if(arg0.getKeyCode() == KeyEvent.VK_3){
+ if(arg0.getKeyCode() == KeyEvent.VK_3) {
fontIncr(10);
}
- else if(arg0.getKeyCode() == KeyEvent.VK_4){
+ else if(arg0.getKeyCode() == KeyEvent.VK_4) {
fontIncr(-10);
}
else if(arg0.getKeyCode() == KeyEvent.VK_H) {
switchHeadBox();
}
- else if(arg0.getKeyCode() == KeyEvent.VK_F){
+ else if(arg0.getKeyCode() == KeyEvent.VK_F) {
drawFPS = !drawFPS;
}
else if(arg0.getKeyCode() == KeyEvent.VK_SPACE) {
nextFontSet();
}
- else if(arg0.getKeyCode() == KeyEvent.VK_I){
+ else if(arg0.getKeyCode() == KeyEvent.VK_I) {
userInput = true;
setIgnoreInput(true);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UINewtDemo01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UINewtDemo01.java
index 7d0ad83fa..1f4856426 100755
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UINewtDemo01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UINewtDemo01.java
@@ -35,6 +35,10 @@ import javax.media.opengl.GLProfile;
import com.jogamp.graph.curve.opengl.RenderState;
import com.jogamp.graph.curve.opengl.Renderer;
import com.jogamp.graph.geom.opengl.SVertex;
+import com.jogamp.newt.event.KeyAdapter;
+import com.jogamp.newt.event.KeyEvent;
+import com.jogamp.newt.event.WindowAdapter;
+import com.jogamp.newt.event.WindowEvent;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.util.glsl.ShaderState;
@@ -59,7 +63,7 @@ public class UINewtDemo01 {
caps.setNumSamples(4);
System.out.println("Requested: " + caps);
- GLWindow window = GLWindow.create(caps);
+ final GLWindow window = GLWindow.create(caps);
window.setPosition(10, 10);
window.setSize(800, 400);
window.setTitle("GPU UI Newt Demo 01");
@@ -71,9 +75,23 @@ public class UINewtDemo01 {
window.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err);
window.setVisible(true);
- Animator animator = new Animator();
+ final Animator animator = new Animator();
animator.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err);
animator.add(window);
+
+ window.addKeyListener(new KeyAdapter() {
+ public void keyPressed(KeyEvent arg0) {
+ if(arg0.getKeyCode() == KeyEvent.VK_F4) {
+ window.destroy();
+ }
+ }
+ });
+ window.addWindowListener(new WindowAdapter() {
+ public void windowDestroyed(WindowEvent e) {
+ animator.stop();
+ }
+ });
+
animator.start();
}
}