aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/com/jogamp/opengl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-09-15 15:06:38 +0200
committerSven Gothel <[email protected]>2011-09-15 15:06:38 +0200
commitd341b3160c4af3bc1efb91c995abb44368f628a5 (patch)
tree6fd33fdef586c5c2edc2ca850c4d0ff123b9af1e /src/test/com/jogamp/opengl
parentbaa88fe536b0b8a70cadabe5412120a9168dec11 (diff)
Graph Demos: Make GLEvenListener 'standalone'; UIScene to common package; Cleanup
Diffstat (limited to 'src/test/com/jogamp/opengl')
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java3
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextGLListener0A.java20
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo01.java1
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo02.java1
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java7
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java (renamed from src/test/com/jogamp/opengl/test/junit/graph/demos/mobile/GPUGraphGLListenerMT.java)80
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo01.java (renamed from src/test/com/jogamp/opengl/test/junit/graph/demos/mobile/GPUTextNewtDemoMobile01.java)6
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/SceneUIController.java16
8 files changed, 74 insertions, 60 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java
index 7a10c4950..dac965df3 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java
@@ -180,11 +180,10 @@ public abstract class GPURendererListenerBase01 implements GLEventListener {
}
}
- public void detachFrom(GLWindow window) {
+ public void detachInputListenerFrom(GLWindow window) {
if ( null == keyAction ) {
return;
}
- window.removeGLEventListener(this);
window.removeKeyListener(keyAction);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextGLListener0A.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextGLListener0A.java
index 6d97505c4..da34b1d78 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextGLListener0A.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextGLListener0A.java
@@ -33,14 +33,26 @@ import javax.media.opengl.GLAutoDrawable;
import com.jogamp.graph.curve.opengl.RenderState;
import com.jogamp.graph.curve.opengl.TextRenderer;
+import com.jogamp.graph.geom.opengl.SVertex;
+import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.util.glsl.ShaderState;
public class GPUTextGLListener0A extends GPUTextRendererListenerBase01 {
+
+ public GPUTextGLListener0A() {
+ this( RenderState.createRenderState(new ShaderState(), SVertex.factory()), 0, 0, false, false ) ;
+ }
+
public GPUTextGLListener0A(RenderState rs, int numpass, int fbosize, boolean debug, boolean trace) {
super(rs, numpass, debug, trace);
setMatrix(-400, -30, 0f, -500, fbosize);
}
public void init(GLAutoDrawable drawable) {
+ if(drawable instanceof GLWindow) {
+ final GLWindow glw = (GLWindow) drawable;
+ attachInputListenerTo(glw);
+ }
super.init(drawable);
GL2ES2 gl = drawable.getGL().getGL2ES2();
@@ -54,4 +66,12 @@ public class GPUTextGLListener0A extends GPUTextRendererListenerBase01 {
textRenderer.setColorStatic(gl, 0.0f, 0.0f, 0.0f);
MSAATool.dump(drawable);
}
+
+ public void dispose(GLAutoDrawable drawable) {
+ if(drawable instanceof GLWindow) {
+ final GLWindow glw = (GLWindow) drawable;
+ detachInputListenerFrom(glw);
+ }
+ super.dispose(drawable);
+ }
}
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 b9a045498..bcd60d441 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
@@ -64,7 +64,6 @@ public class GPUTextNewtDemo01 {
final RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory());
GPUTextGLListener0A textGLListener = new GPUTextGLListener0A(rs, 0, 0, DEBUG, TRACE);
- textGLListener.attachInputListenerTo(window);
window.addGLEventListener(textGLListener);
window.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err);
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 d7dff5170..5981e7971 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
@@ -73,7 +73,6 @@ public class GPUTextNewtDemo02 {
RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory());
GPUTextGLListener0A textGLListener = new GPUTextGLListener0A(rs, Region.VBAA_RENDERING_BIT, window.getWidth()*3, DEBUG, TRACE);
// ((TextRenderer)textGLListener.getRenderer()).setCacheLimit(32);
- textGLListener.attachInputListenerTo(window);
window.addGLEventListener(textGLListener);
window.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err);
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 0fced4715..ad662e000 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
@@ -229,13 +229,12 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
keyAction = new KeyAction();
window.addKeyListener(keyAction);
super.attachInputListenerTo(window);
- }
-
+ }
}
@Override
- public void detachFrom(GLWindow window) {
- super.detachFrom(window);
+ public void detachInputListenerFrom(GLWindow window) {
+ super.detachInputListenerFrom(window);
if ( null == keyAction ) {
return;
}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/mobile/GPUGraphGLListenerMT.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java
index dc0bc68fd..476bbc04f 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/mobile/GPUGraphGLListenerMT.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java
@@ -1,6 +1,5 @@
-package com.jogamp.opengl.test.junit.graph.demos.mobile;
+package com.jogamp.opengl.test.junit.graph.demos;
-import javax.media.opengl.FPSCounter;
import javax.media.opengl.GL;
import javax.media.opengl.GL2ES2;
import javax.media.opengl.GLAnimatorControl;
@@ -14,15 +13,16 @@ import com.jogamp.graph.curve.opengl.RenderState;
import com.jogamp.graph.font.Font;
import com.jogamp.graph.font.FontFactory;
import com.jogamp.graph.geom.opengl.SVertex;
+import com.jogamp.newt.event.MouseAdapter;
import com.jogamp.newt.event.MouseEvent;
-import com.jogamp.newt.event.MouseListener;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.test.junit.graph.demos.ui.Label;
import com.jogamp.opengl.test.junit.graph.demos.ui.RIButton;
import com.jogamp.opengl.test.junit.graph.demos.ui.SceneUIController;
import com.jogamp.opengl.test.junit.graph.demos.ui.opengl.UIRegion;
+import com.jogamp.opengl.util.glsl.ShaderState;
-public class GPUGraphGLListenerMT implements GLEventListener {
+public class GPUUISceneGLListener0A implements GLEventListener {
private boolean debug = false;
private boolean trace = false;
@@ -50,9 +50,8 @@ public class GPUGraphGLListenerMT implements GLEventListener {
private int numSelectable = 6;
- private int mouseX, mouseY;
private SceneUIController sceneUIController = null;
-
+ private MultiTouchListener multiTouchListener = null;
private boolean showFPS = false;
private GLAutoDrawable cDrawable;
private float fps = 0;
@@ -60,7 +59,11 @@ public class GPUGraphGLListenerMT implements GLEventListener {
private String jogamp = "JogAmp - Jogl Graph Module Demo";
private float angText = 0;
- public GPUGraphGLListenerMT(RenderState rs, boolean debug, boolean trace) {
+ public GPUUISceneGLListener0A() {
+ this(RenderState.createRenderState(new ShaderState(), SVertex.factory()), false, false);
+ }
+
+ public GPUUISceneGLListener0A(RenderState rs, boolean debug, boolean trace) {
this.rs = rs;
this.debug = debug;
@@ -173,8 +176,11 @@ public class GPUGraphGLListenerMT implements GLEventListener {
labels = new Label[3];
}
- @Override
public void init(GLAutoDrawable drawable) {
+ if(drawable instanceof GLWindow) {
+ final GLWindow glw = (GLWindow) drawable;
+ attachInputListenerTo(glw);
+ }
final int width = drawable.getWidth();
final int height = drawable.getHeight();
cDrawable = drawable;
@@ -217,14 +223,17 @@ public class GPUGraphGLListenerMT implements GLEventListener {
jogampRegion = new UIRegion(jlabel);
}
- @Override
public void dispose(GLAutoDrawable drawable) {
+ if(drawable instanceof GLWindow) {
+ final GLWindow glw = (GLWindow) drawable;
+ detachInputListenerFrom(glw);
+ }
+
GL2ES2 gl = drawable.getGL().getGL2ES2();
sceneUIController = null;
regionRenderer.destroy(gl);
}
- @Override
public void display(GLAutoDrawable drawable) {
final int width = drawable.getWidth();
final int height = drawable.getHeight();
@@ -241,8 +250,6 @@ public class GPUGraphGLListenerMT implements GLEventListener {
}
private void renderScene(GLAutoDrawable drawable) {
- final int width = drawable.getWidth();
- final int height = drawable.getHeight();
GL2ES2 gl = drawable.getGL().getGL2ES2();
regionRenderer.resetModelview(null);
@@ -300,9 +307,7 @@ public class GPUGraphGLListenerMT implements GLEventListener {
}
}
- @Override
- public void reshape(GLAutoDrawable drawable, int x, int y, int width,
- int height) {
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
GL2ES2 gl = drawable.getGL().getGL2ES2();
gl.glViewport(x, y, width, height);
@@ -310,30 +315,29 @@ public class GPUGraphGLListenerMT implements GLEventListener {
}
public void attachInputListenerTo(GLWindow window) {
- MultiTouchListener multiTouchListener = new MultiTouchListener();
- window.addMouseListener(multiTouchListener);
- sceneUIController = new SceneUIController();
- window.addGLEventListener(sceneUIController);
- sceneUIController.attachInputListenerTo(window);
+ if ( null == multiTouchListener ) {
+ multiTouchListener = new MultiTouchListener();
+ window.addMouseListener(multiTouchListener);
+ sceneUIController = new SceneUIController();
+ window.addGLEventListener(sceneUIController);
+ sceneUIController.attachInputListenerTo(window);
+ }
+ }
+
+ public void detachInputListenerFrom(GLWindow window) {
+ if ( null != multiTouchListener ) {
+ window.removeMouseListener(multiTouchListener);
+ window.removeGLEventListener(sceneUIController);
+ sceneUIController.detachInputListenerFrom(window);
+ }
}
- private class MultiTouchListener implements MouseListener {
+ private class MultiTouchListener extends MouseAdapter {
int lx = 0;
int ly = 0;
boolean first = false;
- @Override
- public void mouseClicked(MouseEvent e) {
- }
-
- @Override
- public void mouseEntered(MouseEvent e) {
- }
-
- @Override
- public void mouseExited(MouseEvent e) {
- }
-
+
@Override
public void mousePressed(MouseEvent e) {
first = true;
@@ -345,11 +349,6 @@ public class GPUGraphGLListenerMT implements GLEventListener {
}
@Override
- public void mouseMoved(MouseEvent e) {
-
- }
-
- @Override
public void mouseDragged(MouseEvent e) {
if(first) {
lx = e.getX();
@@ -368,10 +367,5 @@ public class GPUGraphGLListenerMT implements GLEventListener {
lx = e.getX();
ly = e.getY();
}
-
- @Override
- public void mouseWheelMoved(MouseEvent e) {
-
- }
}
} \ No newline at end of file
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/mobile/GPUTextNewtDemoMobile01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo01.java
index 66f709595..14276ce44 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/mobile/GPUTextNewtDemoMobile01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo01.java
@@ -1,4 +1,4 @@
-package com.jogamp.opengl.test.junit.graph.demos.mobile;
+package com.jogamp.opengl.test.junit.graph.demos;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLProfile;
@@ -11,7 +11,7 @@ import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.util.glsl.ShaderState;
-public class GPUTextNewtDemoMobile01 {
+public class GPUUISceneNewtDemo01 {
static final boolean DEBUG = false;
static final boolean TRACE = false;
@@ -29,7 +29,7 @@ public class GPUTextNewtDemoMobile01 {
window.setTitle("GraphUI Newt Demo");
final RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory());
- GPUGraphGLListenerMT textGLListener = new GPUGraphGLListenerMT(rs, DEBUG, TRACE);
+ GPUUISceneGLListener0A textGLListener = new GPUUISceneGLListener0A(rs, DEBUG, TRACE);
window.addGLEventListener(textGLListener);
textGLListener.attachInputListenerTo(window);
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/SceneUIController.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/SceneUIController.java
index d3b1de827..9ee1c519e 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/SceneUIController.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/SceneUIController.java
@@ -52,10 +52,18 @@ public class SceneUIController implements GLEventListener{
}
public void attachInputListenerTo(GLWindow window) {
- sbcMouseListener = new SBCMouseListener();;
- window.addMouseListener(sbcMouseListener);
+ if(null == sbcMouseListener) {
+ sbcMouseListener = new SBCMouseListener();
+ window.addMouseListener(sbcMouseListener);
+ }
}
+ public void detachInputListenerFrom(GLWindow window) {
+ if(null != sbcMouseListener) {
+ window.removeMouseListener(sbcMouseListener);
+ }
+ }
+
public ArrayList<UIShape> getShapes() {
return shapes;
}
@@ -187,9 +195,6 @@ public class SceneUIController implements GLEventListener{
}
private class SBCMouseListener implements MouseListener {
- int lx = 0;
- int ly = 0;
- boolean selection = false;
int mouseX = -1;
int mouseY = -1;
@@ -201,7 +206,6 @@ public class SceneUIController implements GLEventListener{
}
public void mousePressed(MouseEvent e) {
- selection = true;
mouseX = e.getX();
mouseY = e.getY();