summaryrefslogtreecommitdiffstats
path: root/src/test/com/jogamp
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/com/jogamp')
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit01AWT.java120
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit02AWT.java153
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/TestMultipleNewtCanvasAWT.java185
3 files changed, 389 insertions, 69 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit01AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit01AWT.java
index 92785ef6e..0db2afc32 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit01AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit01AWT.java
@@ -31,6 +31,8 @@ import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import javax.media.opengl.GLAnimatorControl;
@@ -52,13 +54,15 @@ import org.junit.Test;
import org.junit.runners.MethodSorters;
import com.jogamp.common.os.Platform;
+import com.jogamp.newt.awt.NewtCanvasAWT;
+import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.util.Animator;
/**
- * Multiple GLJPanels in a JFrame's Grid
+ * Tests multiple [GLJPanels, GLCanvas or NewtCanvasAWT] in a JFrame's Grid
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestPerf001GLJPanelInit01AWT extends UITestCase {
@@ -69,15 +73,26 @@ public class TestPerf001GLJPanelInit01AWT extends UITestCase {
GLProfile.initSingleton();
}
+ static enum CanvasType { GLCanvas_T, GLJPanel_T, NewtCanvasAWT_T };
+
+ static class GLADComp {
+ GLADComp(final GLAutoDrawable glad, final Component comp) {
+ this.glad = glad;
+ this.comp = comp;
+ }
+ final GLAutoDrawable glad;
+ final Component comp;
+ }
public void test(final GLCapabilitiesImmutable caps, final boolean useGears, final int width, final int height, final int rows,
- final int columns, final boolean useGLJPanel, final boolean useAnim) {
+ final int columns, final CanvasType canvasType, final boolean useAnim) {
final GLAnimatorControl animator = useAnim ? new Animator() : null;
final JFrame frame;
final JPanel panel;
+ final List<NewtCanvasAWT> newtCanvasAWTList = new ArrayList<NewtCanvasAWT>();
panel = new JPanel();
- frame = new JFrame("DemoGLJPanelGridAWT");
+ frame = new JFrame(getSimpleTestName("."));
panel.setLayout(new GridLayout(rows, columns));
// panel.setBounds(0, 0, width, height);
@@ -94,8 +109,21 @@ public class TestPerf001GLJPanelInit01AWT extends UITestCase {
public void run() {
t[0] = Platform.currentTimeMillis();
for(int i=0; i<panelCount; i++) {
- final GLAutoDrawable glad = useGLJPanel ? createGLJPanel(caps, useGears, animator, eSize) : createGLCanvas(caps, useGears, animator, eSize);
- glad.addGLEventListener(new GLEventListener() {
+ final GLADComp gladComp;
+ switch(canvasType) {
+ case GLCanvas_T:
+ gladComp = createGLCanvas(caps, useGears, animator, eSize);
+ break;
+ case GLJPanel_T:
+ gladComp = createGLJPanel(caps, useGears, animator, eSize);
+ break;
+ case NewtCanvasAWT_T:
+ gladComp = createNewtCanvasAWT(caps, useGears, animator, eSize);
+ newtCanvasAWTList.add((NewtCanvasAWT)gladComp.comp);
+ break;
+ default: throw new InternalError("XXX");
+ }
+ gladComp.glad.addGLEventListener(new GLEventListener() {
@Override
public void init(final GLAutoDrawable drawable) {
initCount.getAndIncrement();
@@ -107,7 +135,7 @@ public class TestPerf001GLJPanelInit01AWT extends UITestCase {
@Override
public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {}
});
- panel.add((Component)glad);
+ panel.add(gladComp.comp);
}
t[1] = Platform.currentTimeMillis();
frame.getContentPane().add(panel);
@@ -136,7 +164,7 @@ public class TestPerf001GLJPanelInit01AWT extends UITestCase {
final double panelCountF = initCount.get();
System.err.printf("P: %d %s:%n\tctor\t%6d/t %6.2f/1%n\tvisible\t%6d/t %6.2f/1%n\tsum-i\t%6d/t %6.2f/1%n",
initCount.get(),
- useGLJPanel?"GLJPanel":"GLCanvas",
+ canvasType,
t[1]-t[0], (t[1]-t[0])/panelCountF,
t[3]-t[1], (t[3]-t[1])/panelCountF,
t[3]-t[0], (t[3]-t[0])/panelCountF);
@@ -144,15 +172,24 @@ public class TestPerf001GLJPanelInit01AWT extends UITestCase {
if( wait ) {
UITestCase.waitForKey("Post-Init");
}
+ if( null != animator ) {
+ animator.start();
+ }
try {
Thread.sleep(duration);
} catch (final InterruptedException e1) {
e1.printStackTrace();
}
+ if( null != animator ) {
+ animator.stop();
+ }
t[4] = Platform.currentTimeMillis();
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
+ while( !newtCanvasAWTList.isEmpty() ) {
+ newtCanvasAWTList.remove(0).destroy(); // removeNotify does not destroy GLWindow
+ }
frame.dispose();
} } );
} catch (final Exception e1) {
@@ -166,46 +203,76 @@ public class TestPerf001GLJPanelInit01AWT extends UITestCase {
System.err.println("Total: "+(t[4]-t[0]));
}
- private GLAutoDrawable createGLCanvas(final GLCapabilitiesImmutable caps, final boolean useGears, final GLAnimatorControl anim, final Dimension size) {
+ private GLADComp createNewtCanvasAWT(final GLCapabilitiesImmutable caps, final boolean useGears, final GLAnimatorControl anim, final Dimension size) {
+ final GLWindow window = GLWindow.create(caps);
+ final NewtCanvasAWT canvas = new NewtCanvasAWT(window);
+ canvas.setSize(size);
+ canvas.setPreferredSize(size);
+ if( useGears ) {
+ final GearsES2 g = new GearsES2(0);
+ g.setVerbose(false);
+ window.addGLEventListener(g);
+ }
+ if( null != anim ) {
+ anim.add(window);
+ }
+ return new GLADComp(window, canvas);
+ }
+ private GLADComp createGLCanvas(final GLCapabilitiesImmutable caps, final boolean useGears, final GLAnimatorControl anim, final Dimension size) {
final GLCanvas canvas = new GLCanvas(caps);
canvas.setSize(size);
canvas.setPreferredSize(size);
if( useGears ) {
- canvas.addGLEventListener(new GearsES2());
+ canvas.addGLEventListener(new GearsES2(0));
}
if( null != anim ) {
anim.add(canvas);
}
- return canvas;
+ return new GLADComp(canvas, canvas);
}
- private GLAutoDrawable createGLJPanel(final GLCapabilitiesImmutable caps, final boolean useGears, final GLAnimatorControl anim, final Dimension size) {
+ private GLADComp createGLJPanel(final GLCapabilitiesImmutable caps, final boolean useGears, final GLAnimatorControl anim, final Dimension size) {
final GLJPanel canvas = new GLJPanel(caps);
canvas.setSize(size);
canvas.setPreferredSize(size);
if( useGears ) {
- canvas.addGLEventListener(new GearsES2());
+ canvas.addGLEventListener(new GearsES2(0));
}
if( null != anim ) {
anim.add(canvas);
}
- return canvas;
+ return new GLADComp(canvas, canvas);
}
- @Test
- public void test01NopGLJPanelDef() throws InterruptedException, InvocationTargetException {
- test(new GLCapabilities(null), false /*useGears*/, width, height, rows, cols, true /* useGLJPanel */, false /*useAnim*/);
+ // @Test
+ public void test01NopGLJPanel() throws InterruptedException, InvocationTargetException {
+ test(new GLCapabilities(null), false /*useGears*/, width, height, rows, cols, CanvasType.GLJPanel_T, false /*useAnim*/);
}
- @Test
- public void test02NopGLJPanelBitmap() throws InterruptedException, InvocationTargetException {
+ // @Test
+ public void test02NopGLJPanelBMP() throws InterruptedException, InvocationTargetException {
final GLCapabilities caps = new GLCapabilities(null);
caps.setBitmap(true);
- test(caps, false /*useGears*/, width, height, rows, cols, true /* useGLJPanel */, false /*useAnim*/);
+ test(caps, false /*useGears*/, width, height, rows, cols, CanvasType.GLJPanel_T, false /*useAnim*/);
+ }
+
+ // @Test
+ public void test03NopGLCanvas() throws InterruptedException, InvocationTargetException {
+ test(new GLCapabilities(null), false /*useGears*/, width, height, rows, cols, CanvasType.GLCanvas_T, false /*useAnim*/);
+ }
+
+ // @Test
+ public void test11GearsGLJPanel() throws InterruptedException, InvocationTargetException {
+ test(new GLCapabilities(null), true /*useGears*/, width, height, rows, cols, CanvasType.GLJPanel_T, true /*useAnim*/);
+ }
+
+ // @Test
+ public void test13GearsGLCanvas() throws InterruptedException, InvocationTargetException {
+ test(new GLCapabilities(null), true /*useGears*/, width, height, rows, cols, CanvasType.GLCanvas_T, true /*useAnim*/);
}
@Test
- public void test11NopGLCanvasDef() throws InterruptedException, InvocationTargetException {
- test(new GLCapabilities(null), false /*useGears*/, width, height, rows, cols, false /* useGLJPanel */, false /*useAnim*/);
+ public void test14GearsNewtCanvasAWT() throws InterruptedException, InvocationTargetException {
+ test(new GLCapabilities(null), true /*useGears*/, width, height, rows, cols, CanvasType.NewtCanvasAWT_T, true /*useAnim*/);
}
static long duration = 0; // ms
@@ -215,7 +282,8 @@ public class TestPerf001GLJPanelInit01AWT extends UITestCase {
AtomicInteger initCount = new AtomicInteger(0);
public static void main(final String[] args) {
- boolean useGLJPanel = true, useGears = false, manual=false;
+ CanvasType canvasType = CanvasType.GLJPanel_T;
+ boolean useGears = false, manual=false;
boolean waitMain = false;
for(int i=0; i<args.length; i++) {
@@ -230,8 +298,10 @@ public class TestPerf001GLJPanelInit01AWT extends UITestCase {
rows = MiscUtils.atoi(args[++i], rows);
} else if(args[i].equals("-cols")) {
cols = MiscUtils.atoi(args[++i], cols);
- } else if(args[i].equals("-glcanvas")) {
- useGLJPanel = false;
+ } else if(args[i].equals("-type")) {
+ i++;
+ canvasType = CanvasType.valueOf(args[i]);
+ manual = true;
} else if(args[i].equals("-gears")) {
useGears = true;
} else if(args[i].equals("-wait")) {
@@ -250,7 +320,7 @@ public class TestPerf001GLJPanelInit01AWT extends UITestCase {
if( manual ) {
GLProfile.initSingleton();
final TestPerf001GLJPanelInit01AWT demo = new TestPerf001GLJPanelInit01AWT();
- demo.test(null, useGears, width, height, rows, cols, useGLJPanel, false /*useAnim*/);
+ demo.test(null, useGears, width, height, rows, cols, canvasType, useGears /*useAnim*/);
} else {
org.junit.runner.JUnitCore.main(TestPerf001GLJPanelInit01AWT.class.getName());
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit02AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit02AWT.java
index c60c395eb..9f2e25fd7 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit02AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit02AWT.java
@@ -32,6 +32,8 @@ import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import javax.media.opengl.GLAnimatorControl;
@@ -54,13 +56,15 @@ import org.junit.Test;
import org.junit.runners.MethodSorters;
import com.jogamp.common.os.Platform;
+import com.jogamp.newt.awt.NewtCanvasAWT;
+import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.util.Animator;
/**
- * Multiple GLJPanels in a JFrame
+ * Tests multiple JFrames each with a [GLJPanels, GLCanvas or NewtCanvasAWT]
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestPerf001GLJPanelInit02AWT extends UITestCase {
@@ -71,13 +75,23 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
GLProfile.initSingleton();
}
+ static enum CanvasType { NOP_T, GLCanvas_T, GLJPanel_T, NewtCanvasAWT_T };
+
+ static class GLADComp {
+ GLADComp(final GLAutoDrawable glad, final Component comp) {
+ this.glad = glad;
+ this.comp = comp;
+ }
+ final GLAutoDrawable glad;
+ final Component comp;
+ }
+
public void test(final GLCapabilitiesImmutable caps, final boolean useGears, final boolean skipGLOrientationVerticalFlip, final int width,
- final int height, final int frameCount, final boolean initMT, final boolean useGLJPanel,
- final boolean useSwingDoubleBuffer, final boolean useGLCanvas, final boolean useAnim, final boolean overlap) {
+ final int height, final int frameCount, final boolean initMT,
+ final boolean useSwingDoubleBuffer, final CanvasType canvasType, final boolean useAnim, final boolean overlap) {
final GLAnimatorControl animator;
if( useAnim ) {
animator = new Animator();
- animator.start();
} else {
animator = null;
}
@@ -91,6 +105,8 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
System.err.println("Frame size: "+width+"x"+height+" -> "+frameCount+" x "+eWidth+"x"+eHeight+", overlap "+overlap);
System.err.println("SkipGLOrientationVerticalFlip "+skipGLOrientationVerticalFlip+", useGears "+useGears+", initMT "+initMT+", useAnim "+useAnim);
final JFrame[] frame = new JFrame[frameCount];
+ final List<NewtCanvasAWT> newtCanvasAWTList = new ArrayList<NewtCanvasAWT>();
+
final long[] t = new long[10];
if( wait ) {
UITestCase.waitForKey("Pre-Init");
@@ -103,7 +119,7 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
t[0] = Platform.currentTimeMillis();
int x = 32, y = 32;
for(int i=0; i<frameCount; i++) {
- frame[i] = new JFrame("frame_"+i+"/"+frameCount);
+ frame[i] = new JFrame(i+"/"+frameCount);
frame[i].setLocation(x, y);
if(!overlap) {
x+=eWidth+32;
@@ -117,9 +133,26 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
panel.setDoubleBuffered(useSwingDoubleBuffer);
// panel.setBounds(0, 0, width, height);
final Dimension eSize = new Dimension(eWidth, eHeight);
- final GLAutoDrawable glad = useGLJPanel ? createGLJPanel(initMT, useSwingDoubleBuffer, caps, useGears, skipGLOrientationVerticalFlip, animator, eSize) : ( useGLCanvas ? createGLCanvas(caps, useGears, animator, eSize) : null );
- if( null != glad ) {
- glad.addGLEventListener(new GLEventListener() {
+ final GLADComp gladComp;
+ switch(canvasType) {
+ case GLCanvas_T:
+ gladComp = createGLCanvas(caps, useGears, animator, eSize);
+ break;
+ case GLJPanel_T:
+ gladComp = createGLJPanel(initMT, useSwingDoubleBuffer, caps, useGears, skipGLOrientationVerticalFlip, animator, eSize);
+ break;
+ case NewtCanvasAWT_T:
+ gladComp = createNewtCanvasAWT(caps, useGears, animator, eSize);
+ newtCanvasAWTList.add((NewtCanvasAWT)gladComp.comp);
+ break;
+ case NOP_T:
+ gladComp = null;
+ break;
+ default: throw new InternalError("XXX");
+ }
+
+ if( null != gladComp ) {
+ gladComp.glad.addGLEventListener(new GLEventListener() {
@Override
public void init(final GLAutoDrawable drawable) {
initCount.incrementAndGet();
@@ -131,7 +164,7 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
@Override
public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {}
});
- panel.add((Component)glad);
+ panel.add(gladComp.comp);
} else {
@SuppressWarnings("serial")
final JTextArea c = new JTextArea("area "+i) {
@@ -192,7 +225,7 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
final double panelCountF = initCount.get();
System.err.printf("P: %d %s%s:%n\tctor\t%6d/t %6.2f/1%n\tvisible\t%6d/t %6.2f/1%n\tsum-i\t%6d/t %6.2f/1%n",
initCount.get(),
- useGLJPanel?"GLJPanel":(useGLCanvas?"GLCanvas":"No_GL"), initMT?" (mt)":" (01)",
+ canvasType, initMT?" (mt)":" (01)",
t[1]-t[0], (t[1]-t[0])/panelCountF,
t[3]-t[1], (t[3]-t[1])/panelCountF,
t[3]-t[0], (t[3]-t[0])/panelCountF);
@@ -201,15 +234,24 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
if( wait ) {
UITestCase.waitForKey("Post-Init");
}
+ if( null != animator ) {
+ animator.start();
+ }
try {
Thread.sleep(duration);
} catch (final InterruptedException e1) {
e1.printStackTrace();
}
+ if( null != animator ) {
+ animator.stop();
+ }
t[4] = Platform.currentTimeMillis();
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
+ while( !newtCanvasAWTList.isEmpty() ) {
+ newtCanvasAWTList.remove(0).destroy(); // removeNotify does not destroy GLWindow
+ }
for(int i=0; i<frameCount; i++) {
frame[i].dispose();
}
@@ -226,7 +268,22 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
System.err.println("Total: "+(t[4]-t[0]));
}
- private GLAutoDrawable createGLCanvas(final GLCapabilitiesImmutable caps, final boolean useGears, final GLAnimatorControl anim, final Dimension size) {
+ private GLADComp createNewtCanvasAWT(final GLCapabilitiesImmutable caps, final boolean useGears, final GLAnimatorControl anim, final Dimension size) {
+ final GLWindow window = GLWindow.create(caps);
+ final NewtCanvasAWT canvas = new NewtCanvasAWT(window);
+ canvas.setSize(size);
+ canvas.setPreferredSize(size);
+ if( useGears ) {
+ final GearsES2 g = new GearsES2(0);
+ g.setVerbose(false);
+ window.addGLEventListener(g);
+ }
+ if( null != anim ) {
+ anim.add(window);
+ }
+ return new GLADComp(window, canvas);
+ }
+ private GLADComp createGLCanvas(final GLCapabilitiesImmutable caps, final boolean useGears, final GLAnimatorControl anim, final Dimension size) {
final GLCanvas canvas = new GLCanvas(caps);
canvas.setSize(size);
canvas.setPreferredSize(size);
@@ -238,9 +295,9 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
if( null != anim ) {
anim.add(canvas);
}
- return canvas;
+ return new GLADComp(canvas, canvas);
}
- private GLAutoDrawable createGLJPanel(final boolean initMT, final boolean useSwingDoubleBuffer, final GLCapabilitiesImmutable caps, final boolean useGears, final boolean skipGLOrientationVerticalFlip, final GLAnimatorControl anim, final Dimension size) {
+ private GLADComp createGLJPanel(final boolean initMT, final boolean useSwingDoubleBuffer, final GLCapabilitiesImmutable caps, final boolean useGears, final boolean skipGLOrientationVerticalFlip, final GLAnimatorControl anim, final Dimension size) {
final GLJPanel canvas = new GLJPanel(caps);
canvas.setSize(size);
canvas.setPreferredSize(size);
@@ -260,7 +317,7 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
if( initMT ) {
canvas.initializeBackend(true /* offthread */);
}
- return canvas;
+ return new GLADComp(canvas, canvas);
}
static GLCapabilitiesImmutable caps = null;
@@ -272,31 +329,37 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
@Test
public void test00NopNoGLDefGrid() throws InterruptedException, InvocationTargetException {
test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
- false /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.NOP_T, false /*useAnim*/, false /* overlap */);
}
@Test
public void test01NopGLCanvasDefGrid() throws InterruptedException, InvocationTargetException {
test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
- false /* useGLJPanel */, false /*useSwingDoubleBuffer*/, true /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.GLCanvas_T, false /*useAnim*/, false /* overlap */);
}
@Test
public void test02NopGLJPanelDefGridSingleAutoFlip() throws InterruptedException, InvocationTargetException {
test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
- true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.GLJPanel_T, false /*useAnim*/, false /* overlap */);
}
@Test
public void test03NopGLJPanelDefGridSingleManualFlip() throws InterruptedException, InvocationTargetException {
test(new GLCapabilities(null), false /*useGears*/, true /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
- true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.GLJPanel_T, false /*useAnim*/, false /* overlap */);
}
@Test
public void test04NopGLJPanelDefGridMTManualFlip() throws InterruptedException, InvocationTargetException {
test(new GLCapabilities(null), false /*useGears*/, true /*skipGLOrientationVerticalFlip*/, width , height, frameCount, true /* initMT */,
- true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.GLJPanel_T, false /*useAnim*/, false /* overlap */);
+ }
+
+ @Test
+ public void test05NopNewtCanvasAWTDefGrid() throws InterruptedException, InvocationTargetException {
+ test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
+ false /*useSwingDoubleBuffer*/, CanvasType.NewtCanvasAWT_T, false /*useAnim*/, false /* overlap */);
}
//
@@ -304,35 +367,34 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
//
@Test
- public void test10GearsNoGLDefGrid() throws InterruptedException, InvocationTargetException {
- test(new GLCapabilities(null), true /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
- false /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
- }
-
- @Test
public void test11GearsGLCanvasDefGrid() throws InterruptedException, InvocationTargetException {
test(new GLCapabilities(null), true /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
- false /* useGLJPanel */, false /*useSwingDoubleBuffer*/, true /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.GLCanvas_T, true /*useAnim*/, false /* overlap */);
}
@Test
public void test12GearsGLJPanelDefGridSingleAutoFlip() throws InterruptedException, InvocationTargetException {
test(new GLCapabilities(null), true /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
- true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.GLJPanel_T, true /*useAnim*/, false /* overlap */);
}
@Test
public void test13GearsGLJPanelDefGridSingleManualFlip() throws InterruptedException, InvocationTargetException {
test(new GLCapabilities(null), true /*useGears*/, true /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
- true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.GLJPanel_T, true /*useAnim*/, false /* overlap */);
}
@Test
public void test14GearsGLJPanelDefGridMTManualFlip() throws InterruptedException, InvocationTargetException {
test(new GLCapabilities(null), true /*useGears*/, true /*skipGLOrientationVerticalFlip*/, width , height, frameCount, true /* initMT */,
- true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.GLJPanel_T, true /*useAnim*/, false /* overlap */);
}
+ @Test
+ public void test15GearsNewtCanvasAWTDefGrid() throws InterruptedException, InvocationTargetException {
+ test(new GLCapabilities(null), true /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
+ false /*useSwingDoubleBuffer*/, CanvasType.NewtCanvasAWT_T, true /*useAnim*/, false /* overlap */);
+ }
//
// Overlap + NOP
@@ -342,31 +404,37 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
@Test
public void test20NopNoGLDefOverlap() throws InterruptedException, InvocationTargetException {
test(null, false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
- false /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, true /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.NOP_T, false /*useAnim*/, true /* overlap */);
}
@Test
public void test21NopGLCanvasDefOverlap() throws InterruptedException, InvocationTargetException {
test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
- false /* useGLJPanel */, false /*useSwingDoubleBuffer*/, true /* useGLCanvas */, false /*useAnim*/, true /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.GLCanvas_T, false /*useAnim*/, true /* overlap */);
}
@Test
public void test22NopGLJPanelDefOverlapSingle() throws InterruptedException, InvocationTargetException {
test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
- true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, true /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.GLJPanel_T, false /*useAnim*/, true /* overlap */);
}
@Test
public void test23NopGLJPanelDefOverlapMT() throws InterruptedException, InvocationTargetException {
test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, true /* initMT */,
- true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, true /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.GLJPanel_T, false /*useAnim*/, true /* overlap */);
+ }
+
+ @Test
+ public void test25NopNewtCanvasAWTDefOverlap() throws InterruptedException, InvocationTargetException {
+ test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
+ false /*useSwingDoubleBuffer*/, CanvasType.NewtCanvasAWT_T, false /*useAnim*/, true /* overlap */);
}
// @Test
public void testXXNopGLJPanelDefOverlapSingle() throws InterruptedException, InvocationTargetException {
test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
- true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, true /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.GLJPanel_T, false /*useAnim*/, true /* overlap */);
}
// @Test
@@ -374,7 +442,7 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
final GLCapabilities caps = new GLCapabilities(null);
caps.setBitmap(true);
test(caps, false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
- true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false);
+ false /*useSwingDoubleBuffer*/, CanvasType.GLJPanel_T, false /*useAnim*/, false);
}
static long duration = 0; // ms
@@ -386,7 +454,8 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
public static void main(final String[] args) {
boolean manual=false;
boolean waitMain = false;
- boolean useGLJPanel = true, initMT = false, useGLCanvas = false, useSwingDoubleBuffer=false;
+ CanvasType canvasType = CanvasType.GLJPanel_T;
+ boolean initMT = false, useSwingDoubleBuffer=false;
boolean useGears = false, skipGLOrientationVerticalFlip=false, useAnim = false;
boolean overlap = false;
@@ -403,16 +472,12 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
} else if(args[i].equals("-initMT")) {
initMT = true;
manual = true;
- } else if(args[i].equals("-glcanvas")) {
- useGLJPanel = false;
- useGLCanvas = true;
+ } else if(args[i].equals("-type")) {
+ i++;
+ canvasType = CanvasType.valueOf(args[i]);
manual = true;
} else if(args[i].equals("-swingDoubleBuffer")) {
useSwingDoubleBuffer = true;
- } else if(args[i].equals("-glnone")) {
- useGLJPanel = false;
- useGLCanvas = false;
- manual = true;
} else if(args[i].equals("-gears")) {
useGears = true;
} else if(args[i].equals("-anim")) {
@@ -438,7 +503,7 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
GLProfile.initSingleton();
final TestPerf001GLJPanelInit02AWT demo = new TestPerf001GLJPanelInit02AWT();
demo.test(null, useGears, skipGLOrientationVerticalFlip, width, height, frameCount,
- initMT, useGLJPanel, useSwingDoubleBuffer, useGLCanvas, useAnim, overlap);
+ initMT, useSwingDoubleBuffer, canvasType, useAnim, overlap);
} else {
org.junit.runner.JUnitCore.main(TestPerf001GLJPanelInit02AWT.class.getName());
}
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestMultipleNewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestMultipleNewtCanvasAWT.java
new file mode 100644
index 000000000..0e11ff1e8
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestMultipleNewtCanvasAWT.java
@@ -0,0 +1,185 @@
+/**
+ * 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.newt;
+
+import java.awt.Component;
+import java.awt.Dimension;
+import java.io.IOException;
+
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLProfile;
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.SwingUtilities;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.FixMethodOrder;
+import org.junit.runners.MethodSorters;
+
+import com.jogamp.newt.awt.NewtCanvasAWT;
+import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.Animator;
+
+
+/**
+ * TestMultipleNewtCanvasAWT
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestMultipleNewtCanvasAWT extends UITestCase {
+
+ static long durationPerTest = 1000;
+
+ @BeforeClass
+ public static void initClass() {
+ if(!GLProfile.isAvailable(GLProfile.GL2ES2)) {
+ setTestSupported(false);
+ }
+ }
+
+ @Test
+ public void test01() throws InterruptedException {
+ testImpl();
+ }
+
+ public void testImpl() throws InterruptedException {
+ final JFrame frame = new JFrame(this.getSimpleTestName("."));
+
+ //
+ // GLDrawableFactory factory = GLDrawableFactory.getFactory(GLProfile.get(GLProfile.GL2));
+ // GLContext sharedContext = factory.getOrCreateSharedContext(factory.getDefaultDevice());
+ //
+ final GLCapabilities glCapabilities = new GLCapabilities(GLProfile.get(GLProfile.GL2));
+ glCapabilities.setSampleBuffers(true);
+ glCapabilities.setNumSamples(4);
+
+ final GearsES2 eventListener1 = new GearsES2(0);
+ final GearsES2 eventListener2 = new GearsES2(1);
+
+ final Component openGLComponent1;
+ final Component openGLComponent2;
+ final GLAutoDrawable openGLAutoDrawable1;
+ final GLAutoDrawable openGLAutoDrawable2;
+
+ final GLWindow glWindow1 = GLWindow.create(glCapabilities);
+ final NewtCanvasAWT newtCanvasAWT1 = new NewtCanvasAWT(glWindow1);
+ newtCanvasAWT1.setPreferredSize(new Dimension(640, 480));
+ glWindow1.addGLEventListener(eventListener1);
+ //
+ final GLWindow glWindow2 = GLWindow.create(glCapabilities);
+ final NewtCanvasAWT newtCanvasAWT2 = new NewtCanvasAWT(glWindow2);
+ newtCanvasAWT2.setPreferredSize(new Dimension(640, 480));
+ glWindow2.addGLEventListener(eventListener2);
+
+ openGLComponent1 = newtCanvasAWT1;
+ openGLComponent2 = newtCanvasAWT2;
+ openGLAutoDrawable1 = glWindow1;
+ openGLAutoDrawable2 = glWindow2;
+
+ // group both OpenGL canvases / windows into a horizontal panel
+ final JPanel openGLPanel = new JPanel();
+ openGLPanel.setLayout(new BoxLayout(openGLPanel, BoxLayout.LINE_AXIS));
+ openGLPanel.add(openGLComponent1);
+ openGLPanel.add(Box.createHorizontalStrut(5));
+ openGLPanel.add(openGLComponent2);
+
+ final JPanel mainPanel = (JPanel) frame.getContentPane();
+ mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.LINE_AXIS));
+ mainPanel.add(Box.createHorizontalGlue());
+ mainPanel.add(openGLPanel);
+ mainPanel.add(Box.createHorizontalGlue());
+
+ final Animator animator = new Animator(Thread.currentThread().getThreadGroup());
+ animator.setUpdateFPSFrames(1, null);
+ animator.add(openGLAutoDrawable1);
+ animator.add(openGLAutoDrawable2);
+
+ // make the window visible using the EDT
+ SwingUtilities.invokeLater( new Runnable() {
+ public void run() {
+ frame.pack();
+ frame.setVisible(true);
+ }
+ });
+
+ Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true));
+ Assert.assertEquals(true, AWTRobotUtil.waitForRealized(openGLComponent1, true));
+ Assert.assertEquals(true, AWTRobotUtil.waitForRealized(openGLComponent2, true));
+
+ animator.start();
+
+ // sleep for test duration, then request the window to close, wait for the window to close,s and stop the animation
+ while(animator.isAnimating() && animator.getTotalFPSDuration() < durationPerTest) {
+ Thread.sleep(100);
+ }
+
+ animator.stop();
+
+ // ask the EDT to dispose of the frame;
+ // if using newt, explicitly dispose of the canvases because otherwise it seems our destroy methods are not called
+ SwingUtilities.invokeLater( new Runnable() {
+ public void run() {
+ newtCanvasAWT1.destroy(); // removeNotify does not destroy GLWindow
+ newtCanvasAWT2.destroy(); // removeNotify does not destroy GLWindow
+ frame.dispose();
+ }
+ });
+ Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, false));
+ Assert.assertEquals(true, AWTRobotUtil.waitForRealized(openGLComponent1, false));
+ Assert.assertEquals(true, AWTRobotUtil.waitForRealized(openGLComponent2, false));
+ }
+
+ static int atoi(final String a) {
+ int i=0;
+ try {
+ i = Integer.parseInt(a);
+ } catch (final Exception ex) { ex.printStackTrace(); }
+ return i;
+ }
+
+ public static void main(final String[] args) throws IOException {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ if (++i < args.length) {
+ durationPerTest = atoi(args[i]);
+ }
+ }
+ }
+ org.junit.runner.JUnitCore.main(TestMultipleNewtCanvasAWT.class.getName());
+ }
+
+}
+