diff options
author | Sven Gothel <[email protected]> | 2009-09-14 11:45:30 -0700 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2009-09-14 11:45:30 -0700 |
commit | 0afab6a652471cf1c140d3affe6ae442ab217ff1 (patch) | |
tree | b515e3913c878ccb07c4c246be06c51b91200469 /src/demos | |
parent | e7003e596519e225ecec5b4423314c4dcaa05db8 (diff) |
Fixes and tested JOGLNewtApplet1Run/JOGLNewtAppletBase
Diffstat (limited to 'src/demos')
-rwxr-xr-x | src/demos/applets/JOGLNewtApplet1Run.java | 16 | ||||
-rwxr-xr-x | src/demos/applets/JOGLNewtAppletBase.java | 36 | ||||
-rwxr-xr-x | src/demos/es1/angeles/AngelesES1.java | 4 | ||||
-rwxr-xr-x | src/demos/es1/angeles/AngelesGL.java | 4 | ||||
-rwxr-xr-x | src/demos/es1/cubefbo/FBCubes.java | 2 |
5 files changed, 41 insertions, 21 deletions
diff --git a/src/demos/applets/JOGLNewtApplet1Run.java b/src/demos/applets/JOGLNewtApplet1Run.java index 08522de..6ea3251 100755 --- a/src/demos/applets/JOGLNewtApplet1Run.java +++ b/src/demos/applets/JOGLNewtApplet1Run.java @@ -2,6 +2,9 @@ package demos.applets; import java.applet.*; import java.awt.Container; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionListener; +import java.awt.event.KeyListener; import javax.media.opengl.*; import javax.media.nativewindow.*; @@ -60,6 +63,19 @@ public class JOGLNewtApplet1Run extends Applet { if(null!=nWindow) { base.init(nWindow); } + if(base.isValid()) { + GLEventListener glEventListener = base.getGLEventListener(); + + if(glEventListener instanceof MouseListener) { + addMouseListener((MouseListener)glEventListener); + } + if(glEventListener instanceof MouseMotionListener) { + addMouseMotionListener((MouseMotionListener)glEventListener); + } + if(glEventListener instanceof KeyListener) { + addKeyListener((KeyListener)glEventListener); + } + } } catch (Throwable t) { throw new RuntimeException(t); } diff --git a/src/demos/applets/JOGLNewtAppletBase.java b/src/demos/applets/JOGLNewtAppletBase.java index a1ea482..4246e4a 100755 --- a/src/demos/applets/JOGLNewtAppletBase.java +++ b/src/demos/applets/JOGLNewtAppletBase.java @@ -21,10 +21,10 @@ public class JOGLNewtAppletBase implements WindowListener, KeyListener, MouseLis boolean glDebug; boolean glTrace; + GLEventListener glEventListener = null; GLWindow glWindow = null; Animator glAnimator=null; boolean isValid = false; - boolean quit = false; public JOGLNewtAppletBase(String glEventListenerClazzName, String glProfileName, @@ -43,10 +43,10 @@ public class JOGLNewtAppletBase implements WindowListener, KeyListener, MouseLis this.glTrace = glTrace; } + public GLEventListener getGLEventListener() { return glEventListener; } public GLWindow getGLWindow() { return glWindow; } public Animator getGLAnimator() { return glAnimator; } public boolean isValid() { return isValid; } - public boolean shouldQuit() { return quit; } public static boolean str2Bool(String str, boolean def) { if(null==str) return def; @@ -101,7 +101,7 @@ public class JOGLNewtAppletBase implements WindowListener, KeyListener, MouseLis } public void init(Window nWindow) { - GLEventListener glEventListener = createInstance(glEventListenerClazzName); + glEventListener = createInstance(glEventListenerClazzName); try { glWindow = GLWindow.create(nWindow); @@ -112,9 +112,22 @@ public class JOGLNewtAppletBase implements WindowListener, KeyListener, MouseLis glWindow.addGLEventListener(this); glWindow.addGLEventListener(glEventListener); + + if(glEventListener instanceof WindowListener) { + glWindow.addWindowListener((WindowListener)glEventListener); + } glWindow.addWindowListener(this); + + if(glEventListener instanceof MouseListener) { + glWindow.addMouseListener((MouseListener)glEventListener); + } glWindow.addMouseListener(this); + + if(glEventListener instanceof KeyListener) { + glWindow.addKeyListener((KeyListener)glEventListener); + } glWindow.addKeyListener(this); + glWindow.setEventHandlerMode( useGLInEventHandler ? GLWindow.EVENT_HANDLER_GL_CURRENT : GLWindow.EVENT_HANDLER_GL_NONE ); glWindow.setRunPumpMessages(handleWindowEvents); glWindow.setVisible(true); @@ -141,7 +154,6 @@ public class JOGLNewtAppletBase implements WindowListener, KeyListener, MouseLis } public void destroy() { - quit = true; isValid = false; if(null!=glAnimator) { glAnimator.stop(); @@ -196,7 +208,6 @@ public class JOGLNewtAppletBase implements WindowListener, KeyListener, MouseLis } public void windowDestroyNotify(WindowEvent e) { - quit=true; } public void windowGainedFocus(WindowEvent e) { } public void windowLostFocus(WindowEvent e) { } @@ -207,11 +218,6 @@ public class JOGLNewtAppletBase implements WindowListener, KeyListener, MouseLis public void keyPressed(KeyEvent e) { System.out.println(e); - if(e.getKeyChar()=='f') { - glWindow.setFullscreen(!glWindow.isFullscreen()); - } else if(e.getKeyChar()=='q') { - quit = true; - } } public void keyReleased(KeyEvent e) { System.out.println(e); @@ -226,16 +232,6 @@ public class JOGLNewtAppletBase implements WindowListener, KeyListener, MouseLis public void mouseClicked(MouseEvent e) { System.out.println(" mouseevent: "+e); - switch(e.getClickCount()) { - case 1: - if(e.getButton()>MouseEvent.BUTTON1) { - glWindow.setFullscreen(!glWindow.isFullscreen()); - } - break; - default: - quit=true; - break; - } } public void mouseEntered(MouseEvent e) { } diff --git a/src/demos/es1/angeles/AngelesES1.java b/src/demos/es1/angeles/AngelesES1.java index c5de891..bfb4a78 100755 --- a/src/demos/es1/angeles/AngelesES1.java +++ b/src/demos/es1/angeles/AngelesES1.java @@ -31,6 +31,10 @@ import java.nio.*; public class AngelesES1 implements GLEventListener { + public AngelesES1() { + this(true); + } + public AngelesES1(boolean enableBlending) { blendingEnabled = enableBlending; quadVertices = BufferUtil.newIntBuffer(12); diff --git a/src/demos/es1/angeles/AngelesGL.java b/src/demos/es1/angeles/AngelesGL.java index bae7b5c..12206de 100755 --- a/src/demos/es1/angeles/AngelesGL.java +++ b/src/demos/es1/angeles/AngelesGL.java @@ -32,6 +32,10 @@ import java.nio.*; public class AngelesGL implements GLEventListener { + public AngelesGL() { + this(true); + } + public AngelesGL(boolean enableBlending) { blendingEnabled = enableBlending; quadVertices = BufferUtil.newFloatBuffer(12); diff --git a/src/demos/es1/cubefbo/FBCubes.java b/src/demos/es1/cubefbo/FBCubes.java index ad4e120..ecef02d 100755 --- a/src/demos/es1/cubefbo/FBCubes.java +++ b/src/demos/es1/cubefbo/FBCubes.java @@ -39,7 +39,7 @@ import javax.media.opengl.*; import com.sun.opengl.util.FBObject; import com.sun.opengl.util.glsl.fixedfunc.*; -class FBCubes implements GLEventListener { +public class FBCubes implements GLEventListener { private static final int FBO_SIZE = 256; public FBCubes () { |