diff options
author | Sven Gothel <[email protected]> | 2014-06-06 12:51:45 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-06-06 12:51:45 +0200 |
commit | ebe980ad6ac40148bc84913d1ba1f7adf6200490 (patch) | |
tree | 75227f5cbfd131ddb4dd2c9e0d3a8b4318a0cde9 | |
parent | 026cade97eab6fbd04e8bc902f24a2b61723acb8 (diff) |
Bug 741 HiDPI: Add new NativeSurfaceHolder interface to GLDrawable and NativeWindow; [AWT|SWT]NewtEventFactory use NativeSurfaceHolder as source, fixes pixel unit conversion
- Add new NativeSurfaceHolder interface to GLDrawable and NativeWindow, allowing NativeSurface access (pixel unit conversion)
A NativeSurfaceHolder is e.g.:
- NativeWindow (is-a)
- NEWT [GL]Window
- GLDrawable (has-a)
- [AWT|SWT]GLCanvas
- [AWT|SWT]NewtEventFactory use NativeSurfaceHolder as source, fixes pixel unit conversion
40 files changed, 561 insertions, 413 deletions
diff --git a/src/jogl/classes/javax/media/opengl/GLDrawable.java b/src/jogl/classes/javax/media/opengl/GLDrawable.java index e93d1c3ad..57883c8ac 100644 --- a/src/jogl/classes/javax/media/opengl/GLDrawable.java +++ b/src/jogl/classes/javax/media/opengl/GLDrawable.java @@ -42,6 +42,7 @@ package javax.media.opengl; import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.NativeSurfaceHolder; /** An abstraction for an OpenGL rendering target. A GLDrawable's @@ -50,7 +51,7 @@ import javax.media.nativewindow.NativeSurface; create an OpenGL context, but all implementations of {@link GLAutoDrawable} do so upon creation. */ -public interface GLDrawable { +public interface GLDrawable extends NativeSurfaceHolder { /** * Creates a new context for drawing to this drawable that will * optionally share buffer objects, textures and other server-side OpenGL @@ -190,11 +191,15 @@ public interface GLDrawable { public GLProfile getGLProfile(); /** - * Returns the underlying native surface which surface handle + * {@inheritDoc} + * <p> + * Returns the underlying {@link NativeSurface} which {@link NativeSurface#getSurfaceHandle() native handle} * represents this OpenGL drawable's native resource. + * </p> * * @see #getHandle() */ + @Override public NativeSurface getNativeSurface(); /** diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java index ea6ec893e..690d77901 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java @@ -633,6 +633,9 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, return getHeight() * getPixelScale(); } + @Override + public final NativeSurface getNativeSurface() { return this; } + // // NativeWindow // diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeSurfaceHolder.java b/src/nativewindow/classes/javax/media/nativewindow/NativeSurfaceHolder.java new file mode 100644 index 000000000..b459ab74a --- /dev/null +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeSurfaceHolder.java @@ -0,0 +1,41 @@ +/** + * Copyright 2014 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package javax.media.nativewindow; + +/** + * Accessor interface for implementing classes with ownership of a {@link NativeSurface} + * via an <i>is-a</i> or <i>has-a</i> relation. + */ +public interface NativeSurfaceHolder { + /** + * Returns the associated {@link NativeSurface} of this {@link NativeSurfaceHolder}. + */ + public NativeSurface getNativeSurface(); +} + diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java index 5e5f99aac..7f71bc33b 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java @@ -68,7 +68,16 @@ import javax.media.nativewindow.util.Point; * which can create NativeWindow objects for its components. * </p> */ -public interface NativeWindow extends NativeSurface { +public interface NativeWindow extends NativeSurface, NativeSurfaceHolder { + + /** + * {@inheritDoc} + * <p> + * Returns this instance, which <i>is-a</i> {@link NativeSurface}. + * </p> + */ + @Override + public NativeSurface getNativeSurface(); /** * Destroys this window incl. releasing all related resources. diff --git a/src/nativewindow/classes/jogamp/nativewindow/WrappedWindow.java b/src/nativewindow/classes/jogamp/nativewindow/WrappedWindow.java index b93cbe7f5..403ec83c0 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/WrappedWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/WrappedWindow.java @@ -2,6 +2,7 @@ package jogamp.nativewindow; import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.ProxySurface; import javax.media.nativewindow.UpstreamSurfaceHook; @@ -66,6 +67,9 @@ public class WrappedWindow extends WrappedSurface implements NativeWindow { } @Override + public final NativeSurface getNativeSurface() { return this; } + + @Override public NativeWindow getParent() { return null; } diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index f6b2bab1f..37e9f9813 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -104,7 +104,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto private boolean newtChildAttached = false; private boolean isOnscreen = true; private WindowClosingMode newtChildCloseOp; - private final AWTParentWindowAdapter awtAdapter; + private final AWTParentWindowAdapter awtWinAdapter; private final AWTAdapter awtMouseAdapter; private final AWTAdapter awtKeyAdapter; @@ -140,8 +140,8 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto super(); awtMouseAdapter = new AWTMouseAdapter().addTo(this); awtKeyAdapter = new AWTKeyAdapter().addTo(this); - awtAdapter = (AWTParentWindowAdapter) new AWTParentWindowAdapter().addTo(this); - awtAdapter.removeWindowClosingFrom(this); // we utilize AWTWindowClosingProtocol triggered destruction! + awtWinAdapter = (AWTParentWindowAdapter) new AWTParentWindowAdapter().addTo(this); + awtWinAdapter.removeWindowClosingFrom(this); // we utilize AWTWindowClosingProtocol triggered destruction! } /** @@ -151,8 +151,8 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto super(gc); awtMouseAdapter = new AWTMouseAdapter().addTo(this); awtKeyAdapter = new AWTKeyAdapter().addTo(this); - awtAdapter = (AWTParentWindowAdapter) new AWTParentWindowAdapter().addTo(this); - awtAdapter.removeWindowClosingFrom(this); // we utilize AWTWindowClosingProtocol triggered destruction! + awtWinAdapter = (AWTParentWindowAdapter) new AWTParentWindowAdapter().addTo(this); + awtWinAdapter.removeWindowClosingFrom(this); // we utilize AWTWindowClosingProtocol triggered destruction! } /** @@ -162,8 +162,8 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto super(); awtMouseAdapter = new AWTMouseAdapter().addTo(this); awtKeyAdapter = new AWTKeyAdapter().addTo(this); - awtAdapter = (AWTParentWindowAdapter) new AWTParentWindowAdapter().addTo(this); - awtAdapter.removeWindowClosingFrom(this); // we utilize AWTWindowClosingProtocol triggered destruction! + awtWinAdapter = (AWTParentWindowAdapter) new AWTParentWindowAdapter().addTo(this); + awtWinAdapter.removeWindowClosingFrom(this); // we utilize AWTWindowClosingProtocol triggered destruction! setNEWTChild(child); } @@ -174,8 +174,8 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto super(gc); awtMouseAdapter = new AWTMouseAdapter().addTo(this); awtKeyAdapter = new AWTKeyAdapter().addTo(this); - awtAdapter = (AWTParentWindowAdapter) new AWTParentWindowAdapter().addTo(this); - awtAdapter.removeWindowClosingFrom(this); // we utilize AWTWindowClosingProtocol triggered destruction! + awtWinAdapter = (AWTParentWindowAdapter) new AWTParentWindowAdapter().addTo(this); + awtWinAdapter.removeWindowClosingFrom(this); // we utilize AWTWindowClosingProtocol triggered destruction! setNEWTChild(child); } @@ -779,11 +779,9 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } private final void configureNewtChild(boolean attach) { - awtAdapter.clear(); + awtWinAdapter.clear(); + awtKeyAdapter.clear(); awtMouseAdapter.clear(); - awtKeyAdapter.setConsumeAWTEvent(false); - awtMouseAdapter.clear(); - awtKeyAdapter.setConsumeAWTEvent(false); if(null != keyboardFocusManager) { keyboardFocusManager.removePropertyChangeListener("focusOwner", focusPropertyChangeListener); @@ -797,7 +795,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto throw new InternalError("XXX"); } isOnscreen = jawtWindow.getGraphicsConfiguration().getChosenCapabilities().isOnscreen(); - awtAdapter.setDownstream(jawtWindow, newtChild); + awtWinAdapter.setDownstream(jawtWindow, newtChild); newtChild.addWindowListener(clearAWTMenusOnNewtFocus); newtChild.setFocusAction(focusAction); // enable AWT focus traversal newtChildCloseOp = newtChild.setDefaultCloseOperation(WindowClosingMode.DO_NOTHING_ON_CLOSE); diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java index cf533eb9e..9b1348288 100644 --- a/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java @@ -28,6 +28,8 @@ package com.jogamp.newt.event.awt; +import javax.media.nativewindow.NativeSurfaceHolder; + import jogamp.newt.Debug; /** @@ -117,37 +119,44 @@ public abstract class AWTAdapter implements java.util.EventListener com.jogamp.newt.event.NEWTEventListener newtListener; com.jogamp.newt.Window newtWindow; + NativeSurfaceHolder nsHolder; boolean consumeAWTEvent; protected boolean isSetup; /** - * Simply wrap aroung a NEWT EventListener, exposed as an AWT EventListener.<br> + * Create a proxy adapter, wrapping around an NEWT EventListener, exposed as an AWT EventListener,<br> + * where the given {@link NativeSurfaceHolder} impersonates the event's source. * The NEWT EventListener will be called when an event happens.<br> */ - protected AWTAdapter(com.jogamp.newt.event.NEWTEventListener newtListener) { + protected AWTAdapter(com.jogamp.newt.event.NEWTEventListener newtListener, NativeSurfaceHolder nsProxy) { if(null==newtListener) { - throw new RuntimeException("Argument newtListener is null"); + throw new IllegalArgumentException("Argument newtListener is null"); + } + if(null==nsProxy) { + throw new IllegalArgumentException("Argument nwProxy is null"); } this.newtListener = newtListener; this.newtWindow = null; + this.nsHolder = nsProxy; this.consumeAWTEvent = false; this.isSetup = true; } /** - * Wrap aroung a NEWT EventListener, exposed as an AWT EventListener,<br> - * where the given NEWT Window impersonates as the event's source. + * Create a proxy adapter, wrapping around an NEWT EventListener, exposed as an AWT EventListener,<br> + * where the given {@link com.jogamp.newt.Window NEWT Window}, a {@link NativeSurfaceHolder}, impersonates the event's source. * The NEWT EventListener will be called when an event happens.<br> */ protected AWTAdapter(com.jogamp.newt.event.NEWTEventListener newtListener, com.jogamp.newt.Window newtProxy) { if(null==newtListener) { - throw new RuntimeException("Argument newtListener is null"); + throw new IllegalArgumentException("Argument newtListener is null"); } if(null==newtProxy) { - throw new RuntimeException("Argument newtProxy is null"); + throw new IllegalArgumentException("Argument newtProxy is null"); } this.newtListener = newtListener; this.newtWindow = newtProxy; + this.nsHolder = newtProxy; this.consumeAWTEvent = false; this.isSetup = true; } @@ -156,8 +165,9 @@ public abstract class AWTAdapter implements java.util.EventListener * 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> * This is only supported with EDT enabled! + * @throws IllegalStateException if EDT is not enabled */ - protected AWTAdapter(com.jogamp.newt.Window downstream) { + protected AWTAdapter(com.jogamp.newt.Window downstream) throws IllegalStateException { this(); setDownstream(downstream); } @@ -171,26 +181,34 @@ public abstract class AWTAdapter implements java.util.EventListener * Setup a pipeline adapter, AWT EventListener.<br> * Once attached to an AWT component, it sends the converted AWT events to the NEWT downstream window.<br> * This is only supported with EDT enabled! + * @throws IllegalStateException if EDT is not enabled */ - public synchronized AWTAdapter setDownstream(com.jogamp.newt.Window downstream) { + public synchronized AWTAdapter setDownstream(com.jogamp.newt.Window downstream) throws IllegalStateException { if(null==downstream) { throw new RuntimeException("Argument downstream is null"); } this.newtListener = null; this.newtWindow = downstream; - this.consumeAWTEvent = false; + this.nsHolder = downstream; if( null == newtWindow.getScreen().getDisplay().getEDTUtil() ) { - throw new RuntimeException("EDT not enabled"); + throw new IllegalStateException("EDT not enabled"); } this.isSetup = true; return this; } - /** Removes all references, downstream and NEWT-EventListener. */ + /** + * Removes all references, downstream and NEWT-EventListener. + * <p> + * Also sets the internal <code>setup</code> flag and {@link #setConsumeAWTEvent(boolean)} to <code>false</code>. + * </p> + */ public synchronized AWTAdapter clear() { this.newtListener = null; this.newtWindow = null; + this.nsHolder = null; this.isSetup = false; + this.consumeAWTEvent = false; return this; } @@ -198,10 +216,36 @@ public abstract class AWTAdapter implements java.util.EventListener this.consumeAWTEvent = v; } + /** + * Returns the {@link NativeSurfaceHolder} acting {@link #AWTAdapter(com.jogamp.newt.Window) as downstream}, + * {@link #AWTAdapter(com.jogamp.newt.event.NEWTEventListener, com.jogamp.newt.Window) NEWT window proxy} + * or as an {@link #AWTAdapter(com.jogamp.newt.event.NEWTEventListener, NativeSurfaceHolder) NativeSurfaceHolder proxy}. + * <p> + * Returned value is never null. + * </p> + */ + public final synchronized NativeSurfaceHolder getNativeSurfaceHolder() { + return nsHolder; + } + + /** + * Returns the {@link com.jogamp.newt.Window NEWT Window} acting {@link #AWTAdapter(com.jogamp.newt.Window) as downstream} + * or as a {@link #AWTAdapter(com.jogamp.newt.event.NEWTEventListener, com.jogamp.newt.Window) NEWT window proxy}. + * <p> + * Returned value maybe null if instance is used to be a + * {@link #AWTAdapter(com.jogamp.newt.event.NEWTEventListener, NativeSurfaceHolder) NativeSurfaceHolder proxy}. + * </p> + */ public final synchronized com.jogamp.newt.Window getNewtWindow() { return newtWindow; } + /** + * Returns the {@link com.jogamp.newt.event.NEWTEventListener NEWT event-listener} if instance + * is used as an {@link #AWTAdapter(com.jogamp.newt.event.NEWTEventListener, NativeSurfaceHolder) NativeSurfaceHolder proxy} + * or {@link #AWTAdapter(com.jogamp.newt.event.NEWTEventListener, com.jogamp.newt.Window) NEWT window proxy}, + * otherwise method returns <code>null</code>. + */ public final synchronized com.jogamp.newt.event.NEWTEventListener getNewtEventListener() { return newtListener; } diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java index ddbeb6e42..5ea36bac8 100644 --- a/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java @@ -28,6 +28,8 @@ package com.jogamp.newt.event.awt; +import javax.media.nativewindow.NativeSurfaceHolder; + import jogamp.newt.awt.event.AWTNewtEventFactory; /** @@ -37,8 +39,8 @@ import jogamp.newt.awt.event.AWTNewtEventFactory; */ 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, NativeSurfaceHolder nsProxy) { + super(newtListener, nsProxy); } public AWTKeyAdapter(com.jogamp.newt.event.KeyListener newtListener, com.jogamp.newt.Window newtProxy) { @@ -68,7 +70,7 @@ public class AWTKeyAdapter extends AWTAdapter implements java.awt.event.KeyListe @Override public synchronized void keyPressed(java.awt.event.KeyEvent e) { if( !isSetup ) { return; } - final com.jogamp.newt.event.KeyEvent event = AWTNewtEventFactory.createKeyEvent(com.jogamp.newt.event.KeyEvent.EVENT_KEY_PRESSED, e, newtWindow); + final com.jogamp.newt.event.KeyEvent event = AWTNewtEventFactory.createKeyEvent(com.jogamp.newt.event.KeyEvent.EVENT_KEY_PRESSED, e, nsHolder); if( consumeAWTEvent ) { e.consume(); } @@ -80,7 +82,7 @@ public class AWTKeyAdapter extends AWTAdapter implements java.awt.event.KeyListe @Override public synchronized void keyReleased(java.awt.event.KeyEvent e) { if( !isSetup ) { return; } - final com.jogamp.newt.event.KeyEvent event = AWTNewtEventFactory.createKeyEvent(com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED, e, newtWindow); + final com.jogamp.newt.event.KeyEvent event = AWTNewtEventFactory.createKeyEvent(com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED, e, nsHolder); if( consumeAWTEvent ) { e.consume(); } diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTMouseAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTMouseAdapter.java index d0f73ef33..53fe70bf7 100644 --- a/src/newt/classes/com/jogamp/newt/event/awt/AWTMouseAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTMouseAdapter.java @@ -28,14 +28,16 @@ package com.jogamp.newt.event.awt; +import javax.media.nativewindow.NativeSurfaceHolder; + import jogamp.newt.awt.event.AWTNewtEventFactory; public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener { - public AWTMouseAdapter(com.jogamp.newt.event.MouseListener newtListener) { - super(newtListener); + public AWTMouseAdapter(com.jogamp.newt.event.MouseListener newtListener, NativeSurfaceHolder nsProxy) { + super(newtListener, nsProxy); } public AWTMouseAdapter(com.jogamp.newt.event.MouseListener newtListener, com.jogamp.newt.Window newtProxy) { @@ -69,7 +71,7 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL @Override public synchronized void mouseClicked(java.awt.event.MouseEvent e) { if( !isSetup ) { return; } - com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow); + com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, nsHolder); if( consumeAWTEvent ) { e.consume(); } @@ -81,7 +83,7 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL @Override public synchronized void mouseEntered(java.awt.event.MouseEvent e) { if( !isSetup ) { return; } - com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow); + com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, nsHolder); if( consumeAWTEvent ) { e.consume(); } @@ -93,7 +95,7 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL @Override public synchronized void mouseExited(java.awt.event.MouseEvent e) { if( !isSetup ) { return; } - com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow); + com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, nsHolder); if( consumeAWTEvent ) { e.consume(); } @@ -105,7 +107,7 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL @Override public synchronized void mousePressed(java.awt.event.MouseEvent e) { if( !isSetup ) { return; } - com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow); + com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, nsHolder); if( consumeAWTEvent ) { e.consume(); } @@ -117,7 +119,7 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL @Override public synchronized void mouseReleased(java.awt.event.MouseEvent e) { if( !isSetup ) { return; } - com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow); + com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, nsHolder); if( consumeAWTEvent ) { e.consume(); } @@ -129,7 +131,7 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL @Override public synchronized void mouseDragged(java.awt.event.MouseEvent e) { if( !isSetup ) { return; } - com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow); + com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, nsHolder); if( consumeAWTEvent ) { e.consume(); } @@ -141,7 +143,7 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL @Override public synchronized void mouseMoved(java.awt.event.MouseEvent e) { if( !isSetup ) { return; } - com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow); + com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, nsHolder); if( consumeAWTEvent ) { e.consume(); } @@ -153,7 +155,7 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL @Override public synchronized void mouseWheelMoved(java.awt.event.MouseWheelEvent e) { if( !isSetup ) { return; } - com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow); + com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, nsHolder); if( consumeAWTEvent ) { e.consume(); } diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java index 43a28b3b3..698fe86f4 100644 --- a/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java @@ -30,6 +30,8 @@ package com.jogamp.newt.event.awt; import java.awt.Dimension; +import javax.media.nativewindow.NativeSurfaceHolder; + import jogamp.newt.awt.event.AWTNewtEventFactory; public class AWTWindowAdapter @@ -38,8 +40,8 @@ public class AWTWindowAdapter { WindowClosingListener windowClosingListener; - public AWTWindowAdapter(com.jogamp.newt.event.WindowListener newtListener) { - super(newtListener); + public AWTWindowAdapter(com.jogamp.newt.event.WindowListener newtListener, NativeSurfaceHolder nsProxy) { + super(newtListener, nsProxy); } public AWTWindowAdapter(com.jogamp.newt.event.WindowListener newtListener, com.jogamp.newt.Window newtProxy) { @@ -49,6 +51,7 @@ public class AWTWindowAdapter public AWTWindowAdapter(com.jogamp.newt.Window downstream) { super(downstream); } + public AWTWindowAdapter() { super(); } @@ -100,7 +103,7 @@ public class AWTWindowAdapter @Override public synchronized void focusGained(java.awt.event.FocusEvent e) { if( !isSetup ) { return; } - com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); + com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, nsHolder); if(DEBUG_IMPLEMENTATION) { System.err.println("AWT: focusGained: "+e+" -> "+event); } @@ -112,7 +115,7 @@ public class AWTWindowAdapter @Override public synchronized void focusLost(java.awt.event.FocusEvent e) { if( !isSetup ) { return; } - com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); + com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, nsHolder); if(DEBUG_IMPLEMENTATION) { System.err.println("AWT: focusLost: "+e+" -> "+event); } @@ -124,7 +127,7 @@ public class AWTWindowAdapter @Override public synchronized void componentResized(java.awt.event.ComponentEvent e) { if( !isSetup ) { return; } - com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); + com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, nsHolder); if(DEBUG_IMPLEMENTATION) { final java.awt.Component c = e.getComponent(); final java.awt.Dimension sz = c.getSize(); @@ -148,7 +151,7 @@ public class AWTWindowAdapter @Override public synchronized void componentMoved(java.awt.event.ComponentEvent e) { if( !isSetup ) { return; } - com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); + com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, nsHolder); if(DEBUG_IMPLEMENTATION) { System.err.println("AWT: componentMoved: "+e+" -> "+event); } @@ -198,7 +201,7 @@ public class AWTWindowAdapter @Override public synchronized void windowActivated(java.awt.event.WindowEvent e) { if( !isSetup ) { return; } - com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); + com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, nsHolder); if( EventProcRes.DISPATCH == processEvent(false, event) ) { ((com.jogamp.newt.event.WindowListener)newtListener).windowGainedFocus(event); } @@ -213,7 +216,7 @@ public class AWTWindowAdapter @Override public synchronized void windowDeactivated(java.awt.event.WindowEvent e) { if( !isSetup ) { return; } - com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); + com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, nsHolder); if( EventProcRes.DISPATCH == processEvent(false, event) ) { ((com.jogamp.newt.event.WindowListener)newtListener).windowLostFocus(event); } @@ -233,7 +236,7 @@ public class AWTWindowAdapter public void windowClosing(java.awt.event.WindowEvent e) { synchronized( AWTWindowAdapter.this ) { if( !isSetup ) { return; } - com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); + com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, nsHolder); if( EventProcRes.DISPATCH == processEvent(true, event) ) { ((com.jogamp.newt.event.WindowListener)newtListener).windowDestroyNotify(event); } @@ -243,7 +246,7 @@ public class AWTWindowAdapter public void windowClosed(java.awt.event.WindowEvent e) { synchronized( AWTWindowAdapter.this ) { if( !isSetup ) { return; } - com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); + com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, nsHolder); if( EventProcRes.DISPATCH == processEvent(true, event) ) { ((com.jogamp.newt.event.WindowListener)newtListener).windowDestroyed(event); } diff --git a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java index 93ecc8bb2..674d467f9 100644 --- a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java +++ b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java @@ -548,6 +548,9 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { } @Override + public final NativeSurface getNativeSurface() { return this; } + + @Override public AbstractGraphicsConfiguration getGraphicsConfiguration() { return config; } diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 2411f6595..5288bfcc5 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -854,6 +854,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // public final void destroy() - see below @Override + public final NativeSurface getNativeSurface() { return this; } + + @Override public final NativeWindow getParent() { return parentWindow; } diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java index 709143b82..b04fd98f4 100644 --- a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java @@ -28,6 +28,9 @@ package jogamp.newt.awt.event; +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.NativeSurfaceHolder; + import com.jogamp.newt.event.MouseEvent; /** @@ -590,31 +593,31 @@ public class AWTNewtEventFactory { return defAwtKeyCode; } - public static final com.jogamp.newt.event.WindowEvent createWindowEvent(java.awt.event.WindowEvent event, com.jogamp.newt.Window newtSource) { + public static final com.jogamp.newt.event.WindowEvent createWindowEvent(final java.awt.event.WindowEvent event, final NativeSurfaceHolder sourceHolder) { final short newtType = eventTypeAWT2NEWT(event.getID()); if( (short)0 != newtType ) { - return new com.jogamp.newt.event.WindowEvent(newtType, ((null==newtSource)?(Object)event.getComponent():(Object)newtSource), System.currentTimeMillis()); + return new com.jogamp.newt.event.WindowEvent(newtType, sourceHolder, System.currentTimeMillis()); } return null; // no mapping .. } - public static final com.jogamp.newt.event.WindowEvent createWindowEvent(java.awt.event.ComponentEvent event, com.jogamp.newt.Window newtSource) { + public static final com.jogamp.newt.event.WindowEvent createWindowEvent(final java.awt.event.ComponentEvent event, final NativeSurfaceHolder sourceHolder) { final short newtType = eventTypeAWT2NEWT(event.getID()); if( (short)0 != newtType ) { - return new com.jogamp.newt.event.WindowEvent(newtType, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, System.currentTimeMillis()); + return new com.jogamp.newt.event.WindowEvent(newtType, sourceHolder, System.currentTimeMillis()); } return null; // no mapping .. } - public static final com.jogamp.newt.event.WindowEvent createWindowEvent(java.awt.event.FocusEvent event, com.jogamp.newt.Window newtSource) { + public static final com.jogamp.newt.event.WindowEvent createWindowEvent(final java.awt.event.FocusEvent event, final NativeSurfaceHolder sourceHolder) { final short newtType = eventTypeAWT2NEWT(event.getID()); if( (short)0 != newtType ) { - return new com.jogamp.newt.event.WindowEvent(newtType, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, System.currentTimeMillis()); + return new com.jogamp.newt.event.WindowEvent(newtType, sourceHolder, System.currentTimeMillis()); } return null; // no mapping .. } - public static final com.jogamp.newt.event.MouseEvent createMouseEvent(java.awt.event.MouseEvent event, com.jogamp.newt.Window newtSource) { + public static final com.jogamp.newt.event.MouseEvent createMouseEvent(final java.awt.event.MouseEvent event, final NativeSurfaceHolder sourceHolder) { final short newtType = eventTypeAWT2NEWT(event.getID()); if( (short)0 != newtType ) { float rotation = 0; @@ -626,35 +629,40 @@ public class AWTNewtEventFactory { final short newtButton = awtButton2Newt(event.getButton()); int mods = awtModifiers2Newt(event.getModifiers(), event.getModifiersEx()); mods |= com.jogamp.newt.event.InputEvent.getButtonMask(newtButton); // always include NEWT BUTTON_MASK + final NativeSurface source = sourceHolder.getNativeSurface(); final int[] pixelPos; - if(null!=newtSource) { - if(newtSource.isPointerConfined()) { - mods |= com.jogamp.newt.event.InputEvent.CONFINED_MASK; - } - if(!newtSource.isPointerVisible()) { - mods |= com.jogamp.newt.event.InputEvent.INVISIBLE_MASK; + if( null != source ) { + if( source instanceof com.jogamp.newt.Window ) { + final com.jogamp.newt.Window newtSource = (com.jogamp.newt.Window) source; + if(newtSource.isPointerConfined()) { + mods |= com.jogamp.newt.event.InputEvent.CONFINED_MASK; + } + if(!newtSource.isPointerVisible()) { + mods |= com.jogamp.newt.event.InputEvent.INVISIBLE_MASK; + } } - pixelPos = newtSource.convertToPixelUnits(new int[] { event.getX(), event.getY() }); + pixelPos = source.convertToPixelUnits(new int[] { event.getX(), event.getY() }); } else { pixelPos = new int[] { event.getX(), event.getY() }; } + return new com.jogamp.newt.event.MouseEvent( - newtType, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, event.getWhen(), + newtType, sourceHolder, event.getWhen(), mods, pixelPos[0], pixelPos[1], (short)event.getClickCount(), newtButton, MouseEvent.getRotationXYZ(rotation, mods), 1f); } return null; // no mapping .. } - public static final com.jogamp.newt.event.KeyEvent createKeyEvent(java.awt.event.KeyEvent event, com.jogamp.newt.Window newtSource) { - return createKeyEvent(eventTypeAWT2NEWT(event.getID()), event, newtSource); + public static final com.jogamp.newt.event.KeyEvent createKeyEvent(final java.awt.event.KeyEvent event, final NativeSurfaceHolder sourceHolder) { + return createKeyEvent(eventTypeAWT2NEWT(event.getID()), event, sourceHolder); } - public static final com.jogamp.newt.event.KeyEvent createKeyEvent(short newtType, java.awt.event.KeyEvent event, com.jogamp.newt.Window newtSource) { + public static final com.jogamp.newt.event.KeyEvent createKeyEvent(final short newtType, final java.awt.event.KeyEvent event, final NativeSurfaceHolder sourceHolder) { if( (short)0 != newtType ) { final short newtKeyCode = awtKeyCode2NewtKeyCode( event.getKeyCode() ); return com.jogamp.newt.event.KeyEvent.create( - newtType, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, event.getWhen(), + newtType, sourceHolder, event.getWhen(), awtModifiers2Newt(event.getModifiers(), event.getModifiersEx()), newtKeyCode, newtKeyCode, event.getKeyChar()); } diff --git a/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java index b5c45c1aa..386149b22 100644 --- a/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java @@ -28,6 +28,9 @@ package jogamp.newt.swt.event; +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.NativeSurfaceHolder; + import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; @@ -134,7 +137,7 @@ public class SWTNewtEventFactory { } public static int newtKeyCode2SWTKeyCode(final short newtKeyCode) { - final int defSWTKeyCode = 0xFFFF & (int)newtKeyCode; + final int defSWTKeyCode = 0xFFFF & newtKeyCode; switch (newtKeyCode) { case com.jogamp.newt.event.KeyEvent.VK_HOME : return SWT.HOME; case com.jogamp.newt.event.KeyEvent.VK_END : return SWT.END; @@ -199,15 +202,15 @@ public class SWTNewtEventFactory { } - public static final com.jogamp.newt.event.InputEvent createInputEvent(org.eclipse.swt.widgets.Event event, Object source) { - com.jogamp.newt.event.InputEvent res = createMouseEvent(event, source); + public static final com.jogamp.newt.event.InputEvent createInputEvent(org.eclipse.swt.widgets.Event event, NativeSurfaceHolder sourceHolder) { + com.jogamp.newt.event.InputEvent res = createMouseEvent(event, sourceHolder); if(null == res) { - res = createKeyEvent(event, source); + res = createKeyEvent(event, sourceHolder); } return res; } - public static final com.jogamp.newt.event.MouseEvent createMouseEvent(org.eclipse.swt.widgets.Event event, Object source) { + public static final com.jogamp.newt.event.MouseEvent createMouseEvent(org.eclipse.swt.widgets.Event event, NativeSurfaceHolder sourceHolder) { switch(event.type) { case SWT.MouseDown: case SWT.MouseUp: @@ -230,24 +233,31 @@ public class SWTNewtEventFactory { int mods = swtModifiers2Newt(event.stateMask, true); - if( source instanceof com.jogamp.newt.Window) { - final com.jogamp.newt.Window newtSource = (com.jogamp.newt.Window)source; - if(newtSource.isPointerConfined()) { - mods |= InputEvent.CONFINED_MASK; - } - if(!newtSource.isPointerVisible()) { - mods |= InputEvent.INVISIBLE_MASK; + final NativeSurface source = sourceHolder.getNativeSurface(); + final int[] pixelPos; + if( null != source ) { + if( source instanceof com.jogamp.newt.Window) { + final com.jogamp.newt.Window newtSource = (com.jogamp.newt.Window)source; + if(newtSource.isPointerConfined()) { + mods |= InputEvent.CONFINED_MASK; + } + if(!newtSource.isPointerVisible()) { + mods |= InputEvent.INVISIBLE_MASK; + } } + pixelPos = source.convertToPixelUnits(new int[] { event.x, event.y }); + } else { + pixelPos = new int[] { event.x, event.y }; } return new com.jogamp.newt.event.MouseEvent( - type, (null==source)?(Object)event.data:source, (0xFFFFFFFFL & (long)event.time), - mods, event.x, event.y, (short)event.count, (short)event.button, MouseEvent.getRotationXYZ(rotation, mods), 1f); + type, sourceHolder, (0xFFFFFFFFL & event.time), + mods, pixelPos[0], pixelPos[1], (short)event.count, (short)event.button, MouseEvent.getRotationXYZ(rotation, mods), 1f); } return null; // no mapping .. } - public static final com.jogamp.newt.event.KeyEvent createKeyEvent(org.eclipse.swt.widgets.Event event, Object source) { + public static final com.jogamp.newt.event.KeyEvent createKeyEvent(org.eclipse.swt.widgets.Event event, NativeSurfaceHolder sourceHolder) { switch(event.type) { case SWT.KeyDown: case SWT.KeyUp: @@ -259,7 +269,7 @@ public class SWTNewtEventFactory { if( (short)0 != type ) { final short newtKeyCode = swtKeyCode2NewtKeyCode( event.keyCode ); return com.jogamp.newt.event.KeyEvent.create( - type, (null==source)?(Object)event.data:source, (0xFFFFFFFFL & (long)event.time), + type, sourceHolder, (0xFFFFFFFFL & event.time), swtModifiers2Newt(event.stateMask, false), newtKeyCode, newtKeyCode, event.character); } @@ -280,8 +290,8 @@ public class SWTNewtEventFactory { dragButtonDown = 0; } - public final boolean dispatchMouseEvent(org.eclipse.swt.widgets.Event event, Object source, com.jogamp.newt.event.MouseListener l) { - com.jogamp.newt.event.MouseEvent res = createMouseEvent(event, source); + public final boolean dispatchMouseEvent(org.eclipse.swt.widgets.Event event, NativeSurfaceHolder sourceHolder, com.jogamp.newt.event.MouseListener l) { + com.jogamp.newt.event.MouseEvent res = createMouseEvent(event, sourceHolder); if(null != res) { if(null != l) { switch(event.type) { @@ -331,8 +341,8 @@ public class SWTNewtEventFactory { return false; } - public final boolean dispatchKeyEvent(org.eclipse.swt.widgets.Event event, Object source, com.jogamp.newt.event.KeyListener l) { - com.jogamp.newt.event.KeyEvent res = createKeyEvent(event, source); + public final boolean dispatchKeyEvent(org.eclipse.swt.widgets.Event event, NativeSurfaceHolder sourceHolder, com.jogamp.newt.event.KeyListener l) { + com.jogamp.newt.event.KeyEvent res = createKeyEvent(event, sourceHolder); if(null != res) { if(null != l) { switch(event.type) { @@ -349,27 +359,38 @@ public class SWTNewtEventFactory { return false; } - public final void attachDispatchListener(final org.eclipse.swt.widgets.Control ctrl, final Object source, + public final void attachDispatchListener(final org.eclipse.swt.widgets.Control ctrl, final NativeSurfaceHolder sourceHolder, final com.jogamp.newt.event.MouseListener ml, final com.jogamp.newt.event.KeyListener kl) { - final Listener listener = new Listener () { - @Override - public void handleEvent (Event event) { - if( dispatchMouseEvent( event, source, ml ) ) { - return; - } - if( dispatchKeyEvent( event, source, kl ) ) { - return; - } - } }; - ctrl.addListener(SWT.MouseDown, listener); - ctrl.addListener(SWT.MouseUp, listener); - ctrl.addListener(SWT.MouseMove, listener); - ctrl.addListener(SWT.MouseEnter, listener); - ctrl.addListener(SWT.MouseExit, listener); - ctrl.addListener(SWT.MouseVerticalWheel, listener); - ctrl.addListener(SWT.KeyDown, listener); - ctrl.addListener(SWT.KeyUp, listener); + if(null==ctrl) { + throw new IllegalArgumentException("Argument ctrl is null"); + } + if(null==sourceHolder) { + throw new IllegalArgumentException("Argument source is null"); + } + + if( null != ml ) { + final Listener listener = new Listener () { + @Override + public void handleEvent (Event event) { + dispatchMouseEvent( event, sourceHolder, ml ); + } }; + ctrl.addListener(SWT.MouseDown, listener); + ctrl.addListener(SWT.MouseUp, listener); + ctrl.addListener(SWT.MouseMove, listener); + ctrl.addListener(SWT.MouseEnter, listener); + ctrl.addListener(SWT.MouseExit, listener); + ctrl.addListener(SWT.MouseVerticalWheel, listener); + } + if( null != kl ) { + final Listener listener = new Listener () { + @Override + public void handleEvent (Event event) { + dispatchKeyEvent( event, sourceHolder, kl ); + } }; + ctrl.addListener(SWT.KeyDown, listener); + ctrl.addListener(SWT.KeyUp, listener); + } } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch02AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch02AWT.java index 316199d07..c612f1204 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch02AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch02AWT.java @@ -45,7 +45,6 @@ import javax.media.opengl.awt.GLCanvas; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.GLDrawableUtil; - import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; import com.jogamp.opengl.test.junit.util.QuitAdapter; import com.jogamp.opengl.test.junit.util.UITestCase; @@ -116,14 +115,14 @@ public class TestGLContextDrawableSwitch02AWT extends UITestCase { final GLCapabilities capsOffscreen = (GLCapabilities) capsOnscreen.clone(); capsOffscreen.setOnscreen(false); - final QuitAdapter quitAdapter = new QuitAdapter(); - final Frame frame = new Frame("Gears AWT Test"); Assert.assertNotNull(frame); - new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); GLAutoDrawable glCanvas = createGLAutoDrawable(frame, capsOnscreen, width, height); + final QuitAdapter quitAdapter = new QuitAdapter(); + new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter), glCanvas).addTo(frame); + final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); GearsES2 gears = new GearsES2(1); glCanvas.addGLEventListener(gears); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos01AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos01AWT.java index 443908ff8..28e00dfe2 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos01AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos01AWT.java @@ -236,9 +236,8 @@ public class TestBug816OSXCALayerPos01AWT extends UITestCase { if( twoCanvas ) { animator.add(glCanvas2); } - QuitAdapter quitAdapter = new QuitAdapter(); - - new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); + final QuitAdapter quitAdapter = new QuitAdapter(); + new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter), glCanvas1).addTo(frame); javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos02AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos02AWT.java index df24fc6e0..5f1b43a61 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos02AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos02AWT.java @@ -80,9 +80,9 @@ public class TestBug816OSXCALayerPos02AWT extends UITestCase { final Animator animator = new Animator(); animator.add(glCanvas1); - QuitAdapter quitAdapter = new QuitAdapter(); - new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); + final QuitAdapter quitAdapter = new QuitAdapter(); + new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter), glCanvas1).addTo(frame); // Build a GUI where the canvas 3D is located at top right of the frame // and can be resized with split panes dividers diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03aB729AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03aB729AWT.java index 29dc9a190..f37cdf332 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03aB729AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03aB729AWT.java @@ -87,9 +87,9 @@ public class TestBug816OSXCALayerPos03aB729AWT extends UITestCase { final Animator animator = new Animator(); animator.add(glCanvas1); - QuitAdapter quitAdapter = new QuitAdapter(); - new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); + final QuitAdapter quitAdapter = new QuitAdapter(); + new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter), glCanvas1).addTo(frame); // Create a check box that hides / shows canvas final Checkbox checkbox = new Checkbox("Visible canvas", true); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03bB849AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03bB849AWT.java index 3e60c8b47..acdd40764 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03bB849AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03bB849AWT.java @@ -93,9 +93,9 @@ public class TestBug816OSXCALayerPos03bB849AWT extends UITestCase { final Animator animator = new Animator(); animator.add(glCanvas1); - QuitAdapter quitAdapter = new QuitAdapter(); - new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); + final QuitAdapter quitAdapter = new QuitAdapter(); + new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter), glCanvas1).addTo(frame); // Create a check box that hides / shows canvas final Checkbox checkbox = new Checkbox("Visible canvas", true); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03cB849AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03cB849AWT.java index 24f9de961..52480b89b 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03cB849AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03cB849AWT.java @@ -95,9 +95,9 @@ public class TestBug816OSXCALayerPos03cB849AWT extends UITestCase { final Animator animator = new Animator(); animator.add(glCanvas1); - QuitAdapter quitAdapter = new QuitAdapter(); - new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); + final QuitAdapter quitAdapter = new QuitAdapter(); + new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter), glCanvas1).addTo(frame); // Create a check box that hides / shows canvas final JCheckBox checkbox = new JCheckBox("Visible canvas", true); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos04aAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos04aAWT.java index b558b1680..246c5cdb5 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos04aAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos04aAWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.jogl.awt; import java.awt.BorderLayout; @@ -59,55 +59,55 @@ import com.jogamp.opengl.util.Animator; */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestBug816OSXCALayerPos04aAWT extends UITestCase { - static long duration = 1600; // ms + static long duration = 1600; // ms static int width=640, height=480; - + @Test public void test() throws InterruptedException, InvocationTargetException { final GLCapabilities caps = new GLCapabilities(getGLP()); - + final Frame frame = new Frame("TestBug816OSXCALayerPos04aAWT"); Assert.assertNotNull(frame); final GLCanvas glCanvas1 = new GLCanvas(caps); Assert.assertNotNull(glCanvas1); glCanvas1.addGLEventListener(new GearsES2(1)); - + final Animator animator = new Animator(); animator.add(glCanvas1); - QuitAdapter quitAdapter = new QuitAdapter(); - - new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); + + final QuitAdapter quitAdapter = new QuitAdapter(); + new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter), glCanvas1).addTo(frame); // Display the canvas 3D in a dialog child of a frame frame.setSize(400, 400); - + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { frame.setLocation(100, 100); frame.setSize(width, height); frame.setVisible(true); - }}); + }}); Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); - + final Dialog dialog = new Dialog(frame, "Bug 816 AWT Top-Level Dialog"); dialog.setLayout(new BorderLayout()); dialog.add(glCanvas1, BorderLayout.CENTER); - + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { dialog.setLocation(200, 200); dialog.setSize(width/2, height/2); dialog.setVisible(true); - }}); + }}); Assert.assertEquals(true, AWTRobotUtil.waitForVisible(dialog, true)); - Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas1, true)); - + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas1, true)); + animator.start(); Assert.assertTrue(animator.isStarted()); Assert.assertTrue(animator.isAnimating()); animator.setUpdateFPSFrames(60, System.err); - + final long t0 = System.currentTimeMillis(); long t1 = t0; while(!quitAdapter.shouldQuit() && t1 - t0 < duration) { @@ -117,7 +117,7 @@ public class TestBug816OSXCALayerPos04aAWT extends UITestCase { Assert.assertNotNull(frame); Assert.assertNotNull(glCanvas1); - + Assert.assertNotNull(animator); animator.stop(); Assert.assertFalse(animator.isAnimating()); @@ -138,7 +138,7 @@ public class TestBug816OSXCALayerPos04aAWT extends UITestCase { static GLProfile getGLP() { return GLProfile.getMaxProgrammableCore(true); } - + public static void main(String args[]) { for(int i=0; i<args.length; i++) { if(args[i].equals("-time")) { @@ -146,7 +146,7 @@ public class TestBug816OSXCALayerPos04aAWT extends UITestCase { duration = MiscUtils.atol(args[i], duration); } } - + org.junit.runner.JUnitCore.main(TestBug816OSXCALayerPos04aAWT.class.getName()); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos04bAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos04bAWT.java index b502dbdae..186191b19 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos04bAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos04bAWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.jogl.awt; import java.awt.BorderLayout; @@ -59,55 +59,55 @@ import com.jogamp.opengl.util.Animator; */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestBug816OSXCALayerPos04bAWT extends UITestCase { - static long duration = 1600; // ms + static long duration = 1600; // ms static int width=640, height=480; - + @Test public void test() throws InterruptedException, InvocationTargetException { final GLCapabilities caps = new GLCapabilities(getGLP()); - + final JFrame frame = new JFrame("TestBug816OSXCALayerPos04bAWT"); Assert.assertNotNull(frame); final GLCanvas glCanvas1 = new GLCanvas(caps); Assert.assertNotNull(glCanvas1); glCanvas1.addGLEventListener(new GearsES2(1)); - + final Animator animator = new Animator(); animator.add(glCanvas1); - QuitAdapter quitAdapter = new QuitAdapter(); - - new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); + + final QuitAdapter quitAdapter = new QuitAdapter(); + new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter), glCanvas1).addTo(frame); // Display the canvas 3D in a dialog child of a frame frame.setSize(400, 400); - + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { frame.setLocation(100, 100); frame.setSize(width, height); frame.setVisible(true); - }}); + }}); Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); - - final JDialog dialog = new JDialog(frame, "Bug 816 AWT Top-Level JDialog"); + + final JDialog dialog = new JDialog(frame, "Bug 816 AWT Top-Level JDialog"); dialog.setLayout(new BorderLayout()); dialog.add(glCanvas1, BorderLayout.CENTER); - + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { dialog.setLocation(200, 200); dialog.setSize(width/2, height/2); dialog.setVisible(true); - }}); + }}); Assert.assertEquals(true, AWTRobotUtil.waitForVisible(dialog, true)); Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas1, true)); - + animator.start(); Assert.assertTrue(animator.isStarted()); Assert.assertTrue(animator.isAnimating()); animator.setUpdateFPSFrames(60, System.err); - + final long t0 = System.currentTimeMillis(); long t1 = t0; while(!quitAdapter.shouldQuit() && t1 - t0 < duration) { @@ -117,7 +117,7 @@ public class TestBug816OSXCALayerPos04bAWT extends UITestCase { Assert.assertNotNull(frame); Assert.assertNotNull(glCanvas1); - + Assert.assertNotNull(animator); animator.stop(); Assert.assertFalse(animator.isAnimating()); @@ -138,7 +138,7 @@ public class TestBug816OSXCALayerPos04bAWT extends UITestCase { static GLProfile getGLP() { return GLProfile.getMaxProgrammableCore(true); } - + public static void main(String args[]) { for(int i=0; i<args.length; i++) { if(args[i].equals("-time")) { @@ -146,7 +146,7 @@ public class TestBug816OSXCALayerPos04bAWT extends UITestCase { duration = MiscUtils.atol(args[i], duration); } } - + org.junit.runner.JUnitCore.main(TestBug816OSXCALayerPos04bAWT.class.getName()); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLJPanelTextureStateAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLJPanelTextureStateAWT.java index 2d4c6da4d..a279870df 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLJPanelTextureStateAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLJPanelTextureStateAWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.jogl.awt; @@ -51,7 +51,6 @@ import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.GLReadBufferUtil; import java.awt.Dimension; - import java.io.IOException; import org.junit.Assert; @@ -62,7 +61,7 @@ import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; /** - * Unit test for bug 826, test {@link GLJPanel}'s {@link TextureState} save and restore. + * Unit test for bug 826, test {@link GLJPanel}'s {@link TextureState} save and restore. */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestGLJPanelTextureStateAWT extends UITestCase { @@ -73,25 +72,25 @@ public class TestGLJPanelTextureStateAWT extends UITestCase { public static void initClass() { } - public void testImpl(final boolean keepTextureBound, final int texUnit) - throws InterruptedException, IOException + public void testImpl(final boolean keepTextureBound, final int texUnit) + throws InterruptedException, IOException { final GLReadBufferUtil screenshot = new GLReadBufferUtil(true, false); GLProfile glp; if(GLProfile.isAvailable(GLProfile.GL2ES2)) { glp = GLProfile.getGL2ES2(); } else { - System.err.println(getSimpleTestName(".")+": GLProfile n/a"); + System.err.println(getSimpleTestName(".")+": GLProfile n/a"); return; } final GLCapabilities caps = new GLCapabilities(glp); - + final GLJPanel glc = new GLJPanel(caps); Dimension glc_sz = new Dimension(800, 400); glc.setMinimumSize(glc_sz); glc.setPreferredSize(glc_sz); final JFrame frame = new JFrame("TestGLJPanelTextureStateAWT"); - Assert.assertNotNull(frame); + Assert.assertNotNull(frame); frame.getContentPane().add(glc); final TextureDraw02ES2ListenerFBO gle0; @@ -102,16 +101,16 @@ public class TestGLJPanelTextureStateAWT extends UITestCase { } gle0.setKeepTextureBound(keepTextureBound); gle0.setClearBuffers(false); - + final RedSquareES2 gle1 = new RedSquareES2( 1 ) ; gle1.setClearBuffers(false); - + glc.addGLEventListener(new GLEventListener() { int gle0X, gle0Y, gle0W, gle0H; int gle1X, gle1Y, gle1W, gle1H; int tX, tY, tW, tH; int shot = 0; - + void setupTex(GL gl) { // Note: FBObject uses diff defaults, i.e.: GL_NEAREST and GL_CLAMP_TO_EDGE if( keepTextureBound ) { @@ -121,7 +120,7 @@ public class TestGLJPanelTextureStateAWT extends UITestCase { gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_REPEAT); } } - + @Override public void init(GLAutoDrawable drawable) { // Initialize w/ arbitrary values ! @@ -138,24 +137,24 @@ public class TestGLJPanelTextureStateAWT extends UITestCase { gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_REPEAT); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_REPEAT); - + gle0.init(drawable); gle1.init(drawable); setupTex(gl); } @Override - public void dispose(GLAutoDrawable drawable) { + public void dispose(GLAutoDrawable drawable) { gle0.dispose(drawable); gle1.dispose(drawable); } @Override - public void display(GLAutoDrawable drawable) { + public void display(GLAutoDrawable drawable) { GL2ES2 gl = drawable.getGL().getGL2ES2(); - + gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); - + // restore viewport test final int[] viewport = new int[] { 0, 0, 0, 0 }; gl.glGetIntegerv(GL.GL_VIEWPORT, viewport, 0); @@ -164,25 +163,25 @@ public class TestGLJPanelTextureStateAWT extends UITestCase { ", actual "+gle0X+"/"+gle0Y+" "+gle0W+"x"+gle0H; Assert.assertTrue("Viewport not restored: "+msg, false); } - + // gl.glViewport(gle0X, gle0Y, gle0W, gle0H); // restore viewport test gle0.display(drawable); - + gl.glViewport(gle1X, gle1Y, gle1W, gle1H); gle1.display(drawable); - + shot++; if( 4 == shot ) { gl.glViewport(tX, tY, tW, tH); snapshot(0, null, drawable.getGL(), screenshot, TextureIO.PNG, null); - } - + } + gl.glViewport(gle0X, gle0Y, gle0W, gle0H); // restore viewport test - + final TextureState ts = new TextureState(drawable.getGL(), GL.GL_TEXTURE_2D); // System.err.println("XXX: "+ts); Assert.assertEquals("Texture unit changed", GL.GL_TEXTURE0+texUnit, ts.getUnit()); - if( keepTextureBound ) { + if( keepTextureBound ) { Assert.assertEquals("Texture mag-filter changed", GL.GL_LINEAR, ts.getMagFilter()); Assert.assertEquals("Texture mag-filter changed", GL.GL_LINEAR, ts.getMinFilter()); Assert.assertEquals("Texture wrap-s changed", GL.GL_REPEAT, ts.getWrapS()); @@ -196,37 +195,37 @@ public class TestGLJPanelTextureStateAWT extends UITestCase { gle0Y = y; gle0W = width/2 - 2*border; gle0H = height; - + gle1X = gle0X + gle0W + 2*border; gle1Y = y; gle1W = width/2 - 2*border; gle1H = height; - + tX = x; tY = y; tW = width; tH = height; - + GL2ES2 gl = drawable.getGL().getGL2ES2(); gl.glViewport(gle0X, gle0Y, gle0W, gle0H); gle0.reshape(drawable, gle0X, gle0Y, gle0W, gle0H); - + gl.glViewport(gle1X, gle1Y, gle1W, gle1H); gle1.reshape(drawable, gle1X, gle1Y, gle1W, gle1H); - + gl.glViewport(gle0X, gle0Y, gle0W, gle0H); // restore viewport test - + if( keepTextureBound ) { setupTex(gl); } - } + } }); Animator animator = new Animator(glc); animator.setUpdateFPSFrames(60, showFPS ? System.err : null); - QuitAdapter quitAdapter = new QuitAdapter(); - new com.jogamp.newt.event.awt.AWTKeyAdapter(quitAdapter).addTo(glc); - new com.jogamp.newt.event.awt.AWTWindowAdapter(quitAdapter).addTo(glc); + final QuitAdapter quitAdapter = new QuitAdapter(); + new com.jogamp.newt.event.awt.AWTKeyAdapter(quitAdapter, glc).addTo(glc); + new com.jogamp.newt.event.awt.AWTWindowAdapter(quitAdapter, glc).addTo(glc); try { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { @@ -236,13 +235,14 @@ public class TestGLJPanelTextureStateAWT extends UITestCase { } catch( Throwable throwable ) { throwable.printStackTrace(); Assume.assumeNoException( throwable ); - } + } + animator.start(); while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) { Thread.sleep(100); } - + animator.stop(); try { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { @@ -254,9 +254,9 @@ public class TestGLJPanelTextureStateAWT extends UITestCase { } catch( Throwable throwable ) { throwable.printStackTrace(); Assume.assumeNoException( throwable ); - } + } } - + @Test public void test01_texUnit0_keepTex0_ES2() throws InterruptedException, IOException { testImpl(false /* keepTextureBound */, 0 /* texUnit */); @@ -269,7 +269,7 @@ public class TestGLJPanelTextureStateAWT extends UITestCase { public void test03_texUnit1_keepTex1_ES2() throws InterruptedException, IOException { testImpl(true /* keepTextureBound */, 1 /* texUnit */); } - + public static void main(String args[]) throws IOException { for(int i=0; i<args.length; i++) { if(args[i].equals("-time")) { @@ -277,6 +277,6 @@ public class TestGLJPanelTextureStateAWT extends UITestCase { duration = MiscUtils.atol(args[i], duration); } } - org.junit.runner.JUnitCore.main(TestGLJPanelTextureStateAWT.class.getName()); + org.junit.runner.JUnitCore.main(TestGLJPanelTextureStateAWT.class.getName()); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java index 6cddce62c..b750c54dd 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java @@ -198,8 +198,8 @@ public class GearsES1 implements GLEventListener { window.addKeyListener(gearsKeys); } else if (GLProfile.isAWTAvailable() && upstreamWidget instanceof java.awt.Component) { final java.awt.Component comp = (java.awt.Component) upstreamWidget; - new com.jogamp.newt.event.awt.AWTMouseAdapter(gearsMouse).addTo(comp); - new com.jogamp.newt.event.awt.AWTKeyAdapter(gearsKeys).addTo(comp); + new com.jogamp.newt.event.awt.AWTMouseAdapter(gearsMouse, drawable).addTo(comp); + new com.jogamp.newt.event.awt.AWTKeyAdapter(gearsKeys, drawable).addTo(comp); } System.err.println(Thread.currentThread()+" GearsES1.init FIN"); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java index b2b1dd642..c179aad66 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java @@ -302,8 +302,8 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL window.addGestureHandler(pinchToZoomGesture); } else if (GLProfile.isAWTAvailable() && upstreamWidget instanceof java.awt.Component) { final java.awt.Component comp = (java.awt.Component) upstreamWidget; - new com.jogamp.newt.event.awt.AWTMouseAdapter(gearsMouse).addTo(comp); - new com.jogamp.newt.event.awt.AWTKeyAdapter(gearsKeys).addTo(comp); + new com.jogamp.newt.event.awt.AWTMouseAdapter(gearsMouse, drawable).addTo(comp); + new com.jogamp.newt.event.awt.AWTKeyAdapter(gearsKeys, drawable).addTo(comp); } st.useProgram(gl, false); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java index db0e11734..b86dbb603 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java @@ -296,7 +296,7 @@ public class TextureSequenceCubeES2 implements GLEventListener { window.addMouseListener(mouseAction); } else if (GLProfile.isAWTAvailable() && upstreamWidget instanceof java.awt.Component) { final java.awt.Component comp = (java.awt.Component) upstreamWidget; - new com.jogamp.newt.event.awt.AWTMouseAdapter(mouseAction).addTo(comp); + new com.jogamp.newt.event.awt.AWTMouseAdapter(mouseAction, drawable).addTo(comp); } // Let's show the completed shader state .. diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java index d9839c057..622f51e45 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java @@ -238,10 +238,9 @@ public class TestGearsES2AWT extends UITestCase { if( useAnimator && exclusiveContext ) { animator.setExclusiveContext(awtEDT); } - QuitAdapter quitAdapter = new QuitAdapter(); - - new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter)).addTo(glCanvas); - new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); + final QuitAdapter quitAdapter = new QuitAdapter(); + new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter), glCanvas).addTo(glCanvas); + new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter), glCanvas).addTo(frame); javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelAWT.java index 29750973a..8172eb335 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelAWT.java @@ -168,10 +168,9 @@ public class TestGearsES2GLJPanelAWT extends UITestCase { Assert.assertEquals(true, animator.isAnimating()); } - QuitAdapter quitAdapter = new QuitAdapter(); - - new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter)).addTo(glJPanel); - new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); + final QuitAdapter quitAdapter = new QuitAdapter(); + new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter), glJPanel).addTo(glJPanel); + new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter), glJPanel).addTo(frame); snap.setMakeSnapshot(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java index 9c5d1e249..8eb84e152 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java @@ -109,8 +109,8 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererList window.addKeyListener(gearsKeys); } else if (GLProfile.isAWTAvailable() && upstreamWidget instanceof java.awt.Component) { final java.awt.Component comp = (java.awt.Component) upstreamWidget; - new AWTMouseAdapter(gearsMouse).addTo(comp); - new AWTKeyAdapter(gearsKeys).addTo(comp); + new AWTMouseAdapter(gearsMouse, drawable).addTo(comp); + new AWTKeyAdapter(gearsKeys, drawable).addTo(comp); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWT.java index 24a6d578c..1b83904a9 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,23 +20,24 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.jogl.demos.gl2.awt; import javax.media.opengl.*; import com.jogamp.opengl.util.Animator; + import javax.media.opengl.awt.GLCanvas; + import com.jogamp.newt.event.awt.AWTKeyAdapter; import com.jogamp.newt.event.awt.AWTWindowAdapter; import com.jogamp.newt.event.TraceKeyAdapter; import com.jogamp.newt.event.TraceWindowAdapter; - import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.test.junit.util.QuitAdapter; @@ -94,18 +95,18 @@ public class TestGearsAWT extends UITestCase { glCanvas.addGLEventListener(new Gears(1)); - Animator animator = new Animator(glCanvas); - QuitAdapter quitAdapter = new QuitAdapter(); - - new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter)).addTo(glCanvas); - new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); + final QuitAdapter quitAdapter = new QuitAdapter(); + new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter), glCanvas).addTo(glCanvas); + new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter), glCanvas).addTo(frame); javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { frame.pack(); frame.setVisible(true); }}); - animator.setUpdateFPSFrames(60, System.err); + + final Animator animator = new Animator(glCanvas); + animator.setUpdateFPSFrames(60, System.err); animator.start(); while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) { @@ -156,7 +157,7 @@ public class TestGearsAWT extends UITestCase { } catch (Exception ex) { ex.printStackTrace(); } } else if(args[i].equals("-wait")) { waitForKey = true; - } + } } if(waitForKey) { BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWTAnalyzeBug455.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWTAnalyzeBug455.java index 55a4b8450..2c3b3d472 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWTAnalyzeBug455.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWTAnalyzeBug455.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,26 +20,28 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.jogl.demos.gl2.awt; import javax.media.opengl.*; import com.jogamp.opengl.util.Animator; + import javax.media.opengl.awt.GLCanvas; + import com.jogamp.newt.event.awt.AWTKeyAdapter; import com.jogamp.newt.event.awt.AWTWindowAdapter; import com.jogamp.newt.event.TraceKeyAdapter; import com.jogamp.newt.event.TraceWindowAdapter; - import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.test.junit.util.QuitAdapter; + import java.awt.Frame; import java.io.BufferedReader; import java.io.IOException; @@ -94,11 +96,11 @@ public class TestGearsAWTAnalyzeBug455 extends UITestCase { gl.glCopyPixels(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), GL2.GL_COLOR); // gl.glPopAttrib(); gl.glDrawBuffer(GL.GL_BACK); // def. in dbl buff mode: GL_BACK - } + } } public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { - } + } } protected void runTestGL(GLCapabilities caps) throws InterruptedException, InvocationTargetException { final Frame frame = new Frame("Gears AWT Test"); @@ -112,18 +114,18 @@ public class TestGearsAWTAnalyzeBug455 extends UITestCase { glCanvas.addGLEventListener(new Gears(0)); glCanvas.addGLEventListener(new Swapper()); - Animator animator = new Animator(glCanvas); - QuitAdapter quitAdapter = new QuitAdapter(); - - new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter)).addTo(glCanvas); - new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); + final QuitAdapter quitAdapter = new QuitAdapter(); + new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter), glCanvas).addTo(glCanvas); + new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter), glCanvas).addTo(frame); javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { frame.setSize(512, 512); frame.setVisible(true); }}); - animator.setUpdateFPSFrames(60, System.err); + + final Animator animator = new Animator(glCanvas); + animator.setUpdateFPSFrames(60, System.err); animator.start(); while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsGLJPanelAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsGLJPanelAWT.java index 5de08c738..d6cc712ee 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsGLJPanelAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsGLJPanelAWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.jogl.demos.gl2.awt; import javax.media.opengl.*; @@ -35,6 +35,7 @@ import com.jogamp.newt.event.TraceWindowAdapter; import com.jogamp.newt.event.awt.AWTKeyAdapter; import com.jogamp.newt.event.awt.AWTWindowAdapter; import com.jogamp.opengl.util.FPSAnimator; + import javax.media.opengl.awt.GLJPanel; import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears; @@ -46,6 +47,7 @@ import java.awt.AWTException; import java.awt.BorderLayout; import java.awt.Dimension; import java.lang.reflect.InvocationTargetException; + import javax.swing.JFrame; import javax.swing.SwingUtilities; @@ -115,11 +117,10 @@ public class TestGearsGLJPanelAWT extends UITestCase { Assert.assertEquals(true, animator.isAnimating()); } - QuitAdapter quitAdapter = new QuitAdapter(); + final QuitAdapter quitAdapter = new QuitAdapter(); + new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter), glJPanel).addTo(glJPanel); + new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter), glJPanel).addTo(frame); - new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter)).addTo(glJPanel); - new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); - final long t0 = System.currentTimeMillis(); long t1 = t0; boolean triggerSnap = false; @@ -182,7 +183,7 @@ public class TestGearsGLJPanelAWT extends UITestCase { caps.setSampleBuffers(true); runTestGL(caps); } - + @Test public void test03_PbufferNorm() throws AWTException, InterruptedException, InvocationTargetException @@ -194,7 +195,7 @@ public class TestGearsGLJPanelAWT extends UITestCase { caps.setPBuffer(true); runTestGL(caps); } - + @Test public void test04_PbufferMsaa() throws AWTException, InterruptedException, InvocationTargetException @@ -208,7 +209,7 @@ public class TestGearsGLJPanelAWT extends UITestCase { caps.setPBuffer(true); runTestGL(caps); } - + @Test public void test05_BitmapNorm() throws AWTException, InterruptedException, InvocationTargetException @@ -220,7 +221,7 @@ public class TestGearsGLJPanelAWT extends UITestCase { caps.setBitmap(true); runTestGL(caps); } - + @Test public void test06_BitmapMsaa() throws AWTException, InterruptedException, InvocationTargetException @@ -234,7 +235,7 @@ public class TestGearsGLJPanelAWT extends UITestCase { caps.setBitmap(true); runTestGL(caps); } - + static long duration = 500; // ms public static void main(String args[]) { @@ -263,7 +264,7 @@ public class TestGearsGLJPanelAWT extends UITestCase { System.err.println("shallUsePBuffer "+shallUsePBuffer); System.err.println("shallUseBitmap "+shallUseBitmap); System.err.println("manualTest "+manualTest); - + org.junit.runner.JUnitCore.main(TestGearsGLJPanelAWT.class.getName()); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering3GL2AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering3GL2AWT.java index 4d770e618..74ef0713a 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering3GL2AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering3GL2AWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -60,21 +60,21 @@ import org.junit.Test; import org.junit.runners.MethodSorters; /** - * Demos an onscreen AWT {@link GLCanvas} being used for + * Demos an onscreen AWT {@link GLCanvas} being used for * {@link RandomTileRenderer} rendering to produce a PNG file. * <p> * {@link RandomTileRenderer} is being kicked off from the main thread. * </p> * <p> * {@link RandomTileRenderer} setup and finishing is performed - * within the pre- and post {@link GLEventListener} + * within the pre- and post {@link GLEventListener} * set via {@link TileRendererBase#setGLEventListener(GLEventListener, GLEventListener)} - * on the animation thread. + * on the animation thread. * </p> * <p> * At tile rendering finish, the viewport and * and the original {@link GLEventListener}'s PMV matrix as well. - * The latter is done by calling it's {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape} method. + * The latter is done by calling it's {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape} method. * </p> */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) @@ -82,7 +82,7 @@ public class TestRandomTiledRendering3GL2AWT extends UITestCase { static long duration = 3500; // ms static int width = 512; static int height = 512; - + @Test public void test01_aa0() throws IOException, InterruptedException, InvocationTargetException { doTest(0); @@ -92,7 +92,7 @@ public class TestRandomTiledRendering3GL2AWT extends UITestCase { doTest(8); } - void doTest(int msaaCount) throws IOException, InterruptedException, InvocationTargetException { + void doTest(int msaaCount) throws IOException, InterruptedException, InvocationTargetException { final GLCapabilities caps = new GLCapabilities(null); if( msaaCount > 0 ) { caps.setSampleBuffers(true); @@ -113,11 +113,9 @@ public class TestRandomTiledRendering3GL2AWT extends UITestCase { final Gears gears = new Gears(); glad.addGLEventListener( gears ); - final Animator animator = new Animator(glad); final QuitAdapter quitAdapter = new QuitAdapter(); - - new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter)).addTo(glad); - new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); + new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter), glad).addTo(glad); + new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter), glad).addTo(frame); // Fix the image size for now final int maxTileSize = 64; @@ -134,7 +132,7 @@ public class TestRandomTiledRendering3GL2AWT extends UITestCase { final GLEventListener preTileGLEL = new GLEventListener() { final int w = maxTileSize, h = maxTileSize; int dx = 0, dy = 0; - + @Override public void init(GLAutoDrawable drawable) { final GL gl = drawable.getGL(); @@ -183,15 +181,15 @@ public class TestRandomTiledRendering3GL2AWT extends UITestCase { caps.getGLProfile(), 0 /* internalFormat */, imageWidth, imageHeight, - 0, + 0, imageBuffer.pixelAttributes, - false, false, + false, false, flipVertically[0], imageBuffer.buffer, null /* Flusher */); try { final String filename = getSnapshotFilename(0, "-tile", glad.getChosenGLCapabilities(), imageWidth, imageHeight, false, TextureIO.PNG, null); - final File file = new File(filename); + final File file = new File(filename); TextureIO.write(textureData, file); } catch (IOException e) { e.printStackTrace(); @@ -206,19 +204,21 @@ public class TestRandomTiledRendering3GL2AWT extends UITestCase { public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {} }; renderer.setGLEventListener(preTileGLEL, postTileGLEL); - + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { frame.pack(); frame.setVisible(true); }}); - animator.setUpdateFPSFrames(60, System.err); + + final Animator animator = new Animator(glad); + animator.setUpdateFPSFrames(60, System.err); animator.start(); boolean signalTileRenderer = true; - - while(!quitAdapter.shouldQuit() && animator.isAnimating() && - ( rendererActive[0] || animator.getTotalFPSDuration()<duration ) ) + + while(!quitAdapter.shouldQuit() && animator.isAnimating() && + ( rendererActive[0] || animator.getTotalFPSDuration()<duration ) ) { if( signalTileRenderer && animator.getTotalFPSDuration() > 90 ) { signalTileRenderer = false; @@ -244,9 +244,9 @@ public class TestRandomTiledRendering3GL2AWT extends UITestCase { public void run() { frame.remove(glad); frame.dispose(); - }}); + }}); } - + public static void main(String args[]) { for(int i=0; i<args.length; i++) { if(args[i].equals("-time")) { @@ -257,5 +257,5 @@ public class TestRandomTiledRendering3GL2AWT extends UITestCase { } } org.junit.runner.JUnitCore.main(TestRandomTiledRendering3GL2AWT.class.getName()); - } + } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsAWT.java index 30e0ba4e6..dd8a306cc 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsAWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.jogl.tile; import java.awt.BorderLayout; @@ -72,7 +72,7 @@ public class TestTiledPrintingGearsAWT extends TiledPrintingAWTBase { static boolean allow600dpi = false; static GLProfile glp; static int width, height; - + @BeforeClass public static void initClass() { if(GLProfile.isAvailable(GLProfile.GL2)) { @@ -90,30 +90,30 @@ public class TestTiledPrintingGearsAWT extends TiledPrintingAWTBase { @AfterClass public static void releaseClass() { } - + protected void runTestGL(GLCapabilities caps) throws InterruptedException, InvocationTargetException { final Dimension glc_sz = new Dimension(width/2, height); final GLCanvas glCanvas1 = new GLCanvas(caps); - Assert.assertNotNull(glCanvas1); + Assert.assertNotNull(glCanvas1); glCanvas1.setMinimumSize(glc_sz); glCanvas1.setPreferredSize(glc_sz); glCanvas1.setSize(glc_sz); glCanvas1.addGLEventListener(new Gears()); - + final GLCanvas glCanvas2 = new GLCanvas(caps); - Assert.assertNotNull(glCanvas2); + Assert.assertNotNull(glCanvas2); glCanvas2.setMinimumSize(glc_sz); glCanvas2.setPreferredSize(glc_sz); glCanvas2.setSize(glc_sz); glCanvas2.addGLEventListener(new RedSquareES2()); - + final Panel demoPanel = new Panel(); demoPanel.add(glCanvas1); demoPanel.add(glCanvas2); - + final Frame frame = new Frame("AWT Print"); Assert.assertNotNull(frame); - + final ActionListener print72DPIAction = new ActionListener() { public void actionPerformed(ActionEvent e) { doPrintManual(frame, 72, 0, -1, -1); @@ -132,7 +132,7 @@ public class TestTiledPrintingGearsAWT extends TiledPrintingAWTBase { print300DPIButton.addActionListener(print300DPIAction); final Button print600DPIButton = new Button("600dpi"); print600DPIButton.addActionListener(print600DPIAction); - + frame.setLayout(new BorderLayout()); Panel printPanel = new Panel(); printPanel.add(print72DPIButton); @@ -150,15 +150,15 @@ public class TestTiledPrintingGearsAWT extends TiledPrintingAWTBase { frame.add(eastPanel, BorderLayout.EAST); frame.add(westPanel, BorderLayout.WEST); frame.setTitle("Tiles AWT Print Test"); - + Animator animator = new Animator(); animator.add(glCanvas1); animator.add(glCanvas2); - QuitAdapter quitAdapter = new QuitAdapter(); - new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter)).addTo(glCanvas1); - new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter)).addTo(glCanvas2); - new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); + final QuitAdapter quitAdapter = new QuitAdapter(); + new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter), glCanvas1).addTo(glCanvas1); + new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter), glCanvas2).addTo(glCanvas2); + new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter), glCanvas2).addTo(frame); javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { @@ -168,15 +168,15 @@ public class TestTiledPrintingGearsAWT extends TiledPrintingAWTBase { Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas1, true)); Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas2, true)); - - animator.setUpdateFPSFrames(60, System.err); + + animator.setUpdateFPSFrames(60, System.err); animator.start(); boolean printDone = false; while(!quitAdapter.shouldQuit() && animator.isAnimating() && ( 0 == duration || animator.getTotalFPSDuration()<duration )) { Thread.sleep(200); if( !printDone ) { - printDone = true; + printDone = true; { final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 0, -1, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); @@ -186,27 +186,27 @@ public class TestTiledPrintingGearsAWT extends TiledPrintingAWTBase { waitUntilPrintJobsIdle(p); } { - // No AA needed for 150 dpi and greater :) + // No AA needed for 150 dpi and greater :) final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, -1, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { - // No AA needed for 150 dpi and greater :) + // No AA needed for 150 dpi and greater :) final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, 2048, 2048, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { - // No AA needed for 150 dpi and greater :) + // No AA needed for 150 dpi and greater :) final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, -1, -1, true /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { - // No AA needed for 150 dpi and greater :) + // No AA needed for 150 dpi and greater :) final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, -1, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { - // No AA needed for 150 dpi and greater :) + // No AA needed for 150 dpi and greater :) final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, -1, -1, true/* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } @@ -217,7 +217,7 @@ public class TestTiledPrintingGearsAWT extends TiledPrintingAWTBase { } } } - + Assert.assertNotNull(frame); Assert.assertNotNull(glCanvas1); Assert.assertNotNull(glCanvas2); @@ -243,7 +243,7 @@ public class TestTiledPrintingGearsAWT extends TiledPrintingAWTBase { GLCapabilities caps = new GLCapabilities(glp); runTestGL(caps); } - + @Test public void test02_aa8() throws InterruptedException, InvocationTargetException { GLCapabilities caps = new GLCapabilities(glp); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsNewtAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsNewtAWT.java index ec1d7b1d6..d3abcd01a 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsNewtAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsNewtAWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.jogl.tile; import java.awt.BorderLayout; @@ -73,7 +73,7 @@ public class TestTiledPrintingGearsNewtAWT extends TiledPrintingAWTBase { static boolean allow600dpi = false; static GLProfile glp; static int width, height; - + @BeforeClass public static void initClass() { if(GLProfile.isAvailable(GLProfile.GL2)) { @@ -91,34 +91,34 @@ public class TestTiledPrintingGearsNewtAWT extends TiledPrintingAWTBase { @AfterClass public static void releaseClass() { } - + protected void runTestGL(GLCapabilities caps) throws InterruptedException, InvocationTargetException { final Dimension glc_sz = new Dimension(width/2, height); final GLWindow glad1 = GLWindow.create(caps); - Assert.assertNotNull(glad1); + Assert.assertNotNull(glad1); final NewtCanvasAWT canvas1 = new NewtCanvasAWT(glad1); Assert.assertNotNull(canvas1); canvas1.setMinimumSize(glc_sz); canvas1.setPreferredSize(glc_sz); canvas1.setSize(glc_sz); glad1.addGLEventListener(new Gears()); - + final GLWindow glad2 = GLWindow.create(caps); - Assert.assertNotNull(glad2); + Assert.assertNotNull(glad2); final NewtCanvasAWT canvas2 = new NewtCanvasAWT(glad2); Assert.assertNotNull(canvas2); canvas2.setMinimumSize(glc_sz); canvas2.setPreferredSize(glc_sz); canvas2.setSize(glc_sz); glad2.addGLEventListener(new RedSquareES2()); - + final Panel demoPanel = new Panel(); demoPanel.add(canvas1); demoPanel.add(canvas2); - + final Frame frame = new Frame("Newt/AWT Print"); Assert.assertNotNull(frame); - + final ActionListener print72DPIAction = new ActionListener() { public void actionPerformed(ActionEvent e) { doPrintManual(frame, 72, 0, -1, -1); @@ -137,7 +137,7 @@ public class TestTiledPrintingGearsNewtAWT extends TiledPrintingAWTBase { print300DPIButton.addActionListener(print300DPIAction); final Button print600DPIButton = new Button("600dpi"); print600DPIButton.addActionListener(print600DPIAction); - + frame.setLayout(new BorderLayout()); Panel printPanel = new Panel(); printPanel.add(print72DPIButton); @@ -155,15 +155,15 @@ public class TestTiledPrintingGearsNewtAWT extends TiledPrintingAWTBase { frame.add(eastPanel, BorderLayout.EAST); frame.add(westPanel, BorderLayout.WEST); frame.setTitle("Tiles Newt/AWT Print Test"); - + Animator animator = new Animator(); animator.add(glad1); animator.add(glad2); - QuitAdapter quitAdapter = new QuitAdapter(); - new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter)).addTo(canvas1); - new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter)).addTo(canvas2); - new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); + final QuitAdapter quitAdapter = new QuitAdapter(); + new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter), canvas1.getNEWTChild()).addTo(canvas1); + new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter), canvas2.getNEWTChild()).addTo(canvas2); + new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter), canvas2.getNEWTChild()).addTo(frame); javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { @@ -173,8 +173,8 @@ public class TestTiledPrintingGearsNewtAWT extends TiledPrintingAWTBase { Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); Assert.assertEquals(true, AWTRobotUtil.waitForRealized(canvas1, true)); Assert.assertEquals(true, AWTRobotUtil.waitForRealized(canvas2, true)); - - animator.setUpdateFPSFrames(60, System.err); + + animator.setUpdateFPSFrames(60, System.err); animator.start(); boolean printDone = false; @@ -191,27 +191,27 @@ public class TestTiledPrintingGearsNewtAWT extends TiledPrintingAWTBase { waitUntilPrintJobsIdle(p); } { - // No AA needed for 150 dpi and greater :) + // No AA needed for 150 dpi and greater :) final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, -1, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { - // No AA needed for 150 dpi and greater :) + // No AA needed for 150 dpi and greater :) final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, 2048, 2048, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { - // No AA needed for 150 dpi and greater :) + // No AA needed for 150 dpi and greater :) final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, -1, -1, true /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { - // No AA needed for 150 dpi and greater :) + // No AA needed for 150 dpi and greater :) final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, -1, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { - // No AA needed for 150 dpi and greater :) + // No AA needed for 150 dpi and greater :) final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, -1, -1, true /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } @@ -222,7 +222,7 @@ public class TestTiledPrintingGearsNewtAWT extends TiledPrintingAWTBase { } } } - + Assert.assertNotNull(frame); Assert.assertNotNull(canvas1); Assert.assertNotNull(canvas2); @@ -250,7 +250,7 @@ public class TestTiledPrintingGearsNewtAWT extends TiledPrintingAWTBase { GLCapabilities caps = new GLCapabilities(glp); runTestGL(caps); } - + @Test public void test02_aa8() throws InterruptedException, InvocationTargetException { GLCapabilities caps = new GLCapabilities(glp); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java index 3dd3a83c8..34e1b60e9 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java @@ -192,11 +192,10 @@ public class TestTiledPrintingGearsSwingAWT extends TiledPrintingAWTBase { Animator animator = new Animator(); animator.add(glJPanel1); animator.add(glJPanel2); - QuitAdapter quitAdapter = new QuitAdapter(); - - new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter)).addTo(glJPanel1); - new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter)).addTo(glJPanel2); - new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); + final QuitAdapter quitAdapter = new QuitAdapter(); + new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter), glJPanel1).addTo(glJPanel1); + new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter), glJPanel2).addTo(glJPanel2); + new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter), glJPanel2).addTo(frame); SwingUtilities.invokeAndWait(new Runnable() { public void run() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT2.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT2.java index 29bf8a6c3..8cf1421ae 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT2.java @@ -179,10 +179,9 @@ public class TestTiledPrintingGearsSwingAWT2 extends TiledPrintingAWTBase { if( null != animator ) { animator.add(glJPanel1); } - QuitAdapter quitAdapter = new QuitAdapter(); - - new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter)).addTo(glJPanel1); - new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); + final QuitAdapter quitAdapter = new QuitAdapter(); + new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter), glJPanel1).addTo(glJPanel1); + new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter), glJPanel1).addTo(frame); SwingUtilities.invokeAndWait(new Runnable() { public void run() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileAWT.java index 191d67d31..7ea053a86 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileAWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.jogl.util.texture; @@ -51,7 +51,6 @@ import com.jogamp.opengl.util.GLReadBufferUtil; import java.awt.Dimension; import java.awt.Frame; - import java.io.IOException; import java.io.InputStream; import java.net.URLConnection; @@ -100,8 +99,8 @@ public class TestPNGTextureFromFileAWT extends UITestCase { testTextureStream = null; } - public void testImpl(boolean useFFP, final InputStream istream, final boolean useAWTIIOP) - throws InterruptedException, IOException + public void testImpl(boolean useFFP, final InputStream istream, final boolean useAWTIIOP) + throws InterruptedException, IOException { final GLReadBufferUtil screenshot = new GLReadBufferUtil(true, false); GLProfile glp; @@ -122,7 +121,7 @@ public class TestPNGTextureFromFileAWT extends UITestCase { texData = TextureIO.newTextureData(glp, istream, false /* mipmap */, TextureIO.PNG); } System.err.println("TextureData: "+texData); - + final GLCanvas glc = new GLCanvas(caps); Dimension glc_sz = new Dimension(texData.getWidth(), texData.getHeight()); glc.setMinimumSize(glc_sz); @@ -135,11 +134,11 @@ public class TestPNGTextureFromFileAWT extends UITestCase { // the bug submitter was doing it final GLEventListener gle = useFFP ? new TextureDraw01GL2Listener( texData ) : new TextureDraw01ES2Listener( texData, 0 ) ; glc.addGLEventListener(gle); - glc.addGLEventListener(new GLEventListener() { + glc.addGLEventListener(new GLEventListener() { boolean shot = false; - + @Override public void init(GLAutoDrawable drawable) {} - + @Override public void display(GLAutoDrawable drawable) { // 1 snapshot @@ -153,11 +152,10 @@ public class TestPNGTextureFromFileAWT extends UITestCase { @Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } }); - Animator animator = new Animator(glc); - animator.setUpdateFPSFrames(60, showFPS ? System.err : null); - QuitAdapter quitAdapter = new QuitAdapter(); - new com.jogamp.newt.event.awt.AWTKeyAdapter(quitAdapter).addTo(glc); - new com.jogamp.newt.event.awt.AWTWindowAdapter(quitAdapter).addTo(glc); + final QuitAdapter quitAdapter = new QuitAdapter(); + new com.jogamp.newt.event.awt.AWTKeyAdapter(quitAdapter, glc).addTo(glc); + new com.jogamp.newt.event.awt.AWTWindowAdapter(quitAdapter, glc).addTo(glc); + try { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { @@ -167,13 +165,16 @@ public class TestPNGTextureFromFileAWT extends UITestCase { } catch( Throwable throwable ) { throwable.printStackTrace(); Assume.assumeNoException( throwable ); - } + } + + Animator animator = new Animator(glc); + animator.setUpdateFPSFrames(60, showFPS ? System.err : null); animator.start(); while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) { Thread.sleep(100); } - + animator.stop(); try { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { @@ -185,45 +186,45 @@ public class TestPNGTextureFromFileAWT extends UITestCase { } catch( Throwable throwable ) { throwable.printStackTrace(); Assume.assumeNoException( throwable ); - } + } } - + @Test public void testGrayAWTILoaderGL2() throws InterruptedException, IOException { - testImpl(true, grayTextureStream, true); - } + testImpl(true, grayTextureStream, true); + } @Test public void testGrayAWTILoaderES2() throws InterruptedException, IOException { - testImpl(false, grayTextureStream, true); + testImpl(false, grayTextureStream, true); } - + @Test public void testGrayPNGJLoaderGL2() throws InterruptedException, IOException { - testImpl(true, grayTextureStream, false); + testImpl(true, grayTextureStream, false); } @Test public void testGrayPNGJLoaderES2() throws InterruptedException, IOException { - testImpl(false, grayTextureStream, false); + testImpl(false, grayTextureStream, false); } - + @Test public void testTestAWTILoaderGL2() throws InterruptedException, IOException { - testImpl(true, testTextureStream, true); + testImpl(true, testTextureStream, true); } @Test public void testTestAWTILoaderES2() throws InterruptedException, IOException { - testImpl(false, testTextureStream, true); + testImpl(false, testTextureStream, true); } - + @Test public void testTestPNGJLoaderGL2() throws InterruptedException, IOException { - testImpl(true, testTextureStream, false); + testImpl(true, testTextureStream, false); } @Test public void testTestPNGJLoaderES2() throws InterruptedException, IOException { - testImpl(false, testTextureStream, false); + testImpl(false, testTextureStream, false); } - + public static void main(String args[]) throws IOException { for(int i=0; i<args.length; i++) { if(args[i].equals("-time")) { @@ -231,6 +232,6 @@ public class TestPNGTextureFromFileAWT extends UITestCase { duration = MiscUtils.atol(args[i], duration); } } - org.junit.runner.JUnitCore.main(TestPNGTextureFromFileAWT.class.getName()); + org.junit.runner.JUnitCore.main(TestPNGTextureFromFileAWT.class.getName()); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTextureSequence01AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTextureSequence01AWT.java index 86cf4654e..5549254c4 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTextureSequence01AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTextureSequence01AWT.java @@ -66,11 +66,11 @@ public class TestTextureSequence01AWT extends UITestCase { public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } }); glc.addGLEventListener(new TextureSequenceCubeES2(texSource, false, -2.3f, 0f, 0f)); - final Animator animator = new Animator(glc); - animator.setUpdateFPSFrames(60, showFPS ? System.err : null); - QuitAdapter quitAdapter = new QuitAdapter(); - new com.jogamp.newt.event.awt.AWTKeyAdapter(quitAdapter).addTo(glc); - new com.jogamp.newt.event.awt.AWTWindowAdapter(quitAdapter).addTo(glc); + + final QuitAdapter quitAdapter = new QuitAdapter(); + new com.jogamp.newt.event.awt.AWTKeyAdapter(quitAdapter, glc).addTo(glc); + new com.jogamp.newt.event.awt.AWTWindowAdapter(quitAdapter, glc).addTo(glc); + try { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { @@ -81,6 +81,9 @@ public class TestTextureSequence01AWT extends UITestCase { throwable.printStackTrace(); Assume.assumeNoException( throwable ); } + + final Animator animator = new Animator(glc); + animator.setUpdateFPSFrames(60, showFPS ? System.err : null); animator.start(); while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) { diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersAWTCanvas.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersAWTCanvas.java index f1906f560..a459a7f1f 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersAWTCanvas.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersAWTCanvas.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.newt.event; import javax.media.opengl.awt.GLCanvas ; @@ -61,7 +61,7 @@ public class TestNewtEventModifiersAWTCanvas extends BaseNewtEventModifiers { final GLCanvas canvas = new GLCanvas() ; canvas.addGLEventListener( new RedSquareES2() ) ; - new AWTMouseAdapter( _testMouseListener ).addTo( (java.awt.Component)canvas ) ; + new AWTMouseAdapter( _testMouseListener, canvas ).addTo( canvas ) ; _testFrame = new JFrame( "Event Modifier Test AWTCanvas" ) ; _testFrame.setDefaultCloseOperation( WindowConstants.EXIT_ON_CLOSE ) ; @@ -73,10 +73,10 @@ public class TestNewtEventModifiersAWTCanvas extends BaseNewtEventModifiers { _testFrame.setVisible( true ) ; } }) ; - Assert.assertEquals(true, AWTRobotUtil.waitForVisible(_testFrame, true)); + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(_testFrame, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(canvas, true)); Assert.assertTrue(AWTRobotUtil.waitForRealized(canvas, true)); - + AWTRobotUtil.assertRequestFocusAndWait(null, canvas, canvas, null, null); // programmatic Assert.assertNotNull(_robot); AWTRobotUtil.requestFocus(_robot, canvas, false); // within unit framework, prev. tests (TestFocus02SwingAWTRobot) 'confuses' Windows keyboard input |