aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-04-24 05:11:29 +0200
committerSven Gothel <[email protected]>2010-04-24 05:11:29 +0200
commit1ad8c39df6b097c80ba7a85badf555e7f669cc3f (patch)
tree740606f85dafdef5d5958498b080873c7bf188dd /src
parent778225504c00c7ca03386b6eabfbda929542130f (diff)
NEWT/AWT Interoperability
- Moved all event classes to com.jogamp.newt.event and the new AWT event helper to com.jogamp.newt.awt.event - Added Newt<Type>Adapter for convenience - Added AWT<Type>Adapter for - Using AWT agnostic NEWT event listener see com.jogamp.test.junit.jogl.demos.gl2.gears.TestGearsNEWT even for AWT see com.jogamp.test.junit.jogl.demos.gl2.gears.TestGearsAWT (Nice idea by mbien) - Forwarding AWT events to NEWT (refactoring) Misc - GLDrawableFactory.shutdown() is now protected and called by the JVM shutdown hook. Hence removing the validate().
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java7
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java41
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java2
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java1
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java18
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java23
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/util/Animator.java14
-rw-r--r--src/jogl/classes/javax/media/opengl/GLContext.java7
-rw-r--r--src/jogl/classes/javax/media/opengl/GLDrawableFactory.java7
-rwxr-xr-xsrc/junit/com/jogamp/test/junit/jogl/acore/TestGLProfile01CORE.java49
-rwxr-xr-xsrc/junit/com/jogamp/test/junit/jogl/awt/TestAWT01GLn.java9
-rw-r--r--src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/DebugKeyAdapter.java50
-rw-r--r--src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/Gears.java113
-rw-r--r--src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/QuitKeyAdapter.java51
-rwxr-xr-xsrc/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsAWT.java121
-rwxr-xr-xsrc/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsNEWT.java108
-rwxr-xr-xsrc/junit/com/jogamp/test/junit/jogl/drawable/TestDrawable01NEWT.java2
-rwxr-xr-xsrc/junit/com/jogamp/test/junit/jogl/offscreen/TestOffscreen01NEWT.java6
-rwxr-xr-xsrc/junit/com/jogamp/test/junit/jogl/offscreen/WindowUtilNEWT.java1
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/Display.java35
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/Window.java77
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/AWTDisplay.java113
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/AWTWindow.java142
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/event/AWTAdapter.java155
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/event/AWTKeyAdapter.java80
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/event/AWTMouseAdapter.java117
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/event/AWTNewtEventFactory.java140
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/event/AWTWindowAdapter.java126
-rw-r--r--src/newt/classes/com/jogamp/newt/event/Event.java73
-rw-r--r--src/newt/classes/com/jogamp/newt/event/KeyAdapter.java45
-rw-r--r--src/newt/classes/com/jogamp/newt/event/MouseAdapter.java55
-rw-r--r--src/newt/classes/com/jogamp/newt/event/WindowAdapter.java48
-rw-r--r--src/newt/classes/com/jogamp/newt/intel/gdl/Display.java2
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/macosx/MacDisplay.java2
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/macosx/MacWindow.java1
-rw-r--r--src/newt/classes/com/jogamp/newt/opengl/GLWindow.java12
-rw-r--r--src/newt/classes/com/jogamp/newt/opengl/broadcom/egl/Display.java2
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/opengl/kd/KDDisplay.java2
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/opengl/kd/KDWindow.java1
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/windows/WindowsDisplay.java2
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/windows/WindowsWindow.java1
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/x11/X11Display.java2
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/x11/X11Window.java1
43 files changed, 1432 insertions, 432 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java b/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java
index 7143344bf..7d0c3a0c2 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java
@@ -256,11 +256,8 @@ public abstract class GLContextImpl extends GLContext {
* @see #destroyContextARBImpl
*/
public int makeCurrent() throws GLException {
- // Support calls to makeCurrent() over and over again with
- // different contexts without releasing them
- // Could implement this more efficiently without explicit
- // releasing of the underlying context; would require more error
- // checking during the makeCurrentImpl phase
+ // One context can only be current by one thread,
+ // and one thread can only have one context current!
GLContext current = getCurrent();
if (current != null) {
if (current == this) {
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java b/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java
index cdf5beb24..8f0299c1c 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java
@@ -54,24 +54,10 @@ import java.lang.reflect.*;
public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
protected static final boolean DEBUG = Debug.debug("GLDrawableFactory");
- private boolean isValid = false;
-
- public void shutdown() {
- validate();
- isValid = false;
- }
-
- protected final void validate() {
- if(!isValid) {
- throw new GLException("GLDrawableFactory is already shutdown!");
- }
- }
-
//---------------------------------------------------------------------------
// Dispatching GLDrawable construction in respect to the NativeWindow Capabilities
//
public GLDrawable createGLDrawable(NativeWindow target) {
- validate();
if (target == null) {
throw new IllegalArgumentException("Null target");
}
@@ -132,7 +118,6 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
GLCapabilitiesChooser chooser,
int width,
int height) {
- validate();
if(height<=0 || height<=0) {
throw new GLException("Width and height of pbuffer must be positive (were (" +
width + ", " + height + "))");
@@ -148,7 +133,6 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
int width,
int height,
GLContext shareWith) {
- validate();
return new GLPbufferImpl( (GLDrawableImpl) createGLPbufferDrawable(capabilities, chooser, height, height),
shareWith);
}
@@ -165,7 +149,6 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
GLCapabilitiesChooser chooser,
int width,
int height) {
- validate();
if(width<=0 || height<=0) {
throw new GLException("Width and height of pbuffer must be positive (were (" +
width + ", " + height + "))");
@@ -185,10 +168,30 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
protected abstract GLDrawableImpl getSharedDrawable();
protected abstract GLContextImpl getSharedContext();
+ protected abstract void shutdown();
+
+ // Shutdown hook mechanism for the factory
+ private boolean factoryShutdownHookRegistered;
+ private Thread factoryShutdownHook;
+ private synchronized void registerFactoryShutdownHook() {
+ if (factoryShutdownHookRegistered)
+ return;
+ if (factoryShutdownHook == null) {
+ factoryShutdownHook = new Thread(new Runnable() {
+ public void run() {
+ synchronized (GLDrawableFactoryImpl.this) {
+ shutdown();
+ }
+ }
+ });
+ }
+ Runtime.getRuntime().addShutdownHook(factoryShutdownHook);
+ factoryShutdownHookRegistered = true;
+ }
protected GLDrawableFactoryImpl() {
super();
- isValid = true;
+ registerFactoryShutdownHook();
}
protected void maybeDoSingleThreadedWorkaround(Runnable action) {
@@ -294,7 +297,6 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
* out-of-bounds
*/
public boolean setDisplayGamma(float gamma, float brightness, float contrast) throws IllegalArgumentException {
- validate();
if ((brightness < -1.0f) || (brightness > 1.0f)) {
throw new IllegalArgumentException("Brightness must be between -1.0 and 1.0");
}
@@ -327,7 +329,6 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
}
public synchronized void resetDisplayGamma() {
- validate();
if (gammaShutdownHook == null) {
throw new IllegalArgumentException("Should not call this unless setDisplayGamma called first");
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java
index 4fccf22f8..fb0da9c40 100755
--- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java
@@ -61,7 +61,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
super();
}
-
+ protected void shutdown() {}
protected final GLDrawableImpl getSharedDrawable() { return null; }
protected final GLContextImpl getSharedContext() { return null; }
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java
index d10434252..61d24a106 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java
@@ -62,6 +62,7 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl implements D
} catch (JogampRuntimeException jre) { /* n/a .. */ }
}
+ protected void shutdown() {}
protected final GLDrawableImpl getSharedDrawable() { return null; }
protected final GLContextImpl getSharedContext() { return null; }
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
index a4bf89b81..ee4592adf 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
@@ -92,17 +92,14 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
boolean canCreateGLPbuffer = false;
protected final GLDrawableImpl getSharedDrawable() {
- validate();
return sharedDrawable;
}
protected final GLContextImpl getSharedContext() {
- validate();
return sharedContext;
}
- public void shutdown() {
- super.shutdown();
+ protected void shutdown() {
if (DEBUG) {
System.err.println("!!! Shutdown Shared:");
System.err.println("!!! CTX : "+sharedContext);
@@ -119,7 +116,6 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
}
public GLDrawableImpl createOnscreenDrawable(NativeWindow target) {
- validate();
if (target == null) {
throw new IllegalArgumentException("Null target");
}
@@ -127,7 +123,6 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
}
protected GLDrawableImpl createOffscreenDrawable(NativeWindow target) {
- validate();
if (target == null) {
throw new IllegalArgumentException("Null target");
}
@@ -135,12 +130,10 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
}
public boolean canCreateGLPbuffer(AbstractGraphicsDevice device) {
- validate();
return canCreateGLPbuffer;
}
protected GLDrawableImpl createGLPbufferDrawableImpl(final NativeWindow target) {
- validate();
if (target == null) {
throw new IllegalArgumentException("Null target");
}
@@ -174,7 +167,6 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
}
protected NativeWindow createOffscreenWindow(GLCapabilities capabilities, GLCapabilitiesChooser chooser, int width, int height) {
- validate();
AbstractGraphicsScreen screen = DefaultGraphicsScreen.createDefault();
NullWindow nw = new NullWindow(WindowsWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(
capabilities, chooser, screen) );
@@ -183,22 +175,18 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
}
public GLContext createExternalGLContext() {
- validate();
return WindowsExternalWGLContext.create(this, null);
}
public boolean canCreateExternalGLDrawable(AbstractGraphicsDevice device) {
- validate();
return true;
}
public GLDrawable createExternalGLDrawable() {
- validate();
return WindowsExternalWGLDrawable.create(this, null);
}
public void loadOpenGL32Library() {
- validate();
if (hopengl32 == 0) {
hopengl32 = WGL.LoadLibraryA("OpenGL32");
if (DEBUG) {
@@ -210,7 +198,6 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
}
public void loadGLULibrary() {
- validate();
if (hglu32 == 0) {
hglu32 = WGL.LoadLibraryA("GLU32");
if (hglu32 == 0) {
@@ -220,7 +207,6 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
}
public long dynamicLookupFunction(String glFuncName) {
- validate();
long res = WGL.wglGetProcAddress(glFuncName);
if (res == 0) {
// It may happen that a driver doesn't return the OpenGL32 core function pointer
@@ -253,13 +239,11 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
}
public boolean canCreateContextOnJava2DSurface(AbstractGraphicsDevice device) {
- validate();
return false;
}
public GLContext createContextOnJava2DSurface(Object graphics, GLContext shareWith)
throws GLException {
- validate();
throw new GLException("Unimplemented on this platform");
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java
index d8e5f7646..9a0edcfbb 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java
@@ -104,17 +104,14 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
private X11GLXContext sharedContext=null;
protected final GLDrawableImpl getSharedDrawable() {
- validate();
return sharedDrawable;
}
protected final GLContextImpl getSharedContext() {
- validate();
return sharedContext;
}
- public void shutdown() {
- super.shutdown();
+ protected void shutdown() {
if (DEBUG) {
System.err.println("!!! Shutdown Shared:");
System.err.println("!!! CTX : "+sharedContext);
@@ -131,16 +128,14 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
}
if(null!=sharedScreen) {
X11GraphicsDevice sharedDevice = (X11GraphicsDevice) sharedScreen.getDevice();
- if(null!=sharedDevice) {
- X11Util.closeThreadLocalDisplay(null);
- }
sharedScreen = null;
}
- X11Util.shutdown( !isVendorATI(), DEBUG );
+ // X11Util.shutdown( !isVendorATI(), DEBUG ); // works NV .. but ..
+ // X11Util.shutdown( true, DEBUG ); // fails ATI, works NV .. but
+ X11Util.shutdown( false, DEBUG );
}
public GLDrawableImpl createOnscreenDrawable(NativeWindow target) {
- validate();
if (target == null) {
throw new IllegalArgumentException("Null target");
}
@@ -151,7 +146,6 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
}
protected GLDrawableImpl createOffscreenDrawable(NativeWindow target) {
- validate();
if (target == null) {
throw new IllegalArgumentException("Null target");
}
@@ -162,14 +156,12 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
}
public boolean canCreateGLPbuffer(AbstractGraphicsDevice device) {
- validate();
return glxVersionGreaterEqualThan(device, 1, 3);
}
private boolean glxVersionsQueried = false;
private int glxVersionMajor=0, glxVersionMinor=0;
public boolean glxVersionGreaterEqualThan(AbstractGraphicsDevice device, int majorReq, int minorReq) {
- validate();
if (!glxVersionsQueried) {
if(null == device) {
device = (X11GraphicsDevice) sharedScreen.getDevice();
@@ -195,7 +187,6 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
}
protected GLDrawableImpl createGLPbufferDrawableImpl(final NativeWindow target) {
- validate();
if (target == null) {
throw new IllegalArgumentException("Null target");
}
@@ -228,7 +219,6 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
protected NativeWindow createOffscreenWindow(GLCapabilities capabilities, GLCapabilitiesChooser chooser, int width, int height) {
- validate();
NullWindow nw = null;
X11Lib.XLockDisplay(sharedScreen.getDevice().getHandle());
try{
@@ -243,22 +233,18 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
}
public GLContext createExternalGLContext() {
- validate();
return X11ExternalGLXContext.create(this, null);
}
public boolean canCreateExternalGLDrawable(AbstractGraphicsDevice device) {
- validate();
return canCreateGLPbuffer(device);
}
public GLDrawable createExternalGLDrawable() {
- validate();
return X11ExternalGLXDrawable.create(this, null);
}
public void loadGLULibrary() {
- validate();
X11Lib.dlopen("/usr/lib/libGLU.so");
}
@@ -273,7 +259,6 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
}
public boolean canCreateContextOnJava2DSurface(AbstractGraphicsDevice device) {
- validate();
return false;
}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/Animator.java b/src/jogl/classes/com/jogamp/opengl/util/Animator.java
index 30be0bd90..9bef8e9c3 100755
--- a/src/jogl/classes/com/jogamp/opengl/util/Animator.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/Animator.java
@@ -154,12 +154,19 @@ public class Animator {
impl.display(this, ignoreExceptions, printExceptions);
}
+ private long startTime = 0;
+ private long curTime = 0;
+ private int totalFrames = 0;
+
class MainLoop implements Runnable {
public void run() {
try {
if(DEBUG) {
System.out.println("Animator started: "+Thread.currentThread());
}
+ startTime = System.currentTimeMillis();
+ curTime = startTime;
+
while (!shouldStop) {
// Don't consume CPU unless there is work to be done
if (drawables.size() == 0) {
@@ -173,6 +180,8 @@ public class Animator {
}
}
display();
+ curTime = System.currentTimeMillis();
+ totalFrames++;
if (!runAsFastAsPossible) {
// Avoid swamping the CPU
Thread.yield();
@@ -191,6 +200,11 @@ public class Animator {
}
}
+ public long getStartTime() { return startTime; }
+ public long getCurrentTime() { return curTime; }
+ public long getDuration() { return curTime-startTime; }
+ public int getTotalFrames() { return totalFrames; }
+
/** Starts this animator. */
public synchronized void start() {
if (thread != null) {
diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java
index 2709dd506..c07bbeaf4 100644
--- a/src/jogl/classes/javax/media/opengl/GLContext.java
+++ b/src/jogl/classes/javax/media/opengl/GLContext.java
@@ -188,6 +188,13 @@ public abstract class GLContext {
}
/**
+ * @return true if this GLContext is current on this thread
+ */
+ public final boolean isCurrent() {
+ return getCurrent() == this ;
+ }
+
+ /**
* Sets the thread-local variable returned by {@link #getCurrent}
* and has no other side-effects. For use by third parties adding
* new GLContext implementations; not for use by end users.
diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
index b02bffb61..ca6bc7564 100644
--- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
+++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
@@ -168,13 +168,6 @@ public abstract class GLDrawableFactory {
throw new GLException("No native platform GLDrawableFactory, nor EGLDrawableFactory available: "+glProfileImplName);
}
- /** Shuts down this GLDrawableFactory, releasing resources
- associated with it. Before calling this method you should first
- destroy any GLContexts and GLDrawables that have been created
- and are still in use. No further OpenGL calls may be made after
- shutting down the GLDrawableFactory. */
- public abstract void shutdown();
-
//----------------------------------------------------------------------
// Methods to create high-level objects
diff --git a/src/junit/com/jogamp/test/junit/jogl/acore/TestGLProfile01CORE.java b/src/junit/com/jogamp/test/junit/jogl/acore/TestGLProfile01CORE.java
index a1ff0d860..a446be865 100755
--- a/src/junit/com/jogamp/test/junit/jogl/acore/TestGLProfile01CORE.java
+++ b/src/junit/com/jogamp/test/junit/jogl/acore/TestGLProfile01CORE.java
@@ -46,20 +46,15 @@ import java.io.IOException;
public class TestGLProfile01CORE {
static GLProfile glp;
- static GLDrawableFactory factory;
@BeforeClass
public static void initClass() {
glp = GLProfile.getDefault();
Assert.assertNotNull(glp);
- factory = GLDrawableFactory.getFactory(glp);
- Assert.assertNotNull(factory);
}
@AfterClass
public static void releaseClass() {
- factory.shutdown();
- factory=null;
}
@Test
@@ -69,12 +64,52 @@ public class TestGLProfile01CORE {
@Test
public void test02GLProfileMaxFixedFunc() {
- System.out.println("GLProfile <static> getMaxFixedFunc(): "+GLProfile.getMaxFixedFunc());
+ // Assuming at least one fixed profile is available
+ GLProfile maxFixed = GLProfile.getMaxFixedFunc();
+ System.out.println("GLProfile <static> getMaxFixedFunc(): "+maxFixed);
+ if(maxFixed.getName().equals(GLProfile.GL4bc)) {
+ Assert.assertTrue(GLProfile.isGL4bcAvailable());
+ Assert.assertTrue(GLProfile.isGL3bcAvailable());
+ Assert.assertTrue(GLProfile.isGL2Available());
+ Assert.assertTrue(GLProfile.isGL2ES1Available());
+ Assert.assertTrue(GLProfile.isGL2ES2Available());
+ } else if(maxFixed.getName().equals(GLProfile.GL3bc)) {
+ Assert.assertTrue(GLProfile.isGL3bcAvailable());
+ Assert.assertTrue(GLProfile.isGL2Available());
+ Assert.assertTrue(GLProfile.isGL2ES1Available());
+ Assert.assertTrue(GLProfile.isGL2ES2Available());
+ } else if(maxFixed.getName().equals(GLProfile.GL2)) {
+ Assert.assertTrue(GLProfile.isGL2Available());
+ Assert.assertTrue(GLProfile.isGL2ES1Available());
+ Assert.assertTrue(GLProfile.isGL2ES2Available());
+ } else if(maxFixed.getName().equals(GLProfile.GL2ES1)) {
+ Assert.assertTrue(GLProfile.isGL2ES1Available());
+ }
}
@Test
public void test02GLProfileMaxProgrammable() {
- System.out.println("GLProfile <static> getMaxProgrammable(): "+GLProfile.getMaxProgrammable());
+ // Assuming at least one programmable profile is available
+ GLProfile maxProgrammable = GLProfile.getMaxProgrammable();
+ System.out.println("GLProfile <static> getMaxProgrammable(): "+maxProgrammable);
+ if(maxProgrammable.getName().equals(GLProfile.GL4)) {
+ Assert.assertTrue(GLProfile.isGL4Available());
+ Assert.assertTrue(GLProfile.isGL3Available());
+ Assert.assertTrue(GLProfile.isGL2Available());
+ Assert.assertTrue(GLProfile.isGL2ES1Available());
+ Assert.assertTrue(GLProfile.isGL2ES2Available());
+ } else if(maxProgrammable.getName().equals(GLProfile.GL3)) {
+ Assert.assertTrue(GLProfile.isGL3Available());
+ Assert.assertTrue(GLProfile.isGL2Available());
+ Assert.assertTrue(GLProfile.isGL2ES1Available());
+ Assert.assertTrue(GLProfile.isGL2ES2Available());
+ } else if(maxProgrammable.getName().equals(GLProfile.GL2)) {
+ Assert.assertTrue(GLProfile.isGL2Available());
+ Assert.assertTrue(GLProfile.isGL2ES1Available());
+ Assert.assertTrue(GLProfile.isGL2ES2Available());
+ } else if(maxProgrammable.getName().equals(GLProfile.GL2ES2)) {
+ Assert.assertTrue(GLProfile.isGL2ES2Available());
+ }
}
public static void main(String args[]) throws IOException {
diff --git a/src/junit/com/jogamp/test/junit/jogl/awt/TestAWT01GLn.java b/src/junit/com/jogamp/test/junit/jogl/awt/TestAWT01GLn.java
index ac34b46b5..c8cedd434 100755
--- a/src/junit/com/jogamp/test/junit/jogl/awt/TestAWT01GLn.java
+++ b/src/junit/com/jogamp/test/junit/jogl/awt/TestAWT01GLn.java
@@ -89,16 +89,11 @@ public class TestAWT01GLn {
runTestGL(caps);
}
- /** Both fail on ATI .. if GLn n>2
- public void test02GL3bc() throws InterruptedException {
- GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL3bc));
- runTestGL(caps);
- }
-
+ @Test
public void test03GLMaxFixed() throws InterruptedException {
GLCapabilities caps = new GLCapabilities(GLProfile.getMaxFixedFunc());
runTestGL(caps);
- } */
+ }
public static void main(String args[]) {
org.junit.runner.JUnitCore.main(TestAWT01GLn.class.getName());
diff --git a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/DebugKeyAdapter.java b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/DebugKeyAdapter.java
new file mode 100644
index 000000000..da5e7d62f
--- /dev/null
+++ b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/DebugKeyAdapter.java
@@ -0,0 +1,50 @@
+
+/*
+ * Copyright (c) 2010 Sven Gothel. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name Sven Gothel or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+package com.jogamp.test.junit.jogl.demos.gl2.gears;
+
+import com.jogamp.newt.event.*;
+
+class DebugKeyAdapter extends KeyAdapter {
+
+ public void keyPressed(KeyEvent e) {
+ System.out.println("KEY-PRESSED "+Thread.currentThread()+": "+e);
+ }
+ public void keyReleased(KeyEvent e) {
+ System.out.println("KEY-RELEASED "+Thread.currentThread()+": "+e);
+ }
+ public void keyTyped(KeyEvent e) {
+ System.out.println("KEY-TYPED "+Thread.currentThread()+": "+e);
+ }
+}
+
diff --git a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/Gears.java b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/Gears.java
index 135efd341..45d5a4a58 100644
--- a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/Gears.java
+++ b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/Gears.java
@@ -1,11 +1,13 @@
package com.jogamp.test.junit.jogl.demos.gl2.gears;
-import javax.media.opengl.GL;
-import javax.media.opengl.GL2ES1;
-import javax.media.opengl.GL2;
-import javax.media.opengl.GLAutoDrawable;
-import javax.media.opengl.GLEventListener;
+import javax.media.opengl.*;
+import javax.media.opengl.awt.*;
+import com.jogamp.newt.event.*;
+import com.jogamp.newt.awt.event.*;
+
+import java.awt.Component;
+import com.jogamp.newt.Window;
/**
* Gears.java <BR>
@@ -14,7 +16,7 @@ import javax.media.opengl.GLEventListener;
* This version is equal to Brian Paul's version 1.2 1999/10/21
*/
-public class Gears implements GLEventListener /* , MouseListener, MouseMotionListener */ {
+public class Gears implements GLEventListener {
private float view_rotx = 20.0f, view_roty = 30.0f, view_rotz = 0.0f;
private int gear1, gear2, gear3;
private float angle = 0.0f;
@@ -28,10 +30,6 @@ public class Gears implements GLEventListener /* , MouseListener, MouseMotionLis
GL2 gl = drawable.getGL().getGL2();
- System.err.println("INIT GL IS: " + gl.getClass().getName());
-
- System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities());
-
gl.setSwapInterval(1);
float pos[] = { 5.0f, 5.0f, 10.0f, 0.0f };
@@ -66,12 +64,15 @@ public class Gears implements GLEventListener /* , MouseListener, MouseMotionLis
gl.glEnable(GL2.GL_NORMALIZE);
- /**
- if (drawable instanceof AWTGLAutoDrawable) {
- AWTGLAutoDrawable awtDrawable = (AWTGLAutoDrawable) drawable;
- awtDrawable.addMouseListener(this);
- awtDrawable.addMouseMotionListener(this);
- } */
+ GearsMouseAdapter gearsMouse = new GearsMouseAdapter();
+
+ if (drawable instanceof Component) {
+ Component comp = (Component) drawable;
+ new AWTMouseAdapter(gearsMouse).addTo(comp);
+ } else if (drawable instanceof Window) {
+ Window window = (Window) drawable;
+ window.addMouseListener(gearsMouse);
+ }
}
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
@@ -81,9 +82,6 @@ public class Gears implements GLEventListener /* , MouseListener, MouseMotionLis
gl.glMatrixMode(GL2.GL_PROJECTION);
- System.err.println("GL_VENDOR: " + gl.glGetString(GL2.GL_VENDOR));
- System.err.println("GL_RENDERER: " + gl.glGetString(GL2.GL_RENDERER));
- System.err.println("GL_VERSION: " + gl.glGetString(GL2.GL_VERSION));
gl.glLoadIdentity();
gl.glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f);
gl.glMatrixMode(GL2.GL_MODELVIEW);
@@ -92,7 +90,6 @@ public class Gears implements GLEventListener /* , MouseListener, MouseMotionLis
}
public void dispose(GLAutoDrawable drawable) {
- System.out.println("Gears.dispose: "+drawable);
}
public void display(GLAutoDrawable drawable) {
@@ -264,43 +261,45 @@ public class Gears implements GLEventListener /* , MouseListener, MouseMotionLis
gl.glEnd();
}
- /***
- // Methods required for the implementation of MouseListener
- public void mouseEntered(MouseEvent e) {}
- public void mouseExited(MouseEvent e) {}
-
- public void mousePressed(MouseEvent e) {
- prevMouseX = e.getX();
- prevMouseY = e.getY();
- if ((e.getModifiers() & e.BUTTON3_MASK) != 0) {
- mouseRButtonDown = true;
- }
- }
-
- public void mouseReleased(MouseEvent e) {
- if ((e.getModifiers() & e.BUTTON3_MASK) != 0) {
- mouseRButtonDown = false;
- }
- }
-
- public void mouseClicked(MouseEvent e) {}
-
- // Methods required for the implementation of MouseMotionListener
- public void mouseDragged(MouseEvent e) {
- int x = e.getX();
- int y = e.getY();
- Dimension size = e.getComponent().getSize();
-
- float thetaY = 360.0f * ( (float)(x-prevMouseX)/(float)size.width);
- float thetaX = 360.0f * ( (float)(prevMouseY-y)/(float)size.height);
-
- prevMouseX = x;
- prevMouseY = y;
+ class GearsMouseAdapter extends MouseAdapter {
+ public void mousePressed(MouseEvent e) {
+ prevMouseX = e.getX();
+ prevMouseY = e.getY();
+ if ((e.getModifiers() & e.BUTTON3_MASK) != 0) {
+ mouseRButtonDown = true;
+ }
+ }
+
+ public void mouseReleased(MouseEvent e) {
+ if ((e.getModifiers() & e.BUTTON3_MASK) != 0) {
+ mouseRButtonDown = false;
+ }
+ }
+
+ public void mouseDragged(MouseEvent e) {
+ int x = e.getX();
+ int y = e.getY();
+ int width=0, height=0;
+ Object source = e.getSource();
+ if(source instanceof Window) {
+ Window window = (Window) source;
+ width=window.getWidth();
+ height=window.getHeight();
+ } else if (source instanceof Component) {
+ Component comp = (Component) source;
+ width=comp.getWidth();
+ height=comp.getHeight();
+ } else {
+ throw new RuntimeException("Event source neither Window nor Component: "+source);
+ }
+ float thetaY = 360.0f * ( (float)(x-prevMouseX)/(float)width);
+ float thetaX = 360.0f * ( (float)(prevMouseY-y)/(float)height);
+
+ prevMouseX = x;
+ prevMouseY = y;
- view_rotx += thetaX;
- view_roty += thetaY;
+ view_rotx += thetaX;
+ view_roty += thetaY;
+ }
}
-
- public void mouseMoved(MouseEvent e) {}
- */
}
diff --git a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/QuitKeyAdapter.java b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/QuitKeyAdapter.java
new file mode 100644
index 000000000..443fd74b1
--- /dev/null
+++ b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/QuitKeyAdapter.java
@@ -0,0 +1,51 @@
+
+/*
+ * Copyright (c) 2010 Sven Gothel. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name Sven Gothel or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+package com.jogamp.test.junit.jogl.demos.gl2.gears;
+
+import com.jogamp.opengl.util.Animator;
+import com.jogamp.newt.event.*;
+
+class QuitKeyAdapter extends KeyAdapter {
+ boolean shouldQuit = false;
+
+ public boolean shouldQuit() { return shouldQuit; }
+
+ public void keyTyped(KeyEvent e) {
+ if(e.getKeyChar()=='q') {
+ System.out.println("QUIT "+Thread.currentThread());
+ shouldQuit = true;
+ }
+ }
+}
+
diff --git a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsAWT.java b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsAWT.java
new file mode 100755
index 000000000..36146df58
--- /dev/null
+++ b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsAWT.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2010 Sven Gothel. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name Sven Gothel or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+package com.jogamp.test.junit.jogl.demos.gl2.gears;
+
+import javax.media.opengl.*;
+import com.jogamp.opengl.util.Animator;
+import javax.media.opengl.awt.GLCanvas;
+import com.jogamp.newt.awt.event.AWTKeyAdapter;
+
+import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears;
+import java.awt.Frame;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.AfterClass;
+import org.junit.After;
+import org.junit.Test;
+
+public class TestGearsAWT {
+ static GLProfile glp;
+ static int width, height;
+
+ @BeforeClass
+ public static void initClass() {
+ glp = GLProfile.getDefault();
+ Assert.assertNotNull(glp);
+ width = 512;
+ height = 512;
+ }
+
+ @AfterClass
+ public static void releaseClass() {
+ }
+
+ protected void runTestGL(GLCapabilities caps) throws InterruptedException {
+ Frame frame = new Frame("Gears AWT Test");
+ Assert.assertNotNull(frame);
+
+ GLCanvas glCanvas = new GLCanvas(caps);
+ Assert.assertNotNull(glCanvas);
+ frame.add(glCanvas);
+ frame.setSize(512, 512);
+
+ glCanvas.addGLEventListener(new Gears());
+
+ Animator animator = new Animator(glCanvas);
+ QuitKeyAdapter quitKeyAdapter = new QuitKeyAdapter();
+
+ new AWTKeyAdapter(new DebugKeyAdapter()).addTo(glCanvas);
+ new AWTKeyAdapter(quitKeyAdapter).addTo(glCanvas);
+
+ frame.setVisible(true);
+ animator.start();
+
+ while(!quitKeyAdapter.shouldQuit() && animator.isAnimating() && animator.getDuration()<duration) {
+ Thread.sleep(100);
+ }
+
+ Assert.assertNotNull(frame);
+ Assert.assertNotNull(glCanvas);
+ Assert.assertNotNull(animator);
+
+ animator.stop();
+ frame.setVisible(false);
+ frame.remove(glCanvas);
+ frame.dispose();
+ frame=null;
+ glCanvas=null;
+ }
+
+ @Test
+ public void test01() throws InterruptedException {
+ GLCapabilities caps = new GLCapabilities(GLProfile.getDefault());
+ runTestGL(caps);
+ }
+
+ static long duration = 500; // ms
+
+ public static void main(String args[]) {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ try {
+ duration = Integer.parseInt(args[i]);
+ } catch (Exception ex) { ex.printStackTrace(); }
+ }
+ }
+ org.junit.runner.JUnitCore.main(TestGearsAWT.class.getName());
+ }
+}
diff --git a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsNEWT.java b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsNEWT.java
new file mode 100755
index 000000000..e1de72ab5
--- /dev/null
+++ b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsNEWT.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2010 Sven Gothel. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name Sven Gothel or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+package com.jogamp.test.junit.jogl.demos.gl2.gears;
+
+import javax.media.opengl.*;
+import com.jogamp.opengl.util.Animator;
+
+import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears;
+import com.jogamp.newt.*;
+import com.jogamp.newt.opengl.*;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.AfterClass;
+import org.junit.After;
+import org.junit.Test;
+
+public class TestGearsNEWT {
+ static GLProfile glp;
+ static int width, height;
+
+ @BeforeClass
+ public static void initClass() {
+ glp = GLProfile.getDefault();
+ Assert.assertNotNull(glp);
+ width = 512;
+ height = 512;
+ }
+
+ @AfterClass
+ public static void releaseClass() {
+ }
+
+ protected void runTestGL(GLCapabilities caps) throws InterruptedException {
+ GLWindow glWindow = GLWindow.create(caps);
+ Assert.assertNotNull(glWindow);
+
+ glWindow.addGLEventListener(new Gears());
+
+ Animator animator = new Animator(glWindow);
+ QuitKeyAdapter quitKeyAdapter = new QuitKeyAdapter();
+
+ glWindow.addKeyListener(new DebugKeyAdapter());
+ glWindow.addKeyListener(quitKeyAdapter);
+
+ glWindow.setSize(width, height);
+ glWindow.setVisible(true);
+ animator.start();
+
+ while(!quitKeyAdapter.shouldQuit() && animator.isAnimating() && animator.getDuration()<duration) {
+ Thread.sleep(100);
+ }
+
+ animator.stop();
+ glWindow.destroy(true);
+ }
+
+ @Test
+ public void test01() throws InterruptedException {
+ GLCapabilities caps = new GLCapabilities(GLProfile.getDefault());
+ runTestGL(caps);
+ }
+
+ static long duration = 500; // ms
+
+ public static void main(String args[]) {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ try {
+ duration = Integer.parseInt(args[i]);
+ } catch (Exception ex) { ex.printStackTrace(); }
+ }
+ }
+ org.junit.runner.JUnitCore.main(TestGearsNEWT.class.getName());
+ }
+}
diff --git a/src/junit/com/jogamp/test/junit/jogl/drawable/TestDrawable01NEWT.java b/src/junit/com/jogamp/test/junit/jogl/drawable/TestDrawable01NEWT.java
index 0320c50ae..49dddc701 100755
--- a/src/junit/com/jogamp/test/junit/jogl/drawable/TestDrawable01NEWT.java
+++ b/src/junit/com/jogamp/test/junit/jogl/drawable/TestDrawable01NEWT.java
@@ -65,7 +65,7 @@ public class TestDrawable01NEWT {
@AfterClass
public static void releaseClass() {
- factory.shutdown();
+ Assert.assertNotNull(factory);
factory=null;
}
diff --git a/src/junit/com/jogamp/test/junit/jogl/offscreen/TestOffscreen01NEWT.java b/src/junit/com/jogamp/test/junit/jogl/offscreen/TestOffscreen01NEWT.java
index 459b41f16..67d1d5138 100755
--- a/src/junit/com/jogamp/test/junit/jogl/offscreen/TestOffscreen01NEWT.java
+++ b/src/junit/com/jogamp/test/junit/jogl/offscreen/TestOffscreen01NEWT.java
@@ -48,6 +48,7 @@ import javax.media.opengl.*;
import javax.media.nativewindow.*;
import com.jogamp.newt.*;
+import com.jogamp.newt.event.*;
import com.jogamp.newt.opengl.*;
import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears;
@@ -56,7 +57,6 @@ import java.io.IOException;
public class TestOffscreen01NEWT {
static GLProfile glpDefault;
- static GLDrawableFactory factory;
static int width, height;
GLCapabilities capsDefault;
@@ -64,16 +64,12 @@ public class TestOffscreen01NEWT {
public static void initClass() {
glpDefault = GLProfile.getDefault();
Assert.assertNotNull(glpDefault);
- factory = GLDrawableFactory.getFactory(glpDefault);
- Assert.assertNotNull(factory);
width = 640;
height = 480;
}
@AfterClass
public static void releaseClass() {
- factory.shutdown();
- factory=null;
}
@Before
diff --git a/src/junit/com/jogamp/test/junit/jogl/offscreen/WindowUtilNEWT.java b/src/junit/com/jogamp/test/junit/jogl/offscreen/WindowUtilNEWT.java
index 55ad83d25..7242abf0b 100755
--- a/src/junit/com/jogamp/test/junit/jogl/offscreen/WindowUtilNEWT.java
+++ b/src/junit/com/jogamp/test/junit/jogl/offscreen/WindowUtilNEWT.java
@@ -39,6 +39,7 @@ import org.junit.Assert;
import javax.media.opengl.*;
import javax.media.nativewindow.*;
import com.jogamp.newt.*;
+import com.jogamp.newt.event.*;
import com.jogamp.newt.opengl.*;
public class WindowUtilNEWT {
diff --git a/src/newt/classes/com/jogamp/newt/Display.java b/src/newt/classes/com/jogamp/newt/Display.java
index 2bc99475c..931c16cd9 100755
--- a/src/newt/classes/com/jogamp/newt/Display.java
+++ b/src/newt/classes/com/jogamp/newt/Display.java
@@ -33,6 +33,7 @@
package com.jogamp.newt;
+import com.jogamp.newt.event.*;
import javax.media.nativewindow.*;
import com.jogamp.newt.impl.Debug;
import com.jogamp.newt.util.EDTUtil;
@@ -264,7 +265,39 @@ public abstract class Display {
return "NEWT-Display["+name+", refCount "+refCount+", "+aDevice+"]";
}
- protected abstract void dispatchMessages();
+ protected abstract void dispatchMessagesNative();
+
+ private LinkedList/*<Event>*/ events = new LinkedList();
+
+ protected void dispatchMessages() {
+ Event e;
+ do {
+ synchronized(events) {
+ if (!events.isEmpty()) {
+ e = (Event) events.removeFirst();
+ } else {
+ e = null;
+ }
+ }
+ if (e != null) {
+ Object source = e.getSource();
+ if(source instanceof Window) {
+ ((Window)source).sendEvent(e);
+ } else {
+ throw new RuntimeException("Event source not a NEWT Window: "+source.getClass().getName()+", "+source);
+ }
+ }
+ } while (e != null);
+
+ dispatchMessagesNative();
+ }
+
+ public void enqueueEvent(com.jogamp.newt.event.Event e) {
+ synchronized(events) {
+ events.add(e);
+ }
+ }
+
/** Default impl. nop - Currently only X11 needs a Display lock */
protected void lockDisplay() { }
diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java
index b1f8b3977..33b971578 100755
--- a/src/newt/classes/com/jogamp/newt/Window.java
+++ b/src/newt/classes/com/jogamp/newt/Window.java
@@ -33,6 +33,7 @@
package com.jogamp.newt;
+import com.jogamp.newt.event.*;
import com.jogamp.newt.impl.Debug;
import com.jogamp.newt.util.EDTUtil;
@@ -571,8 +572,24 @@ public abstract class Window implements NativeWindow
}
}
+ //
+ // Generic Event Support
+ //
+
+ protected void sendEvent(Event e) {
+ if(e instanceof WindowEvent) {
+ sendWindowEvent((WindowEvent)e);
+ } else if(e instanceof KeyEvent) {
+ sendKeyEvent((KeyEvent)e);
+ } else if(e instanceof MouseEvent) {
+ sendMouseEvent((MouseEvent)e);
+ } else if(e instanceof PaintEvent) {
+ sendPaintEvent((PaintEvent)e);
+ }
+ }
+
//
- // MouseListener Support
+ // MouseListener/Event Support
//
public void addMouseListener(MouseListener l) {
@@ -609,6 +626,7 @@ public abstract class Window implements NativeWindow
private int lastMouseClickCount = 0; // last mouse button click count
public static final int ClickTimeout = 300;
+ /** Be aware that this method synthesizes the events: MouseClicked and MouseDragged */
protected void sendMouseEvent(int eventType, int modifiers,
int x, int y, int button, int rotation) {
if(x<0||y<0||x>=width||y>=height) {
@@ -633,13 +651,13 @@ public abstract class Window implements NativeWindow
}
lastMousePressed=when;
mouseButtonPressed=button;
- e = new MouseEvent(true, eventType, this, when,
+ e = new MouseEvent(eventType, this, when,
modifiers, x, y, lastMouseClickCount, button, 0);
} else if(MouseEvent.EVENT_MOUSE_RELEASED==eventType) {
- e = new MouseEvent(true, eventType, this, when,
+ e = new MouseEvent(eventType, this, when,
modifiers, x, y, lastMouseClickCount, button, 0);
if(when-lastMousePressed<ClickTimeout) {
- eClicked = new MouseEvent(true, MouseEvent.EVENT_MOUSE_CLICKED, this, when,
+ eClicked = new MouseEvent(MouseEvent.EVENT_MOUSE_CLICKED, this, when,
modifiers, x, y, lastMouseClickCount, button, 0);
} else {
lastMouseClickCount=0;
@@ -648,23 +666,29 @@ public abstract class Window implements NativeWindow
mouseButtonPressed=0;
} else if(MouseEvent.EVENT_MOUSE_MOVED==eventType) {
if (mouseButtonPressed>0) {
- e = new MouseEvent(true, MouseEvent.EVENT_MOUSE_DRAGGED, this, when,
+ e = new MouseEvent(MouseEvent.EVENT_MOUSE_DRAGGED, this, when,
modifiers, x, y, 1, mouseButtonPressed, 0);
} else {
- e = new MouseEvent(true, eventType, this, when,
+ e = new MouseEvent(eventType, this, when,
modifiers, x, y, 0, button, 0);
}
} else if(MouseEvent.EVENT_MOUSE_WHEEL_MOVED==eventType) {
- e = new MouseEvent(true, eventType, this, when, modifiers, x, y, 0, button, rotation);
+ e = new MouseEvent(eventType, this, when, modifiers, x, y, 0, button, rotation);
} else {
- e = new MouseEvent(true, eventType, this, when, modifiers, x, y, 0, button, 0);
+ e = new MouseEvent(eventType, this, when, modifiers, x, y, 0, button, 0);
+ }
+ sendMouseEvent(e);
+ if(null!=eClicked) {
+ if(DEBUG_MOUSE_EVENT) {
+ System.out.println("sendMouseEvent: synthesized MOUSE_CLICKED event");
+ }
+ sendMouseEvent(eClicked);
}
+ }
+ protected void sendMouseEvent(MouseEvent e) {
if(DEBUG_MOUSE_EVENT) {
System.out.println("sendMouseEvent: event: "+e);
- if(null!=eClicked) {
- System.out.println("sendMouseEvent: event Clicked: "+eClicked);
- }
}
ArrayList listeners = null;
@@ -688,9 +712,6 @@ public abstract class Window implements NativeWindow
break;
case MouseEvent.EVENT_MOUSE_RELEASED:
l.mouseReleased(e);
- if(null!=eClicked) {
- l.mouseClicked(eClicked);
- }
break;
case MouseEvent.EVENT_MOUSE_MOVED:
l.mouseMoved(e);
@@ -708,7 +729,7 @@ public abstract class Window implements NativeWindow
}
//
- // KeyListener Support
+ // KeyListener/Event Support
//
public void addKeyListener(KeyListener l) {
@@ -742,8 +763,11 @@ public abstract class Window implements NativeWindow
private ArrayList keyListeners = new ArrayList();
protected void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) {
- KeyEvent e = new KeyEvent(true, eventType, this, System.currentTimeMillis(),
- modifiers, keyCode, keyChar);
+ sendKeyEvent(new KeyEvent(eventType, this, System.currentTimeMillis(),
+ modifiers, keyCode, keyChar) );
+ }
+
+ protected void sendKeyEvent(KeyEvent e) {
if(DEBUG_KEY_EVENT) {
System.out.println("sendKeyEvent: "+e);
}
@@ -753,7 +777,7 @@ public abstract class Window implements NativeWindow
}
for(Iterator i = listeners.iterator(); i.hasNext(); ) {
KeyListener l = (KeyListener) i.next();
- switch(eventType) {
+ switch(e.getEventType()) {
case KeyEvent.EVENT_KEY_PRESSED:
l.keyPressed(e);
break;
@@ -770,7 +794,7 @@ public abstract class Window implements NativeWindow
}
//
- // WindowListener Support
+ // WindowListener/Event Support
//
private ArrayList windowListeners = new ArrayList();
@@ -804,7 +828,10 @@ public abstract class Window implements NativeWindow
}
protected void sendWindowEvent(int eventType) {
- WindowEvent e = new WindowEvent(true, eventType, this, System.currentTimeMillis());
+ sendWindowEvent( new WindowEvent(eventType, this, System.currentTimeMillis()) );
+ }
+
+ protected void sendWindowEvent(WindowEvent e) {
if(DEBUG_WINDOW_EVENT) {
System.out.println("sendWindowEvent: "+e);
}
@@ -814,7 +841,7 @@ public abstract class Window implements NativeWindow
}
for(Iterator i = listeners.iterator(); i.hasNext(); ) {
WindowListener l = (WindowListener) i.next();
- switch(eventType) {
+ switch(e.getEventType()) {
case WindowEvent.EVENT_WINDOW_RESIZED:
l.windowResized(e);
break;
@@ -840,7 +867,7 @@ public abstract class Window implements NativeWindow
//
- // WindowListener Support
+ // PaintListener/Event Support
//
private ArrayList paintListeners = new ArrayList();
@@ -868,8 +895,10 @@ public abstract class Window implements NativeWindow
}
protected void sendPaintEvent(int eventType, int x, int y, int w, int h) {
- PaintEvent e =
- new PaintEvent(eventType, this, System.currentTimeMillis(), x, y, w, h);
+ sendPaintEvent( new PaintEvent(eventType, this, System.currentTimeMillis(), x, y, w, h) );
+ }
+
+ protected void sendPaintEvent(PaintEvent e) {
ArrayList listeners = null;
synchronized(paintListeners) {
listeners = paintListeners;
diff --git a/src/newt/classes/com/jogamp/newt/awt/AWTDisplay.java b/src/newt/classes/com/jogamp/newt/awt/AWTDisplay.java
index 09ce10017..d1fc1bc85 100644
--- a/src/newt/classes/com/jogamp/newt/awt/AWTDisplay.java
+++ b/src/newt/classes/com/jogamp/newt/awt/AWTDisplay.java
@@ -54,115 +54,6 @@ public class AWTDisplay extends Display {
protected void closeNative() { }
- public void dispatchMessages() {
- AWTEventWrapper w;
- do {
- synchronized(this) {
- if (!events.isEmpty()) {
- w = (AWTEventWrapper) events.removeFirst();
- } else {
- w = null;
- }
- }
- if (w != null) {
- switch (w.getType()) {
- case com.jogamp.newt.WindowEvent.EVENT_WINDOW_RESIZED:
- case com.jogamp.newt.WindowEvent.EVENT_WINDOW_MOVED:
- case com.jogamp.newt.WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY:
- w.getWindow().sendWindowEvent(w.getType());
- break;
-
- case com.jogamp.newt.MouseEvent.EVENT_MOUSE_CLICKED:
- case com.jogamp.newt.MouseEvent.EVENT_MOUSE_ENTERED:
- case com.jogamp.newt.MouseEvent.EVENT_MOUSE_EXITED:
- case com.jogamp.newt.MouseEvent.EVENT_MOUSE_PRESSED:
- case com.jogamp.newt.MouseEvent.EVENT_MOUSE_RELEASED:
- case com.jogamp.newt.MouseEvent.EVENT_MOUSE_MOVED:
- case com.jogamp.newt.MouseEvent.EVENT_MOUSE_DRAGGED:
- case com.jogamp.newt.MouseEvent.EVENT_MOUSE_WHEEL_MOVED:
- {
- MouseEvent e = (MouseEvent) w.getEvent();
- int rotation = 0;
- if (e instanceof MouseWheelEvent) {
- rotation = ((MouseWheelEvent)e).getWheelRotation();
- }
- w.getWindow().sendMouseEvent(w.getType(), convertModifiers(e),
- e.getX(), e.getY(), convertButton(e),
- rotation);
- }
- break;
-
- case com.jogamp.newt.KeyEvent.EVENT_KEY_PRESSED:
- case com.jogamp.newt.KeyEvent.EVENT_KEY_RELEASED:
- case com.jogamp.newt.KeyEvent.EVENT_KEY_TYPED:
- {
- KeyEvent e = (KeyEvent) w.getEvent();
- w.getWindow().sendKeyEvent(w.getType(), convertModifiers(e),
- e.getKeyCode(), e.getKeyChar());
- }
- break;
-
- default:
- throw new NativeWindowException("Unknown event type " + w.getType());
- }
- if(Window.DEBUG_MOUSE_EVENT) {
- System.out.println("dispatchMessages: "+w.getWindow()+" in event:"+w.getEvent());
- }
- }
- } while (w != null);
- }
-
- protected void enqueueEvent(AWTWindow w, int type, InputEvent e) {
- AWTEventWrapper wrapper = new AWTEventWrapper(w, type, e);
- synchronized(this) {
- events.add(wrapper);
- }
- }
-
- private LinkedList/*<AWTEventWrapper>*/ events = new LinkedList();
-
- static class AWTEventWrapper {
- AWTWindow window;
- int type;
- InputEvent e;
-
- AWTEventWrapper(AWTWindow w, int type, InputEvent e) {
- this.window = w;
- this.type = type;
- this.e = e;
- }
-
- public AWTWindow getWindow() {
- return window;
- }
-
- public int getType() {
- return type;
- }
-
- public InputEvent getEvent() {
- return e;
- }
- }
-
- private static int convertModifiers(InputEvent e) {
- int newtMods = 0;
- int mods = e.getModifiers();
- if ((mods & InputEvent.SHIFT_MASK) != 0) newtMods |= com.jogamp.newt.InputEvent.SHIFT_MASK;
- if ((mods & InputEvent.CTRL_MASK) != 0) newtMods |= com.jogamp.newt.InputEvent.CTRL_MASK;
- if ((mods & InputEvent.META_MASK) != 0) newtMods |= com.jogamp.newt.InputEvent.META_MASK;
- if ((mods & InputEvent.ALT_MASK) != 0) newtMods |= com.jogamp.newt.InputEvent.ALT_MASK;
- if ((mods & InputEvent.ALT_GRAPH_MASK) != 0) newtMods |= com.jogamp.newt.InputEvent.ALT_GRAPH_MASK;
- return newtMods;
- }
-
- private static int convertButton(MouseEvent e) {
- switch (e.getButton()) {
- case MouseEvent.BUTTON1: return com.jogamp.newt.MouseEvent.BUTTON1;
- case MouseEvent.BUTTON2: return com.jogamp.newt.MouseEvent.BUTTON2;
- case MouseEvent.BUTTON3: return com.jogamp.newt.MouseEvent.BUTTON3;
- }
- return 0;
- }
-
+ protected void dispatchMessagesNative() { /* nop */ }
}
+
diff --git a/src/newt/classes/com/jogamp/newt/awt/AWTWindow.java b/src/newt/classes/com/jogamp/newt/awt/AWTWindow.java
index 7beeed44b..daeaa3e4e 100644
--- a/src/newt/classes/com/jogamp/newt/awt/AWTWindow.java
+++ b/src/newt/classes/com/jogamp/newt/awt/AWTWindow.java
@@ -33,6 +33,8 @@
package com.jogamp.newt.awt;
+import com.jogamp.newt.awt.event.*;
+
import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Container;
@@ -43,7 +45,6 @@ import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
-import java.awt.event.*;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.*;
@@ -119,18 +120,20 @@ public class AWTWindow extends Window {
}
container.setLayout(new BorderLayout());
canvas = new AWTCanvas(caps);
- Listener listener = new Listener(awtWindow);
- canvas.addMouseListener(listener);
- canvas.addMouseMotionListener(listener);
- canvas.addKeyListener(listener);
- canvas.addComponentListener(listener);
+
+ addWindowListener(new LocalWindowListener());
+
+ new AWTMouseAdapter(awtWindow).addTo(canvas); // fwd all AWT Mouse events to here
+ new AWTKeyAdapter(awtWindow).addTo(canvas); // fwd all AWT Key events to here
+
+ // canvas.addComponentListener(listener);
container.add(canvas, BorderLayout.CENTER);
container.setSize(width, height);
container.setLocation(x, y);
- container.addComponentListener(new MoveListener(awtWindow));
+ new AWTWindowAdapter(awtWindow).addTo(container); // fwd all AWT Window events to here
+
if(null!=frame) {
frame.setUndecorated(undecorated||fullscreen);
- frame.addWindowListener(new WindowEventListener(awtWindow));
}
}
});
@@ -315,127 +318,18 @@ public class AWTWindow extends Window {
}
}
- private static final int WINDOW_EVENT = 1;
- private static final int KEY_EVENT = 2;
- private static final int MOUSE_EVENT = 3;
-
- class MoveListener implements ComponentListener {
- private AWTWindow window;
- private AWTDisplay display;
-
- public MoveListener(AWTWindow w) {
- window = w;
- display = (AWTDisplay)window.getScreen().getDisplay();
- }
-
- public void componentResized(ComponentEvent e) {
- }
-
- public void componentMoved(ComponentEvent e) {
+ class LocalWindowListener extends com.jogamp.newt.event.WindowAdapter {
+ public void windowMoved(com.jogamp.newt.event.WindowEvent e) {
if(null!=container) {
x = container.getX();
y = container.getY();
}
- display.enqueueEvent(window, com.jogamp.newt.WindowEvent.EVENT_WINDOW_MOVED, null);
- }
-
- public void componentShown(ComponentEvent e) {
- }
-
- public void componentHidden(ComponentEvent e) {
- }
-
- }
-
- class Listener implements ComponentListener, MouseListener, MouseMotionListener, KeyListener {
- private AWTWindow window;
- private AWTDisplay display;
-
- public Listener(AWTWindow w) {
- window = w;
- display = (AWTDisplay)window.getScreen().getDisplay();
- }
-
- public void componentResized(ComponentEvent e) {
- width = canvas.getWidth();
- height = canvas.getHeight();
- display.enqueueEvent(window, com.jogamp.newt.WindowEvent.EVENT_WINDOW_RESIZED, null);
- }
-
- public void componentMoved(ComponentEvent e) {
- }
-
- public void componentShown(ComponentEvent e) {
- }
-
- public void componentHidden(ComponentEvent e) {
- }
-
- public void mouseClicked(MouseEvent e) {
- // We ignore these as we synthesize them ourselves out of
- // mouse pressed and released events
}
-
- public void mouseEntered(MouseEvent e) {
- display.enqueueEvent(window, com.jogamp.newt.MouseEvent.EVENT_MOUSE_ENTERED, e);
- }
-
- public void mouseExited(MouseEvent e) {
- display.enqueueEvent(window, com.jogamp.newt.MouseEvent.EVENT_MOUSE_EXITED, e);
- }
-
- public void mousePressed(MouseEvent e) {
- display.enqueueEvent(window, com.jogamp.newt.MouseEvent.EVENT_MOUSE_PRESSED, e);
- }
-
- public void mouseReleased(MouseEvent e) {
- display.enqueueEvent(window, com.jogamp.newt.MouseEvent.EVENT_MOUSE_RELEASED, e);
- }
-
- public void mouseMoved(MouseEvent e) {
- display.enqueueEvent(window, com.jogamp.newt.MouseEvent.EVENT_MOUSE_MOVED, e);
- }
-
- public void mouseDragged(MouseEvent e) {
- display.enqueueEvent(window, com.jogamp.newt.MouseEvent.EVENT_MOUSE_DRAGGED, e);
- }
-
- public void keyPressed(KeyEvent e) {
- display.enqueueEvent(window, com.jogamp.newt.KeyEvent.EVENT_KEY_PRESSED, e);
- }
-
- public void keyReleased(KeyEvent e) {
- display.enqueueEvent(window, com.jogamp.newt.KeyEvent.EVENT_KEY_RELEASED, e);
- }
-
- public void keyTyped(KeyEvent e) {
- display.enqueueEvent(window, com.jogamp.newt.KeyEvent.EVENT_KEY_TYPED, e);
- }
- }
-
- class WindowEventListener implements WindowListener {
- private AWTWindow window;
- private AWTDisplay display;
-
- public WindowEventListener(AWTWindow w) {
- window = w;
- display = (AWTDisplay)window.getScreen().getDisplay();
- }
-
- public void windowActivated(WindowEvent e) {
- }
- public void windowClosed(WindowEvent e) {
- }
- public void windowClosing(WindowEvent e) {
- display.enqueueEvent(window, com.jogamp.newt.WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY, null);
- }
- public void windowDeactivated(WindowEvent e) {
- }
- public void windowDeiconified(WindowEvent e) {
- }
- public void windowIconified(WindowEvent e) {
- }
- public void windowOpened(WindowEvent e) {
+ public void windowResized(com.jogamp.newt.event.WindowEvent e) {
+ if(null!=canvas) {
+ width = canvas.getWidth();
+ height = canvas.getHeight();
+ }
}
}
}
diff --git a/src/newt/classes/com/jogamp/newt/awt/event/AWTAdapter.java b/src/newt/classes/com/jogamp/newt/awt/event/AWTAdapter.java
new file mode 100644
index 000000000..345eb02b9
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/awt/event/AWTAdapter.java
@@ -0,0 +1,155 @@
+/*
+ * Copyright (c) 2010 Sven Gothel. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name Sven Gothel or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+package com.jogamp.newt.awt.event;
+
+/**
+ * Convenient adapter forwarding AWT events to NEWT via the event listener model.<br>
+ *
+ * You may attach an instance of this adapter to an AWT Component. When an event happen,
+ * it is converted to a NEWT event and the given NEWT listener is being called.<br>
+ *
+ * This adapter fullfills three use cases. First as a plain utility to write code AWT agnostic,
+ * ie write an {@link javax.media.opengl.GLEvenListener} and some appropriate NEWT {@link com.jogamp.newt.event.EventListener}.<br>
+ *
+ * Attach the {@link javax.media.opengl.GLEvenListener} to a NEWT {@link javax.media.opengl.GLAutoDrawable}, e.g. {@link com.jogamp.newt.opengl.GLWindow},
+ * or to an AWT {@link javax.media.opengl.GLAutoDrawable}, e.g. {@link javax.media.opengl.awt.GLCanvas}.<br>
+ * Attach the NEWT {@link com.jogamp.newt.event.EventListener} to a NEWT component, e.g. {@link com.jogamp.newt.Window},
+ * or to an AWT component, e.g. {@link java.awt.Component}.<br><br>
+ * <code>
+ javax.media.opengl.GLEvenListener demo1 = new javax.media.opengl.GLEvenListener() { ... } ;
+ com.jogamp.newt.event.MouseListener mouseListener = new com.jogamp.newt.event.MouseAdapter() { ... } ;
+
+ // NEWT Usage
+ GLWindow glWindow = GLWindow.create();
+ glWindow.addGLEventListener(demo1);
+ glWindow.addMouseListener(mouseListener);
+ ..
+
+ // AWT Usage
+ GLCanvas glCanvas = new GLCanvas();
+ glCanvas.addGLEventListener(demo1);
+ new AWTMouseAdapter(mouseListener).addTo(glCanvas);
+
+ // This last line is nothing else but a simplified form of:
+ AWTMouseAdapter mouseAdapter = new AWTMouseAdapter(mouseListener);
+ glCanvas.addMouseListener(mouseAdapter);
+ glCanvas.addMouseMotionListener(mouseAdapter);
+ * </code>
+ *
+ * Second is just a litte variation, where we pass a NEWT Window
+ * to impersonate as the source of the event.<br>
+ *
+ * <code>
+ com.jogamp.newt.event.MouseListener mouseListener = new com.jogamp.newt.event.MouseAdapter() { ... } ;
+ Component comp = ... ; // the AWT component
+ GLWindow glWindow = GLWindow.create(); // the NEWT component
+
+ new AWTMouseAdapter(mouseListener, glWindow).addTo(comp);
+ * </code>
+ *
+ * Last but not least, the AWTAdapter maybe used as a general AWT event forwarder to NEWT.<br>
+ *
+ * <code>
+ com.jogamp.newt.event.MouseListener mouseListener = new com.jogamp.newt.event.MouseAdapter() { ... } ;
+ Component comp = ... ; // the AWT component
+ GLWindow glWindow = GLWindow.create(); // the NEWT component
+ glWindow.addMouseListener(mouseListener); // add the custom EventListener to the NEWT component
+
+ new AWTMouseAdapter(glWindow).addTo(comp); // forward all AWT events to glWindow, as NEWT events
+ * </code>
+ *
+ * </code>
+ *
+ * @see #attachTo
+ */
+public abstract class AWTAdapter implements java.util.EventListener
+{
+ com.jogamp.newt.event.EventListener newtListener;
+ com.jogamp.newt.Window newtWindow;
+
+ /**
+ * Simply wrap aroung a NEWT EventListener, exposed as an AWT EventListener.<br>
+ * The NEWT EventListener will be called when an event happens.<br>
+ */
+ public AWTAdapter(com.jogamp.newt.event.EventListener newtListener) {
+ if(null==newtListener) {
+ throw new RuntimeException("Argument newtListener is null");
+ }
+ this.newtListener = newtListener;
+ this.newtWindow = null;
+ }
+
+ /**
+ * Wrap aroung a NEWT EventListener, exposed as an AWT EventListener,<br>
+ * where the given NEWT Window impersonates as the event's source.
+ * The NEWT EventListener will be called when an event happens.<br>
+ */
+ public AWTAdapter(com.jogamp.newt.event.EventListener newtListener, com.jogamp.newt.Window newtProxy) {
+ if(null==newtListener) {
+ throw new RuntimeException("Argument newtListener is null");
+ }
+ if(null==newtProxy) {
+ throw new RuntimeException("Argument newtProxy is null");
+ }
+ this.newtListener = newtListener;
+ this.newtWindow = newtProxy;
+ }
+
+ /**
+ * Create a pipeline adapter, AWT EventListener.<br>
+ * Once attached to an AWT component, it sends the converted AWT events to the NEWT downstream window.<br>
+ */
+ public AWTAdapter(com.jogamp.newt.Window downstream) {
+ if(null==downstream) {
+ throw new RuntimeException("Argument downstream is null");
+ }
+ this.newtListener = null;
+ this.newtWindow = downstream;
+ }
+
+ /**
+ * Due to the fact that some NEWT {@link com.jogamp.newt.event.EventListener}
+ * are mapped to more than one {@link java.util.EventListener},
+ * this method is for your convenience to use this Adapter as a listener for all types.<br>
+ * E.g. {@link com.jogamp.newt.event.MouseListener} is mapped to {@link java.awt.event.MouseListener} and {@link java.awt.event.MouseMotionListener}.
+ */
+ public abstract AWTAdapter addTo(java.awt.Component awtComponent);
+
+ void enqueueEvent(com.jogamp.newt.event.Event event) {
+ try {
+ newtWindow.getScreen().getDisplay().enqueueEvent(event);
+ } catch (NullPointerException npe) {
+ /* that's ok .. window might be down already */
+ }
+ }
+}
+
diff --git a/src/newt/classes/com/jogamp/newt/awt/event/AWTKeyAdapter.java b/src/newt/classes/com/jogamp/newt/awt/event/AWTKeyAdapter.java
new file mode 100644
index 000000000..866ec5476
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/awt/event/AWTKeyAdapter.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2010 Sven Gothel. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name Sven Gothel or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+package com.jogamp.newt.awt.event;
+
+public class AWTKeyAdapter extends AWTAdapter implements java.awt.event.KeyListener
+{
+ public AWTKeyAdapter(com.jogamp.newt.event.KeyListener newtListener) {
+ super(newtListener);
+ }
+
+ public AWTKeyAdapter(com.jogamp.newt.event.KeyListener newtListener, com.jogamp.newt.Window newtProxy) {
+ super(newtListener, newtProxy);
+ }
+
+ public AWTKeyAdapter(com.jogamp.newt.Window downstream) {
+ super(downstream);
+ }
+
+ public AWTAdapter addTo(java.awt.Component awtComponent) {
+ awtComponent.addKeyListener(this);
+ return this;
+ }
+
+ public void keyPressed(java.awt.event.KeyEvent e) {
+ com.jogamp.newt.event.KeyEvent event = AWTNewtEventFactory.createKeyEvent(e, newtWindow);
+ if(null!=newtListener) {
+ ((com.jogamp.newt.event.KeyListener)newtListener).keyPressed(event);
+ } else {
+ enqueueEvent(event);
+ }
+ }
+
+ public void keyReleased(java.awt.event.KeyEvent e) {
+ com.jogamp.newt.event.KeyEvent event = AWTNewtEventFactory.createKeyEvent(e, newtWindow);
+ if(null!=newtListener) {
+ ((com.jogamp.newt.event.KeyListener)newtListener).keyReleased(event);
+ } else {
+ enqueueEvent(event);
+ }
+ }
+
+ public void keyTyped(java.awt.event.KeyEvent e) {
+ com.jogamp.newt.event.KeyEvent event = AWTNewtEventFactory.createKeyEvent(e, newtWindow);
+ if(null!=newtListener) {
+ ((com.jogamp.newt.event.KeyListener)newtListener).keyTyped(event);
+ } else {
+ enqueueEvent(event);
+ }
+ }
+}
+
diff --git a/src/newt/classes/com/jogamp/newt/awt/event/AWTMouseAdapter.java b/src/newt/classes/com/jogamp/newt/awt/event/AWTMouseAdapter.java
new file mode 100644
index 000000000..db28616b9
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/awt/event/AWTMouseAdapter.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2010 Sven Gothel. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name Sven Gothel or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+package com.jogamp.newt.awt.event;
+
+public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener
+{
+ public AWTMouseAdapter(com.jogamp.newt.event.MouseListener newtListener) {
+ super(newtListener);
+ }
+
+ public AWTMouseAdapter(com.jogamp.newt.event.MouseListener newtListener, com.jogamp.newt.Window newtProxy) {
+ super(newtListener, newtProxy);
+ }
+
+ public AWTMouseAdapter(com.jogamp.newt.Window downstream) {
+ super(downstream);
+ }
+
+ public AWTAdapter addTo(java.awt.Component awtComponent) {
+ awtComponent.addMouseListener(this);
+ awtComponent.addMouseMotionListener(this);
+ return this;
+ }
+
+ public void mouseClicked(java.awt.event.MouseEvent e) {
+ com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow);
+ if(null!=newtListener) {
+ ((com.jogamp.newt.event.MouseListener)newtListener).mouseClicked(event);
+ } else {
+ enqueueEvent(event);
+ }
+ }
+
+ public void mouseEntered(java.awt.event.MouseEvent e) {
+ com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow);
+ if(null!=newtListener) {
+ ((com.jogamp.newt.event.MouseListener)newtListener).mouseEntered(event);
+ } else {
+ enqueueEvent(event);
+ }
+ }
+
+ public void mouseExited(java.awt.event.MouseEvent e) {
+ com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow);
+ if(null!=newtListener) {
+ ((com.jogamp.newt.event.MouseListener)newtListener).mouseExited(event);
+ } else {
+ enqueueEvent(event);
+ }
+ }
+
+ public void mousePressed(java.awt.event.MouseEvent e) {
+ com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow);
+ if(null!=newtListener) {
+ ((com.jogamp.newt.event.MouseListener)newtListener).mousePressed(event);
+ } else {
+ enqueueEvent(event);
+ }
+ }
+
+ public void mouseReleased(java.awt.event.MouseEvent e) {
+ com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow);
+ if(null!=newtListener) {
+ ((com.jogamp.newt.event.MouseListener)newtListener).mouseReleased(event);
+ } else {
+ enqueueEvent(event);
+ }
+ }
+
+ public void mouseDragged(java.awt.event.MouseEvent e) {
+ com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow);
+ if(null!=newtListener) {
+ ((com.jogamp.newt.event.MouseListener)newtListener).mouseDragged(event);
+ } else {
+ enqueueEvent(event);
+ }
+ }
+
+ public void mouseMoved(java.awt.event.MouseEvent e) {
+ com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow);
+ if(null!=newtListener) {
+ ((com.jogamp.newt.event.MouseListener)newtListener).mouseMoved(event);
+ } else {
+ enqueueEvent(event);
+ }
+ }
+}
+
diff --git a/src/newt/classes/com/jogamp/newt/awt/event/AWTNewtEventFactory.java b/src/newt/classes/com/jogamp/newt/awt/event/AWTNewtEventFactory.java
new file mode 100644
index 000000000..ea10c9de5
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/awt/event/AWTNewtEventFactory.java
@@ -0,0 +1,140 @@
+
+/*
+ * Copyright (c) 2010 Sven Gothel. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name Sven Gothel or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+package com.jogamp.newt.awt.event;
+
+import com.jogamp.common.util.IntIntHashMap;
+
+class AWTNewtEventFactory {
+
+ protected static final IntIntHashMap eventTypeAWT2NEWT;
+
+ static {
+ IntIntHashMap map = new IntIntHashMap();
+ map.setKeyNotFoundValue(-1);
+ // n/a map.put(java.awt.event.WindowEvent.WINDOW_OPENED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_OPENED);
+ map.put(java.awt.event.WindowEvent.WINDOW_CLOSING, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY);
+ // n/a map.put(java.awt.event.WindowEvent.WINDOW_CLOSED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_CLOSED);
+ // n/a map.put(java.awt.event.WindowEvent.WINDOW_ICONIFIED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_ICONIFIED);
+ // n/a map.put(java.awt.event.WindowEvent.WINDOW_DEICONIFIED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_DEICONIFIED);
+ map.put(java.awt.event.WindowEvent.WINDOW_ACTIVATED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_GAINED_FOCUS);
+ map.put(java.awt.event.WindowEvent.WINDOW_GAINED_FOCUS, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_GAINED_FOCUS);
+ map.put(java.awt.event.WindowEvent.WINDOW_DEACTIVATED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_LOST_FOCUS);
+ map.put(java.awt.event.WindowEvent.WINDOW_LOST_FOCUS, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_LOST_FOCUS);
+ // n/a map.put(java.awt.event.WindowEvent.WINDOW_STATE_CHANGED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_STATE_CHANGED);
+
+ map.put(java.awt.event.ComponentEvent.COMPONENT_MOVED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_MOVED);
+ map.put(java.awt.event.ComponentEvent.COMPONENT_RESIZED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_RESIZED);
+ // n/a map.put(java.awt.event.ComponentEvent.COMPONENT_SHOWN, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_SHOWN);
+ // n/a map.put(java.awt.event.ComponentEvent.COMPONENT_HIDDEN, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_HIDDEN);
+
+ map.put(java.awt.event.MouseEvent.MOUSE_CLICKED, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_CLICKED);
+ map.put(java.awt.event.MouseEvent.MOUSE_PRESSED, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED);
+ map.put(java.awt.event.MouseEvent.MOUSE_RELEASED, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED);
+ map.put(java.awt.event.MouseEvent.MOUSE_MOVED, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_MOVED);
+ map.put(java.awt.event.MouseEvent.MOUSE_ENTERED, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_ENTERED);
+ map.put(java.awt.event.MouseEvent.MOUSE_EXITED, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_EXITED);
+ map.put(java.awt.event.MouseEvent.MOUSE_DRAGGED, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_DRAGGED);
+ map.put(java.awt.event.MouseEvent.MOUSE_WHEEL, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_WHEEL_MOVED);
+
+ map.put(java.awt.event.KeyEvent.KEY_PRESSED, com.jogamp.newt.event.KeyEvent.EVENT_KEY_PRESSED);
+ map.put(java.awt.event.KeyEvent.KEY_RELEASED, com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED);
+ map.put(java.awt.event.KeyEvent.KEY_TYPED, com.jogamp.newt.event.KeyEvent.EVENT_KEY_TYPED);
+
+ eventTypeAWT2NEWT = map;
+ }
+
+ public static final int awtModifiers2Newt(int awtMods, boolean mouseHint) {
+ int newtMods = 0;
+ if ((awtMods & java.awt.event.InputEvent.SHIFT_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.SHIFT_MASK;
+ if ((awtMods & java.awt.event.InputEvent.CTRL_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.CTRL_MASK;
+ if ((awtMods & java.awt.event.InputEvent.META_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.META_MASK;
+ if ((awtMods & java.awt.event.InputEvent.ALT_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.ALT_MASK;
+ if ((awtMods & java.awt.event.InputEvent.ALT_GRAPH_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.ALT_GRAPH_MASK;
+ return newtMods;
+ }
+
+ public static final int awtButton2Newt(int awtButton) {
+ switch (awtButton) {
+ case java.awt.event.MouseEvent.BUTTON1: return com.jogamp.newt.event.MouseEvent.BUTTON1;
+ case java.awt.event.MouseEvent.BUTTON2: return com.jogamp.newt.event.MouseEvent.BUTTON2;
+ case java.awt.event.MouseEvent.BUTTON3: return com.jogamp.newt.event.MouseEvent.BUTTON3;
+ }
+ return 0;
+ }
+
+ static final com.jogamp.newt.event.WindowEvent createWindowEvent(java.awt.event.WindowEvent event, com.jogamp.newt.Window newtSource) {
+ int type = eventTypeAWT2NEWT.get(event.getID());
+ if(-1 < type) {
+ return new com.jogamp.newt.event.WindowEvent(type, ((null==newtSource)?(Object)event.getComponent():(Object)newtSource), System.currentTimeMillis());
+ }
+ return null; // no mapping ..
+ }
+
+ static final com.jogamp.newt.event.WindowEvent createWindowEvent(java.awt.event.ComponentEvent event, com.jogamp.newt.Window newtSource) {
+ int type = eventTypeAWT2NEWT.get(event.getID());
+ if(-1 < type) {
+ return new com.jogamp.newt.event.WindowEvent(type, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, System.currentTimeMillis());
+ }
+ return null; // no mapping ..
+ }
+
+ static final com.jogamp.newt.event.MouseEvent createMouseEvent(java.awt.event.MouseEvent event, com.jogamp.newt.Window newtSource) {
+ int type = eventTypeAWT2NEWT.get(event.getID());
+ if(-1 < type) {
+ int rotation = 0;
+ if (event instanceof java.awt.event.MouseWheelEvent) {
+ rotation = ((java.awt.event.MouseWheelEvent)event).getWheelRotation();
+ }
+
+ return new com.jogamp.newt.event.MouseEvent(
+ type, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, event.getWhen(),
+ awtModifiers2Newt(event.getModifiers(), true),
+ event.getX(), event.getY(), event.getClickCount(),
+ awtButton2Newt(event.getButton()), rotation);
+ }
+ return null; // no mapping ..
+ }
+
+ static final com.jogamp.newt.event.KeyEvent createKeyEvent(java.awt.event.KeyEvent event, com.jogamp.newt.Window newtSource) {
+ int type = eventTypeAWT2NEWT.get(event.getID());
+ if(-1 < type) {
+ return new com.jogamp.newt.event.KeyEvent(
+ type, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, event.getWhen(),
+ awtModifiers2Newt(event.getModifiers(), false),
+ event.getKeyCode(), event.getKeyChar());
+ }
+ return null; // no mapping ..
+ }
+
+}
+
diff --git a/src/newt/classes/com/jogamp/newt/awt/event/AWTWindowAdapter.java b/src/newt/classes/com/jogamp/newt/awt/event/AWTWindowAdapter.java
new file mode 100644
index 000000000..d17bac242
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/awt/event/AWTWindowAdapter.java
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2010 Sven Gothel. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name Sven Gothel or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+package com.jogamp.newt.awt.event;
+
+public class AWTWindowAdapter extends AWTAdapter implements java.awt.event.ComponentListener, java.awt.event.WindowListener
+{
+ public AWTWindowAdapter(com.jogamp.newt.event.WindowListener newtListener) {
+ super(newtListener);
+ }
+
+ public AWTWindowAdapter(com.jogamp.newt.event.WindowListener newtListener, com.jogamp.newt.Window newtProxy) {
+ super(newtListener, newtProxy);
+ }
+
+ public AWTWindowAdapter(com.jogamp.newt.Window downstream) {
+ super(downstream);
+ }
+
+ public AWTAdapter addTo(java.awt.Component awtComponent) {
+ awtComponent.addComponentListener(this);
+ if(awtComponent instanceof java.awt.Window) {
+ ((java.awt.Window)awtComponent).addWindowListener(this);
+ }
+ return this;
+ }
+
+ public void componentResized(java.awt.event.ComponentEvent e) {
+ com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
+ if(null!=newtListener) {
+ ((com.jogamp.newt.event.WindowListener)newtListener).windowResized(event);
+ } else {
+ enqueueEvent(event);
+ }
+ }
+
+ public void componentMoved(java.awt.event.ComponentEvent e) {
+ com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
+ if(null!=newtListener) {
+ ((com.jogamp.newt.event.WindowListener)newtListener).windowMoved(event);
+ } else {
+ enqueueEvent(event);
+ }
+ }
+
+ public void componentShown(java.awt.event.ComponentEvent e) {
+ // n/a
+ }
+
+ public void componentHidden(java.awt.event.ComponentEvent e) {
+ // n/a
+ }
+
+ public void windowActivated(java.awt.event.WindowEvent e) {
+ com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
+ if(null!=newtListener) {
+ ((com.jogamp.newt.event.WindowListener)newtListener).windowGainedFocus(event);
+ } else {
+ enqueueEvent(event);
+ }
+ }
+
+ public void windowClosed(java.awt.event.WindowEvent e) {
+ // n/a
+ }
+
+ public void windowClosing(java.awt.event.WindowEvent e) {
+ com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
+ if(null!=newtListener) {
+ ((com.jogamp.newt.event.WindowListener)newtListener).windowDestroyNotify(event);
+ } else {
+ enqueueEvent(event);
+ }
+ }
+
+ public void windowDeactivated(java.awt.event.WindowEvent e) {
+ com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
+ if(null!=newtListener) {
+ ((com.jogamp.newt.event.WindowListener)newtListener).windowLostFocus(event);
+ } else {
+ enqueueEvent(event);
+ }
+ }
+
+ public void windowDeiconified(java.awt.event.WindowEvent e) {
+ // n/a
+ }
+
+ public void windowIconified(java.awt.event.WindowEvent e) {
+ // n/a
+ }
+
+ public void windowOpened(java.awt.event.WindowEvent e) {
+ // n/a
+ }
+
+}
+
diff --git a/src/newt/classes/com/jogamp/newt/event/Event.java b/src/newt/classes/com/jogamp/newt/event/Event.java
index d42a95735..d93995ead 100644
--- a/src/newt/classes/com/jogamp/newt/event/Event.java
+++ b/src/newt/classes/com/jogamp/newt/event/Event.java
@@ -31,25 +31,78 @@
*
*/
-package com.jogamp.newt;
+package com.jogamp.newt.event;
+
+import com.jogamp.newt.*;
+import java.util.*;
public class Event {
private boolean isSystemEvent;
private int eventType;
- private Window source;
+ private Object source;
private long when;
- Event(boolean isSystemEvent, int eventType, Window source, long when) {
- this.isSystemEvent = isSystemEvent;
+ static final boolean DEBUG = false;
+
+ // 0: Event.java
+ // 1: InputEvent.java
+ // 2: KeyEvent.java
+ // 3: com.jogamp.newt.Window
+ // 3: com.jogamp.newt.awt.event.AWTNewtEventFactory
+ // 2: MouseEvent.java
+ // 3: com.jogamp.newt.Window
+ // 3: com.jogamp.newt.awt.event.AWTNewtEventFactory
+ // 1: PaintEvent.java
+ // 2: com.jogamp.newt.Window
+ // 2: com.jogamp.newt.awt.event.AWTNewtEventFactory
+ // 1: WindowEvent.java
+ // 2: com.jogamp.newt.Window
+ // 2: com.jogamp.newt.awt.event.AWTNewtEventFactory
+ //
+ static final String WindowClazzName = "com.jogamp.newt.Window" ;
+ static final String AWTNewtEventFactoryClazzName = "com.jogamp.newt.awt.event.AWTNewtEventFactory" ;
+
+ static final boolean evaluateIsSystemEvent(Event event, Throwable t) {
+ StackTraceElement[] stack = t.getStackTrace();
+ if(stack.length==0 || null==stack[0]) {
+ return false;
+ }
+ if(DEBUG) {
+ for (int i = 0; i < stack.length && i<5; i++) {
+ System.out.println(i+": " + stack[i].getClassName()+ "." + stack[i].getMethodName());
+ }
+ }
+
+ String clazzName = null;
+
+ if( (event instanceof com.jogamp.newt.event.WindowEvent) ||
+ (event instanceof com.jogamp.newt.event.PaintEvent) ) {
+ if ( stack.length > 2 ) {
+ clazzName = stack[2].getClassName();
+ }
+ } else if( (event instanceof com.jogamp.newt.event.MouseEvent) ||
+ (event instanceof com.jogamp.newt.event.KeyEvent) ) {
+ if ( stack.length > 3 ) {
+ clazzName = stack[3].getClassName();
+ }
+ }
+
+ boolean res = null!=clazzName && (
+ clazzName.equals(WindowClazzName) ||
+ clazzName.equals(AWTNewtEventFactoryClazzName) ) ;
+ if(DEBUG) {
+ System.out.println("system: "+res);
+ }
+ return res;
+ }
+
+ protected Event(int eventType, Object source, long when) {
+ this.isSystemEvent = evaluateIsSystemEvent(this, new Throwable());
this.eventType = eventType;
this.source = source;
this.when = when;
}
- protected Event(int eventType, Window source, long when) {
- this(false, eventType, source, when);
- }
-
/** Indicates whether this event was produced by the system or
generated by user code. */
public final boolean isSystemEvent() {
@@ -61,8 +114,8 @@ public class Event {
return eventType;
}
- /** Returns the source Window which produced this Event. */
- public final Window getSource() {
+ /** Returns the source Object which produced this Event. */
+ public final Object getSource() {
return source;
}
diff --git a/src/newt/classes/com/jogamp/newt/event/KeyAdapter.java b/src/newt/classes/com/jogamp/newt/event/KeyAdapter.java
new file mode 100644
index 000000000..22b4cf1f7
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/event/KeyAdapter.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2010 Sven Gothel. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name Sven Gothel or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+package com.jogamp.newt.event;
+
+import com.jogamp.newt.*;
+
+public abstract class KeyAdapter implements KeyListener
+{
+ public void keyPressed(KeyEvent e) {
+ }
+ public void keyReleased(KeyEvent e) {
+ }
+ public void keyTyped(KeyEvent e) {
+ }
+}
+
diff --git a/src/newt/classes/com/jogamp/newt/event/MouseAdapter.java b/src/newt/classes/com/jogamp/newt/event/MouseAdapter.java
new file mode 100644
index 000000000..b7428e313
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/event/MouseAdapter.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2010 Sven Gothel. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name Sven Gothel or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+package com.jogamp.newt.event;
+
+import com.jogamp.newt.*;
+
+public abstract class MouseAdapter implements MouseListener
+{
+ public void mouseClicked(MouseEvent e) {
+ }
+ public void mouseEntered(MouseEvent e) {
+ }
+ public void mouseExited(MouseEvent e) {
+ }
+ public void mousePressed(MouseEvent e) {
+ }
+ public void mouseReleased(MouseEvent e) {
+ }
+ public void mouseMoved(MouseEvent e) {
+ }
+ public void mouseDragged(MouseEvent e) {
+ }
+ public void mouseWheelMoved(MouseEvent e) {
+ }
+}
+
diff --git a/src/newt/classes/com/jogamp/newt/event/WindowAdapter.java b/src/newt/classes/com/jogamp/newt/event/WindowAdapter.java
new file mode 100644
index 000000000..51732789e
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/event/WindowAdapter.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2010 Sven Gothel. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name Sven Gothel or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+package com.jogamp.newt.event;
+
+import com.jogamp.newt.*;
+
+public abstract class WindowAdapter implements WindowListener
+{
+ public void windowResized(WindowEvent e) {
+ }
+ public void windowMoved(WindowEvent e) {
+ }
+ public void windowDestroyNotify(WindowEvent e) {
+ }
+ public void windowGainedFocus(WindowEvent e) {
+ }
+ public void windowLostFocus(WindowEvent e) {
+ }
+}
diff --git a/src/newt/classes/com/jogamp/newt/intel/gdl/Display.java b/src/newt/classes/com/jogamp/newt/intel/gdl/Display.java
index a3e5501c4..f79573644 100644
--- a/src/newt/classes/com/jogamp/newt/intel/gdl/Display.java
+++ b/src/newt/classes/com/jogamp/newt/intel/gdl/Display.java
@@ -85,7 +85,7 @@ public class Display extends com.jogamp.newt.Display {
}
}
- protected void dispatchMessages() {
+ protected void dispatchMessagesNative() {
if(0!=displayHandle) {
DispatchMessages(displayHandle, focusedWindow);
}
diff --git a/src/newt/classes/com/jogamp/newt/macosx/MacDisplay.java b/src/newt/classes/com/jogamp/newt/macosx/MacDisplay.java
index 0b5297685..cf67537ae 100755
--- a/src/newt/classes/com/jogamp/newt/macosx/MacDisplay.java
+++ b/src/newt/classes/com/jogamp/newt/macosx/MacDisplay.java
@@ -66,7 +66,7 @@ public class MacDisplay extends Display {
}
private DispatchAction dispatchAction = new DispatchAction();
- public void dispatchMessages() {
+ protected void dispatchMessagesNative() {
MainThread.invoke(false, dispatchAction);
}
diff --git a/src/newt/classes/com/jogamp/newt/macosx/MacWindow.java b/src/newt/classes/com/jogamp/newt/macosx/MacWindow.java
index 52d6fb0c7..8762d106c 100755
--- a/src/newt/classes/com/jogamp/newt/macosx/MacWindow.java
+++ b/src/newt/classes/com/jogamp/newt/macosx/MacWindow.java
@@ -37,6 +37,7 @@ import javax.media.nativewindow.*;
import com.jogamp.newt.util.MainThread;
import com.jogamp.newt.*;
+import com.jogamp.newt.event.*;
import com.jogamp.newt.impl.*;
public class MacWindow extends Window {
diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
index fec70c99c..0bbd38a4e 100644
--- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
+++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
@@ -34,6 +34,7 @@
package com.jogamp.newt.opengl;
import com.jogamp.newt.*;
+import com.jogamp.newt.event.*;
import javax.media.nativewindow.*;
import javax.media.opengl.*;
import com.jogamp.opengl.impl.GLDrawableHelper;
@@ -66,20 +67,11 @@ public class GLWindow extends Window implements GLAutoDrawable {
this.window = window;
this.window.setAutoDrawableClient(true);
this.runPumpMessages = ( null == getScreen().getDisplay().getEDTUtil() ) ;
- window.addWindowListener(new WindowListener() {
+ window.addWindowListener(new WindowAdapter() {
public void windowResized(WindowEvent e) {
sendReshape = true;
}
- public void windowMoved(WindowEvent e) {
- }
-
- public void windowGainedFocus(WindowEvent e) {
- }
-
- public void windowLostFocus(WindowEvent e) {
- }
-
public void windowDestroyNotify(WindowEvent e) {
sendDestroy = true;
}
diff --git a/src/newt/classes/com/jogamp/newt/opengl/broadcom/egl/Display.java b/src/newt/classes/com/jogamp/newt/opengl/broadcom/egl/Display.java
index 999a407ec..7db5b18dd 100644
--- a/src/newt/classes/com/jogamp/newt/opengl/broadcom/egl/Display.java
+++ b/src/newt/classes/com/jogamp/newt/opengl/broadcom/egl/Display.java
@@ -70,7 +70,7 @@ public class Display extends com.jogamp.newt.Display {
}
}
- protected void dispatchMessages() {
+ protected void dispatchMessagesNative() {
// n/a .. DispatchMessages();
}
diff --git a/src/newt/classes/com/jogamp/newt/opengl/kd/KDDisplay.java b/src/newt/classes/com/jogamp/newt/opengl/kd/KDDisplay.java
index 6a28f992b..8a8e2a7c3 100755
--- a/src/newt/classes/com/jogamp/newt/opengl/kd/KDDisplay.java
+++ b/src/newt/classes/com/jogamp/newt/opengl/kd/KDDisplay.java
@@ -75,7 +75,7 @@ public class KDDisplay extends Display {
}
}
- protected void dispatchMessages() {
+ protected void dispatchMessagesNative() {
DispatchMessages();
}
diff --git a/src/newt/classes/com/jogamp/newt/opengl/kd/KDWindow.java b/src/newt/classes/com/jogamp/newt/opengl/kd/KDWindow.java
index 555f54599..c8bed8a68 100755
--- a/src/newt/classes/com/jogamp/newt/opengl/kd/KDWindow.java
+++ b/src/newt/classes/com/jogamp/newt/opengl/kd/KDWindow.java
@@ -34,6 +34,7 @@
package com.jogamp.newt.opengl.kd;
import com.jogamp.newt.*;
+import com.jogamp.newt.event.*;
import com.jogamp.newt.impl.*;
import com.jogamp.opengl.impl.egl.*;
import javax.media.nativewindow.*;
diff --git a/src/newt/classes/com/jogamp/newt/windows/WindowsDisplay.java b/src/newt/classes/com/jogamp/newt/windows/WindowsDisplay.java
index 281022901..678777e81 100755
--- a/src/newt/classes/com/jogamp/newt/windows/WindowsDisplay.java
+++ b/src/newt/classes/com/jogamp/newt/windows/WindowsDisplay.java
@@ -69,7 +69,7 @@ public class WindowsDisplay extends Display {
// UnregisterWindowClass(getWindowClassAtom(), getHInstance());
}
- protected void dispatchMessages() {
+ protected void dispatchMessagesNative() {
DispatchMessages();
}
diff --git a/src/newt/classes/com/jogamp/newt/windows/WindowsWindow.java b/src/newt/classes/com/jogamp/newt/windows/WindowsWindow.java
index 4a468ae86..db1ae4718 100755
--- a/src/newt/classes/com/jogamp/newt/windows/WindowsWindow.java
+++ b/src/newt/classes/com/jogamp/newt/windows/WindowsWindow.java
@@ -35,6 +35,7 @@ package com.jogamp.newt.windows;
import javax.media.nativewindow.*;
import com.jogamp.newt.*;
+import com.jogamp.newt.event.*;
public class WindowsWindow extends Window {
diff --git a/src/newt/classes/com/jogamp/newt/x11/X11Display.java b/src/newt/classes/com/jogamp/newt/x11/X11Display.java
index c8faefbf1..70e002e9e 100755
--- a/src/newt/classes/com/jogamp/newt/x11/X11Display.java
+++ b/src/newt/classes/com/jogamp/newt/x11/X11Display.java
@@ -78,7 +78,7 @@ public class X11Display extends Display {
X11Util.closeThreadLocalDisplay(name);
}
- protected void dispatchMessages() {
+ protected void dispatchMessagesNative() {
DispatchMessages(getHandle(), javaObjectAtom, windowDeleteAtom);
}
diff --git a/src/newt/classes/com/jogamp/newt/x11/X11Window.java b/src/newt/classes/com/jogamp/newt/x11/X11Window.java
index cc3aa58a2..59ecc3bab 100755
--- a/src/newt/classes/com/jogamp/newt/x11/X11Window.java
+++ b/src/newt/classes/com/jogamp/newt/x11/X11Window.java
@@ -34,6 +34,7 @@
package com.jogamp.newt.x11;
import com.jogamp.newt.*;
+import com.jogamp.newt.event.*;
import javax.media.nativewindow.*;
import javax.media.nativewindow.x11.*;