aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-01-30 20:41:11 +0100
committerSven Gothel <[email protected]>2013-01-30 20:41:11 +0100
commitcedbdb09c00bb2a32cc065cb75590f3571bb7aa1 (patch)
tree308a5319f05b58ef08d1db4e14f0181bced62111
parent4d6983ca087feb0544c27326c8bf470444df2eec (diff)
Fix AWTKeyAdapter: Reorder AWT events to NEWT order - also ensuring TYPED is always sent.
This foremost fixes an issue w/ OSX/Java7 and NewtCanvasAWT offscreen CALayer usage, which utilizes AWTKeyAdapter and AWTNewtEventFactory (AWT -> NEWT) key events.
-rwxr-xr-xmake/scripts/tests-osx-x64-java7.sh2
-rwxr-xr-xmake/scripts/tests-x64-custom.sh12
-rwxr-xr-xmake/scripts/tests.sh8
-rw-r--r--src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java26
-rw-r--r--src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java35
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java300
6 files changed, 353 insertions, 30 deletions
diff --git a/make/scripts/tests-osx-x64-java7.sh b/make/scripts/tests-osx-x64-java7.sh
index 378938167..36eee3255 100755
--- a/make/scripts/tests-osx-x64-java7.sh
+++ b/make/scripts/tests-osx-x64-java7.sh
@@ -8,6 +8,6 @@ export JAVA_HOME PATH
spath=`dirname $0`
-. $spath/tests.sh $JAVA_HOME/bin/java -d64 ../build-macosx $*
+. $spath/tests.sh $JAVA_HOME/bin/java -d64 ../build-macosx-java7 $*
diff --git a/make/scripts/tests-x64-custom.sh b/make/scripts/tests-x64-custom.sh
new file mode 100755
index 000000000..482afbbf2
--- /dev/null
+++ b/make/scripts/tests-x64-custom.sh
@@ -0,0 +1,12 @@
+#! /bin/bash
+
+SDIR=`dirname $0`
+
+#export LD_LIBRARY_PATH=/home/sven/libav/lib:$LD_LIBRARY_PATH
+
+#if [ -e $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh ] ; then
+# . $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh
+#fi
+
+. $SDIR/tests.sh `which java` -d64 ../build-x86_64 $*
+
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
index 0aeb54b56..cd8d37b47 100755
--- a/make/scripts/tests.sh
+++ b/make/scripts/tests.sh
@@ -168,7 +168,7 @@ function jrun() {
#D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.GLContext"
#D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen"
#D_ARGS="-Dnewt.debug.Window"
- D_ARGS="-Dnewt.debug.Window.KeyEvent"
+ #D_ARGS="-Dnewt.debug.Window.KeyEvent"
#D_ARGS="-Dnewt.debug.Window.MouseEvent"
#D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all"
#D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug.JAWT -Djogl.debug.Animator"
@@ -266,6 +266,7 @@ function testawtswt() {
#testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $*
+#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $*
@@ -298,8 +299,6 @@ function testawtswt() {
#testawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext02FPSAnimAWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext11VSyncAnimNEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext12FPSAnimNEWT $*
-#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $*
-#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $*
@@ -414,6 +413,9 @@ function testawtswt() {
#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventOrderAWT $*
#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT $*
#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT $*
+#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $*
+#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $*
+#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $*
testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $*
#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT $*
#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $*
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 7b0f6ba97..64071eed6 100644
--- a/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java
+++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java
@@ -30,6 +30,11 @@ package com.jogamp.newt.event.awt;
import jogamp.newt.awt.event.AWTNewtEventFactory;
+/**
+ * AWT:
+ * printable: PRESSED (t0), TYPED (t0), RELEASED (t1)
+ * non-printable: PRESSED (t0), RELEASED (t1)
+ */
public class AWTKeyAdapter extends AWTAdapter implements java.awt.event.KeyListener
{
public AWTKeyAdapter(com.jogamp.newt.event.KeyListener newtListener) {
@@ -54,8 +59,9 @@ public class AWTKeyAdapter extends AWTAdapter implements java.awt.event.KeyListe
return this;
}
+ @Override
public void keyPressed(java.awt.event.KeyEvent e) {
- com.jogamp.newt.event.KeyEvent event = AWTNewtEventFactory.createKeyEvent(e, newtWindow);
+ final com.jogamp.newt.event.KeyEvent event = AWTNewtEventFactory.createKeyEvent(com.jogamp.newt.event.KeyEvent.EVENT_KEY_PRESSED, e, newtWindow);
if(null!=newtListener) {
((com.jogamp.newt.event.KeyListener)newtListener).keyPressed(event);
} else {
@@ -63,22 +69,22 @@ public class AWTKeyAdapter extends AWTAdapter implements java.awt.event.KeyListe
}
}
+ @Override
public void keyReleased(java.awt.event.KeyEvent e) {
- com.jogamp.newt.event.KeyEvent event = AWTNewtEventFactory.createKeyEvent(e, newtWindow);
+ com.jogamp.newt.event.KeyEvent keyReleaseEvt = AWTNewtEventFactory.createKeyEvent(com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED, e, newtWindow);
+ com.jogamp.newt.event.KeyEvent keyTypedEvt = AWTNewtEventFactory.createKeyEvent(com.jogamp.newt.event.KeyEvent.EVENT_KEY_TYPED, e, newtWindow);
if(null!=newtListener) {
- ((com.jogamp.newt.event.KeyListener)newtListener).keyReleased(event);
+ final com.jogamp.newt.event.KeyListener newtKeyListener = (com.jogamp.newt.event.KeyListener)newtListener;
+ newtKeyListener.keyReleased(keyReleaseEvt);
+ newtKeyListener.keyTyped(keyTypedEvt);
} else {
- enqueueEvent(false, event);
+ enqueueEvent(false, keyReleaseEvt);
+ enqueueEvent(false, keyTypedEvt);
}
}
+ @Override
public void keyTyped(java.awt.event.KeyEvent e) {
- com.jogamp.newt.event.KeyEvent event = AWTNewtEventFactory.createKeyEvent(e, newtWindow);
- if(null!=newtListener) {
- ((com.jogamp.newt.event.KeyListener)newtListener).keyTyped(event);
- } else {
- enqueueEvent(false, event);
- }
}
}
diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java
index e0f7af69c..e11d79ddc 100644
--- a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java
+++ b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java
@@ -236,32 +236,32 @@ public class AWTNewtEventFactory {
}
public static final com.jogamp.newt.event.WindowEvent createWindowEvent(java.awt.event.WindowEvent event, com.jogamp.newt.Window newtSource) {
- int type = eventTypeAWT2NEWT.get(event.getID());
- if(0xFFFFFFFF != type) {
- return new com.jogamp.newt.event.WindowEvent(type, ((null==newtSource)?(Object)event.getComponent():(Object)newtSource), System.currentTimeMillis());
+ final int newtType = eventTypeAWT2NEWT.get(event.getID());
+ if(0xFFFFFFFF != newtType) {
+ return new com.jogamp.newt.event.WindowEvent(newtType, ((null==newtSource)?(Object)event.getComponent():(Object)newtSource), 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) {
- int type = eventTypeAWT2NEWT.get(event.getID());
- if(0xFFFFFFFF != type) {
- return new com.jogamp.newt.event.WindowEvent(type, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, System.currentTimeMillis());
+ final int newtType = eventTypeAWT2NEWT.get(event.getID());
+ if(0xFFFFFFFF != newtType) {
+ return new com.jogamp.newt.event.WindowEvent(newtType, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, 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) {
- int type = eventTypeAWT2NEWT.get(event.getID());
- if(0xFFFFFFFF != type) {
- return new com.jogamp.newt.event.WindowEvent(type, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, System.currentTimeMillis());
+ final int newtType = eventTypeAWT2NEWT.get(event.getID());
+ if(0xFFFFFFFF != newtType) {
+ return new com.jogamp.newt.event.WindowEvent(newtType, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, 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) {
- int type = eventTypeAWT2NEWT.get(event.getID());
- if(0xFFFFFFFF != type) {
+ final int newtType = eventTypeAWT2NEWT.get(event.getID());
+ if(0xFFFFFFFF != newtType) {
float rotation = 0;
if (event instanceof java.awt.event.MouseWheelEvent) {
// AWT/NEWT rotation is reversed - AWT +1 is down, NEWT +1 is up.
@@ -280,7 +280,7 @@ public class AWTNewtEventFactory {
}
}
return new com.jogamp.newt.event.MouseEvent(
- type, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, event.getWhen(),
+ newtType, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, event.getWhen(),
mods, event.getX(), event.getY(), event.getClickCount(),
newtButton, rotation);
}
@@ -288,15 +288,18 @@ public class AWTNewtEventFactory {
}
public static final com.jogamp.newt.event.KeyEvent createKeyEvent(java.awt.event.KeyEvent event, com.jogamp.newt.Window newtSource) {
- int type = eventTypeAWT2NEWT.get(event.getID());
- if(0xFFFFFFFF != type) {
+ return createKeyEvent(eventTypeAWT2NEWT.get(event.getID()), event, newtSource);
+ }
+
+ public static final com.jogamp.newt.event.KeyEvent createKeyEvent(int newtType, java.awt.event.KeyEvent event, com.jogamp.newt.Window newtSource) {
+ if(0xFFFFFFFF != newtType) {
return new com.jogamp.newt.event.KeyEvent(
- type, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, event.getWhen(),
+ newtType, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, event.getWhen(),
awtModifiers2Newt(event.getModifiers(), event.getModifiersEx()),
event.getKeyCode(), event.getKeyChar());
}
return null; // no mapping ..
}
-
+
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java
new file mode 100644
index 000000000..5fca50593
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java
@@ -0,0 +1,300 @@
+/**
+ * Copyright 2011 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 com.jogamp.opengl.test.junit.jogl.demos.es2.newt;
+
+import java.awt.BorderLayout;
+import java.awt.Frame;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+
+import com.jogamp.newt.Display;
+import com.jogamp.newt.NewtFactory;
+import com.jogamp.newt.Screen;
+import com.jogamp.newt.awt.NewtCanvasAWT;
+import com.jogamp.newt.event.KeyAdapter;
+import com.jogamp.newt.event.KeyEvent;
+import com.jogamp.newt.event.WindowEvent;
+import com.jogamp.newt.event.WindowAdapter;
+import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.test.junit.util.QuitAdapter;
+
+import com.jogamp.opengl.util.Animator;
+
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+
+import javax.media.nativewindow.util.Dimension;
+import javax.media.nativewindow.util.Point;
+import javax.media.nativewindow.util.PointImmutable;
+import javax.media.nativewindow.util.DimensionImmutable;
+
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLProfile;
+import javax.swing.SwingUtilities;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.AfterClass;
+import org.junit.Test;
+
+public class TestGearsES2NewtCanvasAWT extends UITestCase {
+ static int screenIdx = 0;
+ static PointImmutable wpos;
+ static DimensionImmutable wsize;
+
+ static long duration = 500; // ms
+ static boolean opaque = true;
+ static int forceAlpha = -1;
+ static boolean fullscreen = false;
+ static boolean pmvUseBackingArray = true;
+ static int swapInterval = 1;
+ static boolean showFPS = false;
+ static int loops = 1;
+ static boolean loop_shutdown = false;
+ static boolean forceES2 = false;
+ static boolean forceGL3 = false;
+ static boolean mainRun = false;
+ static boolean exclusiveContext = false;
+
+ @BeforeClass
+ public static void initClass() {
+ if(null == wsize) {
+ wsize = new Dimension(640, 480);
+ }
+ }
+
+ @AfterClass
+ public static void releaseClass() {
+ }
+
+ protected void runTestGL(GLCapabilitiesImmutable caps) throws InterruptedException, InvocationTargetException {
+ System.err.println("requested: vsync "+swapInterval+", "+caps);
+ Display dpy = NewtFactory.createDisplay(null);
+ Screen screen = NewtFactory.createScreen(dpy, screenIdx);
+ final GLWindow glWindow = GLWindow.create(screen, caps);
+ Assert.assertNotNull(glWindow);
+
+ final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow);
+
+ final Frame frame1 = new Frame("AWT Parent Frame");
+ frame1.setLayout(new BorderLayout());
+ frame1.add(newtCanvasAWT, BorderLayout.CENTER);
+ frame1.setSize(wsize.getWidth(), wsize.getHeight());
+ frame1.setLocation(0, 0);
+ frame1.setTitle("Gears NewtCanvasAWT Test (translucent "+!caps.isBackgroundOpaque()+"), swapInterval "+swapInterval+", size "+wsize+", pos "+wpos);
+
+ final GearsES2 demo = new GearsES2(swapInterval);
+ demo.setPMVUseBackingArray(pmvUseBackingArray);
+ glWindow.addGLEventListener(demo);
+
+ Animator animator = new Animator();
+ animator.setModeBits(false, Animator.MODE_EXPECT_AWT_RENDERING_THREAD);
+ animator.setExclusiveContext(exclusiveContext);
+
+ QuitAdapter quitAdapter = new QuitAdapter();
+ //glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter));
+ //glWindow.addWindowListener(new TraceWindowAdapter(quitAdapter));
+ glWindow.addKeyListener(quitAdapter);
+ glWindow.addWindowListener(quitAdapter);
+
+ glWindow.addWindowListener(new WindowAdapter() {
+ public void windowResized(WindowEvent e) {
+ System.err.println("window resized: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight());
+ }
+ public void windowMoved(WindowEvent e) {
+ System.err.println("window moved: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight());
+ }
+ });
+
+ glWindow.addKeyListener(new KeyAdapter() {
+ public void keyTyped(KeyEvent e) {
+ if(e.getKeyChar()=='f') {
+ new Thread() {
+ public void run() {
+ final Thread t = glWindow.setExclusiveContextThread(null);
+ System.err.println("[set fullscreen pre]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets());
+ glWindow.setFullscreen(!glWindow.isFullscreen());
+ System.err.println("[set fullscreen post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets());
+ glWindow.setExclusiveContextThread(t);
+ } }.start();
+ }
+ }
+ });
+
+ animator.add(glWindow);
+ animator.start();
+ Assert.assertTrue(animator.isStarted());
+ Assert.assertTrue(animator.isAnimating());
+ Assert.assertEquals(exclusiveContext ? animator.getThread() : null, glWindow.getExclusiveContextThread());
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame1.setVisible(true);
+ }
+ });
+
+ animator.setUpdateFPSFrames(60, showFPS ? System.err : null);
+
+ System.err.println("NW chosen: "+glWindow.getDelegatedWindow().getChosenCapabilities());
+ System.err.println("GL chosen: "+glWindow.getChosenCapabilities());
+ System.err.println("window pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets());
+
+ while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
+ Thread.sleep(100);
+ }
+
+ Assert.assertEquals(exclusiveContext ? animator.getThread() : null, glWindow.getExclusiveContextThread());
+ animator.stop();
+ Assert.assertFalse(animator.isAnimating());
+ Assert.assertFalse(animator.isStarted());
+ Assert.assertEquals(null, glWindow.getExclusiveContextThread());
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame1.dispose();
+ }
+ });
+ glWindow.destroy();
+ Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow, false));
+ }
+
+ @Test
+ public void test01GL2ES2() throws InterruptedException, InvocationTargetException {
+ for(int i=1; i<=loops; i++) {
+ System.err.println("Loop "+i+"/"+loops);
+ final GLProfile glp;
+ if(forceGL3) {
+ glp = GLProfile.get(GLProfile.GL3);
+ } else if(forceES2) {
+ glp = GLProfile.get(GLProfile.GLES2);
+ } else {
+ glp = GLProfile.getGL2ES2();
+ }
+ final GLCapabilities caps = new GLCapabilities( glp );
+ caps.setBackgroundOpaque(opaque);
+ if(-1 < forceAlpha) {
+ caps.setAlphaBits(forceAlpha);
+ }
+ runTestGL(caps);
+ if(loop_shutdown) {
+ GLProfile.shutdown();
+ }
+ }
+ }
+
+ @Test
+ public void test02GL3() throws InterruptedException, InvocationTargetException {
+ if(mainRun) return;
+
+ if( !GLProfile.isAvailable(GLProfile.GL3) ) {
+ System.err.println("GL3 n/a");
+ }
+ final GLProfile glp = GLProfile.get(GLProfile.GL3);
+ final GLCapabilities caps = new GLCapabilities( glp );
+ runTestGL(caps);
+ }
+
+ public static void main(String args[]) throws IOException {
+ mainRun = true;
+
+ int x=0, y=0, w=640, h=480;
+ boolean usePos = false;
+
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ duration = MiscUtils.atol(args[i], duration);
+ } else if(args[i].equals("-translucent")) {
+ opaque = false;
+ } else if(args[i].equals("-forceAlpha")) {
+ i++;
+ forceAlpha = MiscUtils.atoi(args[i], 0);
+ } else if(args[i].equals("-fullscreen")) {
+ fullscreen = true;
+ } else if(args[i].equals("-pmvDirect")) {
+ pmvUseBackingArray = false;
+ } else if(args[i].equals("-vsync")) {
+ i++;
+ swapInterval = MiscUtils.atoi(args[i], swapInterval);
+ } else if(args[i].equals("-exclctx")) {
+ exclusiveContext = true;
+ } else if(args[i].equals("-es2")) {
+ forceES2 = true;
+ } else if(args[i].equals("-gl3")) {
+ forceGL3 = true;
+ } else if(args[i].equals("-showFPS")) {
+ showFPS = true;
+ } else if(args[i].equals("-width")) {
+ i++;
+ w = MiscUtils.atoi(args[i], w);
+ } else if(args[i].equals("-height")) {
+ i++;
+ h = MiscUtils.atoi(args[i], h);
+ } else if(args[i].equals("-x")) {
+ i++;
+ x = MiscUtils.atoi(args[i], x);
+ usePos = true;
+ } else if(args[i].equals("-y")) {
+ i++;
+ y = MiscUtils.atoi(args[i], y);
+ usePos = true;
+ } else if(args[i].equals("-screen")) {
+ i++;
+ screenIdx = MiscUtils.atoi(args[i], 0);
+ } else if(args[i].equals("-loops")) {
+ i++;
+ loops = MiscUtils.atoi(args[i], 1);
+ } else if(args[i].equals("-loop-shutdown")) {
+ loop_shutdown = true;
+ }
+ }
+ wsize = new Dimension(w, h);
+
+ if(usePos) {
+ wpos = new Point(x, y);
+ }
+ System.err.println("position "+wpos);
+ System.err.println("size "+wsize);
+ System.err.println("screen "+screenIdx);
+ System.err.println("translucent "+(!opaque));
+ System.err.println("forceAlpha "+forceAlpha);
+ System.err.println("fullscreen "+fullscreen);
+ System.err.println("pmvDirect "+(!pmvUseBackingArray));
+ System.err.println("loops "+loops);
+ System.err.println("loop shutdown "+loop_shutdown);
+ System.err.println("forceES2 "+forceES2);
+ System.err.println("forceGL3 "+forceGL3);
+ System.err.println("swapInterval "+swapInterval);
+ System.err.println("exclusiveContext "+exclusiveContext);
+
+ org.junit.runner.JUnitCore.main(TestGearsES2NewtCanvasAWT.class.getName());
+ }
+}