aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xmake/scripts/tests-win.bat9
-rw-r--r--make/scripts/tests.sh3
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java31
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLCanvas.java37
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLJPanel.java31
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java37
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/GLContextDrawableSwitchBase0.java254
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/GLContextDrawableSwitchBase1.java (renamed from src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/GLContextDrawableSwitchBase.java)2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestBug722GLContextDrawableSwitchNewt2AWT.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch02AWT.java112
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch02NEWT.java100
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch11NewtAWT.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch12AWT.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch13Newt2AWT.java (renamed from src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch21Newt2AWT.java)4
14 files changed, 482 insertions, 144 deletions
diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat
index 2fec817cc..fb6e84773 100755
--- a/make/scripts/tests-win.bat
+++ b/make/scripts/tests-win.bat
@@ -1,5 +1,5 @@
REM scripts\java-win.bat jogamp.newt.awt.opengl.VersionApplet
-scripts\java-win.bat com.jogamp.newt.opengl.GLWindow
+REM scripts\java-win.bat com.jogamp.newt.opengl.GLWindow
REM scripts\java-win.bat javax.media.opengl.awt.GLCanvas
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT %*
REM scripts\java-win.bat com.jogamp.oculusvr.OVRVersion %*
@@ -77,8 +77,9 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDraw
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile02NEWT %*
-REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch01NEWT %*
-REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch11NEWT %*
+scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch02AWT %*
+REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch01NEWT %*
+REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch11NEWT %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT %*
@@ -183,7 +184,7 @@ REM scripts\java-win.bat testawt com.jogamp.opengl.test.junit.jogl.caps.TestMult
REM scripts\java-win.bat testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1NEWT %*
REM scripts\java-win.bat testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES2NEWT %*
REM scripts\java-win.bat testawt com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyAWT %*
-REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyNEWT %*
+scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyNEWT %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentChildWindowBug632NEWT %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug461OffscreenSupersamplingSwingAWT
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
index 48de758b5..641e78eef 100644
--- a/make/scripts/tests.sh
+++ b/make/scripts/tests.sh
@@ -375,7 +375,7 @@ function testawtswt() {
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $*
#testawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLCanvasAWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $*
-testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $*
+#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestVersionSemanticsNOUI $*
#
@@ -537,6 +537,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $*
#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.acore.glels.TestGLContextDrawableSwitch02NEWT $*
#testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch02AWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch01NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch10NEWT $*
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java b/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java
index a2978d6d5..c19bb12e9 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java
@@ -149,6 +149,37 @@ public class GLDrawableUtil {
}
/**
+ * Return a heuristic value whether switching the {@link GLContext} is safe between {@lin GLAutoDrawable}s,
+ * i.e. via {@link #swapGLContext(GLAutoDrawable, GLAutoDrawable)} or {@link #swapGLContextAndAllGLEventListener(GLAutoDrawable, GLAutoDrawable)}.
+ * <p>
+ * Method currently returns <code>false</code> if:
+ * <ul>
+ * <li>Switching between on- and offscreen and one of the following is <code>true</code>:
+ * <ul>
+ * <li>{@link GLCapabilitiesImmutable#getSampleBuffers() MSAA is used}[1], or
+ * <li>{@link GLCapabilitiesImmutable#getStereo() Stereo is used}
+ * </ul></li>
+ * </ul>
+ * Otherwise method returns <code>true</code>
+ * </p>
+ * <p>
+ * [1] See Bug 830: swapGLContextAndAllGLEventListener and onscreen MSAA w/ NV/GLX
+ * </p>
+ */
+ public static boolean isSwapGLContextSafe(final GLCapabilitiesImmutable a, final GLCapabilitiesImmutable b) {
+ if( ( a.isOnscreen() && !b.isOnscreen() || !a.isOnscreen() && b.isOnscreen() ) && // switching between on- and offscreen
+ (
+ ( a.getSampleBuffers() || b.getSampleBuffers() ) || // MSAA involved
+ ( a.getStereo() || b.getStereo() ) // Stereo involved
+ )
+ )
+ {
+ return false;
+ } else {
+ return true;
+ }
+ }
+ /**
* Swaps the {@link GLContext} and all {@link GLEventListener} between {@link GLAutoDrawable} <code>a</code> and <code>b</code>,
* while preserving it's initialized state, resets the GL-Viewport and issuing {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape(..)}.
* <p>
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
index a8aa7382d..4b1d4a7ff 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
@@ -860,32 +860,35 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
printAnimator.remove(GLCanvas.this);
}
printGLAD = GLCanvas.this; // _not_ default, shall be replaced by offscreen GLAD
- final GLCapabilities caps = (GLCapabilities)getChosenGLCapabilities().cloneMutable();
- final int printNumSamples = printAWTTiles.getNumSamples(caps);
+ final GLCapabilitiesImmutable gladCaps = getChosenGLCapabilities();
+ final int printNumSamples = printAWTTiles.getNumSamples(gladCaps);
GLDrawable printDrawable = printGLAD.getDelegatedDrawable();
- final boolean reqNewGLADSamples = printNumSamples != caps.getNumSamples();
+ final boolean reqNewGLADSamples = printNumSamples != gladCaps.getNumSamples();
final boolean reqNewGLADSize = printAWTTiles.customTileWidth != -1 && printAWTTiles.customTileWidth != printDrawable.getSurfaceWidth() ||
printAWTTiles.customTileHeight != -1 && printAWTTiles.customTileHeight != printDrawable.getSurfaceHeight();
- final boolean reqNewGLADOnscrn = caps.isOnscreen();
- // It is desired to use a new offscreen GLAD, however Bug 830 forbids this for AA onscreen context.
- // Bug 830: swapGLContextAndAllGLEventListener and onscreen MSAA w/ NV/GLX
- final boolean reqNewGLAD = !caps.getSampleBuffers() && ( reqNewGLADOnscrn || reqNewGLADSamples || reqNewGLADSize );
+ final boolean reqNewGLADOnscrn = gladCaps.isOnscreen();
+
+ final GLCapabilities newGLADCaps = (GLCapabilities)gladCaps.cloneMutable();
+ newGLADCaps.setDoubleBuffered(false);
+ newGLADCaps.setOnscreen(false);
+ if( printNumSamples != newGLADCaps.getNumSamples() ) {
+ newGLADCaps.setSampleBuffers(0 < printNumSamples);
+ newGLADCaps.setNumSamples(printNumSamples);
+ }
+ final boolean reqNewGLADSafe = GLDrawableUtil.isSwapGLContextSafe(gladCaps, newGLADCaps);
+
+ final boolean reqNewGLAD = ( reqNewGLADOnscrn || reqNewGLADSamples || reqNewGLADSize ) && reqNewGLADSafe;
+
if( DEBUG ) {
- System.err.println("AWT print.setup: reqNewGLAD "+reqNewGLAD+"[ onscreen "+reqNewGLADOnscrn+", samples "+reqNewGLADSamples+", size "+reqNewGLADSize+"], "+
+ System.err.println("AWT print.setup: reqNewGLAD "+reqNewGLAD+"[ onscreen "+reqNewGLADOnscrn+", samples "+reqNewGLADSamples+", size "+reqNewGLADSize+", safe "+reqNewGLADSafe+"], "+
", drawableSize "+printDrawable.getSurfaceWidth()+"x"+printDrawable.getSurfaceHeight()+
", customTileSize "+printAWTTiles.customTileWidth+"x"+printAWTTiles.customTileHeight+
", scaleMat "+printAWTTiles.scaleMatX+" x "+printAWTTiles.scaleMatY+
", numSamples "+printAWTTiles.customNumSamples+" -> "+printNumSamples+", printAnimator "+printAnimator);
}
if( reqNewGLAD ) {
- caps.setDoubleBuffered(false);
- caps.setOnscreen(false);
- if( printNumSamples != caps.getNumSamples() ) {
- caps.setSampleBuffers(0 < printNumSamples);
- caps.setNumSamples(printNumSamples);
- }
- final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile());
- printGLAD = factory.createOffscreenAutoDrawable(null, caps, null,
+ final GLDrawableFactory factory = GLDrawableFactory.getFactory(newGLADCaps.getGLProfile());
+ printGLAD = factory.createOffscreenAutoDrawable(null, newGLADCaps, null,
printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE,
printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE);
GLDrawableUtil.swapGLContextAndAllGLEventListener(GLCanvas.this, printGLAD);
@@ -896,7 +899,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
printAWTTiles.renderer.attachAutoDrawable(printGLAD);
if( DEBUG ) {
System.err.println("AWT print.setup "+printAWTTiles);
- System.err.println("AWT print.setup AA "+printNumSamples+", "+caps);
+ System.err.println("AWT print.setup AA "+printNumSamples+", "+newGLADCaps);
System.err.println("AWT print.setup printGLAD: "+printGLAD.getSurfaceWidth()+"x"+printGLAD.getSurfaceHeight()+", "+printGLAD);
System.err.println("AWT print.setup printDraw: "+printDrawable.getSurfaceWidth()+"x"+printDrawable.getSurfaceHeight()+", "+printDrawable);
}
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
index 3a1e45440..96f9e455c 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
@@ -712,27 +712,34 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
}
printGLAD = GLJPanel.this; // default: re-use
- final GLCapabilities caps = (GLCapabilities)getChosenGLCapabilities().cloneMutable();
- final int printNumSamples = printAWTTiles.getNumSamples(caps);
+ final GLCapabilitiesImmutable gladCaps = getChosenGLCapabilities();
+ final int printNumSamples = printAWTTiles.getNumSamples(gladCaps);
GLDrawable printDrawable = printGLAD.getDelegatedDrawable();
- final boolean reqNewGLADSamples = printNumSamples != caps.getNumSamples();
+ final boolean reqNewGLADSamples = printNumSamples != gladCaps.getNumSamples();
final boolean reqNewGLADSize = printAWTTiles.customTileWidth != -1 && printAWTTiles.customTileWidth != printDrawable.getSurfaceWidth() ||
printAWTTiles.customTileHeight != -1 && printAWTTiles.customTileHeight != printDrawable.getSurfaceHeight();
- final boolean reqNewGLAD = reqNewGLADSamples || reqNewGLADSize ;
+
+ final GLCapabilities newGLADCaps = (GLCapabilities)gladCaps.cloneMutable();
+ newGLADCaps.setDoubleBuffered(false);
+ newGLADCaps.setOnscreen(false);
+ if( printNumSamples != newGLADCaps.getNumSamples() ) {
+ newGLADCaps.setSampleBuffers(0 < printNumSamples);
+ newGLADCaps.setNumSamples(printNumSamples);
+ }
+ final boolean reqNewGLADSafe = GLDrawableUtil.isSwapGLContextSafe(gladCaps, newGLADCaps);
+
+ final boolean reqNewGLAD = ( reqNewGLADSamples || reqNewGLADSize ) && reqNewGLADSafe;
+
if( DEBUG ) {
- System.err.println("AWT print.setup: reqNewGLAD "+reqNewGLAD+"[ samples "+reqNewGLADSamples+", size "+reqNewGLADSize+"], "+
+ System.err.println("AWT print.setup: reqNewGLAD "+reqNewGLAD+"[ samples "+reqNewGLADSamples+", size "+reqNewGLADSize+", safe "+reqNewGLADSafe+"], "+
", drawableSize "+printDrawable.getSurfaceWidth()+"x"+printDrawable.getSurfaceHeight()+
", customTileSize "+printAWTTiles.customTileWidth+"x"+printAWTTiles.customTileHeight+
", scaleMat "+printAWTTiles.scaleMatX+" x "+printAWTTiles.scaleMatY+
", numSamples "+printAWTTiles.customNumSamples+" -> "+printNumSamples+", printAnimator "+printAnimator);
}
if( reqNewGLAD ) {
- caps.setDoubleBuffered(false);
- caps.setOnscreen(false);
- caps.setSampleBuffers(0 < printNumSamples);
- caps.setNumSamples(printNumSamples);
- final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile());
- printGLAD = factory.createOffscreenAutoDrawable(null, caps, null,
+ final GLDrawableFactory factory = GLDrawableFactory.getFactory(newGLADCaps.getGLProfile());
+ printGLAD = factory.createOffscreenAutoDrawable(null, newGLADCaps, null,
printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE,
printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE);
GLDrawableUtil.swapGLContextAndAllGLEventListener(GLJPanel.this, printGLAD);
@@ -743,7 +750,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
printAWTTiles.renderer.attachAutoDrawable(printGLAD);
if( DEBUG ) {
System.err.println("AWT print.setup "+printAWTTiles);
- System.err.println("AWT print.setup AA "+printNumSamples+", "+caps);
+ System.err.println("AWT print.setup AA "+printNumSamples+", "+newGLADCaps);
System.err.println("AWT print.setup printGLAD: "+printGLAD.getSurfaceWidth()+"x"+printGLAD.getSurfaceHeight()+", "+printGLAD);
System.err.println("AWT print.setup printDraw: "+printDrawable.getSurfaceWidth()+"x"+printDrawable.getSurfaceHeight()+", "+printDrawable);
}
diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
index c44584d78..c0c28d515 100644
--- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
+++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
@@ -53,6 +53,7 @@ import javax.media.nativewindow.WindowClosingProtocol;
import javax.media.opengl.GLAnimatorControl;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLCapabilitiesImmutable;
import javax.media.opengl.GLDrawable;
import javax.media.opengl.GLDrawableFactory;
import javax.swing.MenuSelectionManager;
@@ -641,33 +642,35 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
printAnimator.remove(glad);
}
printGLAD = glad; // _not_ default, shall be replaced by offscreen GLAD
- final GLCapabilities caps = (GLCapabilities)glad.getChosenGLCapabilities().cloneMutable();
- final int printNumSamples = printAWTTiles.getNumSamples(caps);
+ final GLCapabilitiesImmutable gladCaps = glad.getChosenGLCapabilities();
+ final int printNumSamples = printAWTTiles.getNumSamples(gladCaps);
GLDrawable printDrawable = printGLAD.getDelegatedDrawable();
- final boolean reqNewGLADSamples = printNumSamples != caps.getNumSamples();
+ final boolean reqNewGLADSamples = printNumSamples != gladCaps.getNumSamples();
final boolean reqNewGLADSize = printAWTTiles.customTileWidth != -1 && printAWTTiles.customTileWidth != printDrawable.getSurfaceWidth() ||
printAWTTiles.customTileHeight != -1 && printAWTTiles.customTileHeight != printDrawable.getSurfaceHeight();
- final boolean reqNewGLADOnscrn = caps.isOnscreen();
+ final boolean reqNewGLADOnscrn = gladCaps.isOnscreen();
+
+ final GLCapabilities newGLADCaps = (GLCapabilities)gladCaps.cloneMutable();
+ newGLADCaps.setDoubleBuffered(false);
+ newGLADCaps.setOnscreen(false);
+ if( printNumSamples != newGLADCaps.getNumSamples() ) {
+ newGLADCaps.setSampleBuffers(0 < printNumSamples);
+ newGLADCaps.setNumSamples(printNumSamples);
+ }
+ final boolean reqNewGLADSafe = GLDrawableUtil.isSwapGLContextSafe(gladCaps, newGLADCaps);
+
+ final boolean reqNewGLAD = ( reqNewGLADOnscrn || reqNewGLADSamples || reqNewGLADSize ) && reqNewGLADSafe;
- // It is desired to use a new offscreen GLAD, however Bug 830 forbids this for AA onscreen context.
- // Bug 830: swapGLContextAndAllGLEventListener and onscreen MSAA w/ NV/GLX
- final boolean reqNewGLAD = !caps.getSampleBuffers() && ( reqNewGLADOnscrn || reqNewGLADSamples || reqNewGLADSize );
if( DEBUG ) {
- System.err.println("AWT print.setup: reqNewGLAD "+reqNewGLAD+"[ onscreen "+reqNewGLADOnscrn+", samples "+reqNewGLADSamples+", size "+reqNewGLADSize+"], "+
+ System.err.println("AWT print.setup: reqNewGLAD "+reqNewGLAD+"[ onscreen "+reqNewGLADOnscrn+", samples "+reqNewGLADSamples+", size "+reqNewGLADSize+", safe "+reqNewGLADSafe+"], "+
", drawableSize "+printDrawable.getSurfaceWidth()+"x"+printDrawable.getSurfaceHeight()+
", customTileSize "+printAWTTiles.customTileWidth+"x"+printAWTTiles.customTileHeight+
", scaleMat "+printAWTTiles.scaleMatX+" x "+printAWTTiles.scaleMatY+
", numSamples "+printAWTTiles.customNumSamples+" -> "+printNumSamples+", printAnimator "+printAnimator);
}
if( reqNewGLAD ) {
- caps.setDoubleBuffered(false);
- caps.setOnscreen(false);
- if( printNumSamples != caps.getNumSamples() ) {
- caps.setSampleBuffers(0 < printNumSamples);
- caps.setNumSamples(printNumSamples);
- }
- final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile());
- printGLAD = factory.createOffscreenAutoDrawable(null, caps, null,
+ final GLDrawableFactory factory = GLDrawableFactory.getFactory(newGLADCaps.getGLProfile());
+ printGLAD = factory.createOffscreenAutoDrawable(null, newGLADCaps, null,
printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE,
printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE);
GLDrawableUtil.swapGLContextAndAllGLEventListener(glad, printGLAD);
@@ -678,7 +681,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
printAWTTiles.renderer.attachAutoDrawable(printGLAD);
if( DEBUG ) {
System.err.println("AWT print.setup "+printAWTTiles);
- System.err.println("AWT print.setup AA "+printNumSamples+", "+caps);
+ System.err.println("AWT print.setup AA "+printNumSamples+", "+newGLADCaps);
System.err.println("AWT print.setup printGLAD: "+printGLAD.getSurfaceWidth()+"x"+printGLAD.getSurfaceHeight()+", "+printGLAD);
System.err.println("AWT print.setup printDraw: "+printDrawable.getSurfaceWidth()+"x"+printDrawable.getSurfaceHeight()+", "+printDrawable);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/GLContextDrawableSwitchBase0.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/GLContextDrawableSwitchBase0.java
new file mode 100644
index 000000000..49d16a80a
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/GLContextDrawableSwitchBase0.java
@@ -0,0 +1,254 @@
+/**
+ * Copyright 2013 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.acore.glels;
+
+import java.lang.reflect.InvocationTargetException;
+
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLProfile;
+
+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;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.FixMethodOrder;
+import org.junit.runners.MethodSorters;
+
+/**
+ * Test re-association (switching) of GLWindow /GLDrawables,
+ * from GLWindow/GLOffscreenAutoDrawable to an GLOffscreenAutoDrawable and back.
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public abstract class GLContextDrawableSwitchBase0 extends UITestCase {
+ static int width, height;
+ static boolean testEvenUnsafeSwapGLContext = false;
+
+ static GLCapabilities getCaps(final String profile) {
+ if( !GLProfile.isAvailable(profile) ) {
+ System.err.println("Profile "+profile+" n/a");
+ return null;
+ }
+ return new GLCapabilities(GLProfile.get(profile));
+ }
+
+ @BeforeClass
+ public static void initClass() {
+ width = 256;
+ height = 256;
+ }
+
+ public abstract GLAutoDrawable createGLAutoDrawable(final QuitAdapter quitAdapter, final GLCapabilitiesImmutable caps, final int width, final int height) throws InterruptedException, InvocationTargetException;
+ public abstract void destroyGLAutoDrawable(final GLAutoDrawable glad) throws InterruptedException, InvocationTargetException;
+
+ @Test(timeout=30000)
+ public void test01aSwitch2Onscreen2OnscreenGL2ES2_Def() throws InterruptedException, InvocationTargetException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2);
+ if(null == reqGLCaps) return;
+ testImpl(reqGLCaps, true);
+ }
+
+ @Test(timeout=30000)
+ public void test01bSwitch2Onscreen2OffscreenGL2ES2_Def() throws InterruptedException, InvocationTargetException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2);
+ if(null == reqGLCaps) return;
+ testImpl(reqGLCaps, false);
+ }
+
+ @Test(timeout=30000)
+ public void test01cSwitch2Offscreen2OffscreenGL2ES2_Def() throws InterruptedException, InvocationTargetException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ testImpl(reqGLCaps, false);
+ }
+
+ @Test(timeout=30000)
+ public void test01dSwitch2Offscreen2OnscreenGL2ES2_Def() throws InterruptedException, InvocationTargetException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ testImpl(reqGLCaps, true);
+ }
+
+ @Test(timeout=30000)
+ public void test02aSwitch2Onscreen2OnscreenGL2ES2_MSAA() throws InterruptedException, InvocationTargetException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setNumSamples(4);
+ reqGLCaps.setSampleBuffers(true);
+ testImpl(reqGLCaps, true);
+ }
+
+ @Test(timeout=30000)
+ public void test02bSwitch2Onscreen2OffscreenGL2ES2_MSAA() throws InterruptedException, InvocationTargetException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setNumSamples(4);
+ reqGLCaps.setSampleBuffers(true);
+ testImpl(reqGLCaps, false);
+ }
+
+ @Test(timeout=30000)
+ public void test02cSwitch2Offscreen2OffscreenGL2ES2_MSAA() throws InterruptedException, InvocationTargetException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ reqGLCaps.setNumSamples(4);
+ reqGLCaps.setSampleBuffers(true);
+ testImpl(reqGLCaps, false);
+ }
+
+ @Test(timeout=30000)
+ public void test02dSwitch2Offscreen2OnscreenGL2ES2_MSAA() throws InterruptedException, InvocationTargetException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ reqGLCaps.setNumSamples(4);
+ reqGLCaps.setSampleBuffers(true);
+ testImpl(reqGLCaps, true);
+ }
+
+ @Test(timeout=30000)
+ public void test03aSwitch2Onscreen2OnscreenGL2ES2_Accu() throws InterruptedException, InvocationTargetException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setAccumRedBits(1);
+ reqGLCaps.setAccumGreenBits(1);
+ reqGLCaps.setAccumBlueBits(1);
+ testImpl(reqGLCaps, true);
+ }
+
+ @Test(timeout=30000)
+ public void test03bSwitch2Onscreen2OffscreenGL2ES2_Accu() throws InterruptedException, InvocationTargetException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setAccumRedBits(1);
+ reqGLCaps.setAccumGreenBits(1);
+ reqGLCaps.setAccumBlueBits(1);
+ testImpl(reqGLCaps, false);
+ }
+
+ @Test(timeout=30000)
+ public void test03cSwitch2Offscreen2OffscreenGL2ES2_Accu() throws InterruptedException, InvocationTargetException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ reqGLCaps.setAccumRedBits(1);
+ reqGLCaps.setAccumGreenBits(1);
+ reqGLCaps.setAccumBlueBits(1);
+ testImpl(reqGLCaps, false);
+ }
+
+ @Test(timeout=30000)
+ public void test03dSwitch2Offscreen2OnscreenGL2ES2_Accu() throws InterruptedException, InvocationTargetException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ reqGLCaps.setAccumRedBits(1);
+ reqGLCaps.setAccumGreenBits(1);
+ reqGLCaps.setAccumBlueBits(1);
+ testImpl(reqGLCaps, true);
+ }
+
+ private void testImpl(final GLCapabilitiesImmutable srcCaps, final boolean dstOnscreen) throws InterruptedException, InvocationTargetException {
+ final QuitAdapter quitAdapter = new QuitAdapter();
+ final GLAutoDrawable gladSource = createGLAutoDrawable(quitAdapter, srcCaps, width, height);
+
+ final GLCapabilitiesImmutable srcCapsChosen = gladSource.getChosenGLCapabilities();
+
+ final GLCapabilities dstCaps = (GLCapabilities) srcCapsChosen.cloneMutable();
+ dstCaps.setOnscreen(dstOnscreen);
+
+ final boolean isSwapGLContextSafe = GLDrawableUtil.isSwapGLContextSafe(srcCapsChosen, dstCaps);
+ System.err.println("Source Caps Requested: "+srcCaps);
+ System.err.println("Source Caps Chosen : "+srcCapsChosen);
+ System.err.println("Dest Caps Requested: "+dstCaps);
+ System.err.println("Is SwapGLContext safe: "+isSwapGLContextSafe);
+
+ if( !isSwapGLContextSafe && !testEvenUnsafeSwapGLContext ) {
+ System.err.println("Supressing unsafe tests ...");
+ destroyGLAutoDrawable(gladSource);
+ return;
+ }
+
+ final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener();
+ final GearsES2 gears = new GearsES2(1);
+ gears.setVerbose(false);
+ gladSource.addGLEventListener(gears);
+ gladSource.addGLEventListener(snapshotGLEventListener);
+ snapshotGLEventListener.setMakeSnapshot();
+
+ final Animator animator = new Animator();
+ animator.add(gladSource);
+ animator.start();
+
+ int s = 0;
+ final long t0 = System.currentTimeMillis();
+ long t1 = t0;
+
+ final GLAutoDrawable gladDest = createGLAutoDrawable(quitAdapter, dstCaps, width, height);
+ RuntimeException caught = null;
+ try {
+ while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration ) {
+ if( ( t1 - t0 ) / period > s) {
+ s++;
+ System.err.println(s+" - switch - START "+ ( t1 - t0 ));
+
+ // switch context _and_ the demo synchronously
+ GLDrawableUtil.swapGLContextAndAllGLEventListener(gladSource, gladDest);
+ snapshotGLEventListener.setMakeSnapshot();
+
+ System.err.println(s+" - switch - END "+ ( t1 - t0 ));
+ }
+ Thread.sleep(100);
+ t1 = System.currentTimeMillis();
+ }
+ } catch (final RuntimeException t) {
+ caught = t;
+ }
+
+ animator.stop();
+ destroyGLAutoDrawable(gladDest);
+ destroyGLAutoDrawable(gladSource);
+
+ if( null != caught ) {
+ throw caught;
+ }
+ }
+
+ // default timing for 2 switches
+ static long duration = 2900; // ms
+ static long period = 1000; // ms
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/GLContextDrawableSwitchBase.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/GLContextDrawableSwitchBase1.java
index b19dc38f2..0e7ea3e83 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/GLContextDrawableSwitchBase.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/GLContextDrawableSwitchBase1.java
@@ -68,7 +68,7 @@ import org.junit.BeforeClass;
* See Bug 665 - https://jogamp.org/bugzilla/show_bug.cgi?id=665.
* </p>
*/
-public abstract class GLContextDrawableSwitchBase extends UITestCase {
+public abstract class GLContextDrawableSwitchBase1 extends UITestCase {
static protected enum GLADType { GLCanvasOnscreen, GLCanvasOffscreen, GLWindow, GLOffscreen };
// default period for 1 GLAD cycle
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestBug722GLContextDrawableSwitchNewt2AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestBug722GLContextDrawableSwitchNewt2AWT.java
index 512ebc974..e961fe32d 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestBug722GLContextDrawableSwitchNewt2AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestBug722GLContextDrawableSwitchNewt2AWT.java
@@ -54,7 +54,7 @@ import org.junit.runners.MethodSorters;
* </p>
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestBug722GLContextDrawableSwitchNewt2AWT extends GLContextDrawableSwitchBase {
+public class TestBug722GLContextDrawableSwitchNewt2AWT extends GLContextDrawableSwitchBase1 {
static int loops = 10;
static long duration2 = 100; // ms
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 d665c1a87..d9f2d0e18 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
@@ -29,6 +29,7 @@
package com.jogamp.opengl.test.junit.jogl.acore.glels;
import java.awt.BorderLayout;
+import java.awt.Component;
import java.awt.Dimension;
import java.awt.Frame;
import java.io.IOException;
@@ -38,20 +39,15 @@ import com.jogamp.newt.event.TraceWindowAdapter;
import com.jogamp.newt.event.awt.AWTWindowAdapter;
import javax.media.opengl.GLAutoDrawable;
-import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLCapabilitiesImmutable;
import javax.media.opengl.GLDrawableFactory;
-import javax.media.opengl.GLProfile;
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 jogamp.nativewindow.awt.AWTMisc;
+
import com.jogamp.opengl.test.junit.util.QuitAdapter;
-import com.jogamp.opengl.test.junit.util.UITestCase;
import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
@@ -60,26 +56,15 @@ import org.junit.runners.MethodSorters;
* from GLCanvas to an GLOffscreenAutoDrawable and back.
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestGLContextDrawableSwitch02AWT extends UITestCase {
- static int width, height;
-
- static GLCapabilities getCaps(final String profile) {
- if( !GLProfile.isAvailable(profile) ) {
- System.err.println("Profile "+profile+" n/a");
- return null;
- }
- return new GLCapabilities(GLProfile.get(profile));
- }
+public class TestGLContextDrawableSwitch02AWT extends GLContextDrawableSwitchBase0 {
- @BeforeClass
- public static void initClass() {
- width = 256;
- height = 256;
- }
-
- private GLAutoDrawable createGLAutoDrawable(final Frame frame, final GLCapabilities caps, final int width, final int height) throws InterruptedException, InvocationTargetException {
+ @Override
+ public GLAutoDrawable createGLAutoDrawable(final QuitAdapter quitAdapter, final GLCapabilitiesImmutable caps, final int width, final int height) throws InterruptedException, InvocationTargetException {
final GLAutoDrawable glad;
if( caps.isOnscreen() ) {
+ final Frame frame = new Frame("Gears AWT Test");
+ Assert.assertNotNull(frame);
+
final GLCanvas glCanvas = new GLCanvas(caps);
Assert.assertNotNull(glCanvas);
final Dimension glc_sz = new Dimension(width, height);
@@ -88,6 +73,8 @@ public class TestGLContextDrawableSwitch02AWT extends UITestCase {
glCanvas.setSize(glc_sz);
glad = glCanvas;
+ new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter), glCanvas).addTo(frame);
+
frame.setLayout(new BorderLayout());
frame.add(glCanvas, BorderLayout.CENTER);
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
@@ -95,7 +82,6 @@ public class TestGLContextDrawableSwitch02AWT extends UITestCase {
frame.pack();
frame.setVisible(true);
}});
-
} else {
final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile());
glad = factory.createOffscreenAutoDrawable(null, caps, null, width, height);
@@ -104,70 +90,20 @@ public class TestGLContextDrawableSwitch02AWT extends UITestCase {
return glad;
}
- @Test(timeout=30000)
- public void testSwitch2AWTGLCanvas2OffscreenGL2ES2() throws InterruptedException, InvocationTargetException {
- final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2);
- if(null == reqGLCaps) return;
- testSwitch2AWTGLCanvas2OffscreenImpl(reqGLCaps);
- }
-
- private void testSwitch2AWTGLCanvas2OffscreenImpl(final GLCapabilities capsOnscreen) throws InterruptedException, InvocationTargetException {
- final GLCapabilities capsOffscreen = (GLCapabilities) capsOnscreen.clone();
- capsOffscreen.setOnscreen(false);
-
- final Frame frame = new Frame("Gears AWT Test");
- Assert.assertNotNull(frame);
-
- final 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();
- final GearsES2 gears = new GearsES2(1);
- glCanvas.addGLEventListener(gears);
- glCanvas.addGLEventListener(snapshotGLEventListener);
- snapshotGLEventListener.setMakeSnapshot();
-
- final Animator animator = new Animator();
- animator.add(glCanvas);
- animator.start();
-
- int s = 0;
- final long t0 = System.currentTimeMillis();
- long t1 = t0;
-
- final GLAutoDrawable glOffscreen = createGLAutoDrawable(null, capsOffscreen, width, height);
- while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration ) {
- if( ( t1 - t0 ) / period > s) {
- s++;
- System.err.println(s+" - switch - START "+ ( t1 - t0 ));
-
- // switch context _and_ the demo synchronously
- GLDrawableUtil.swapGLContextAndAllGLEventListener(glCanvas, glOffscreen);
- snapshotGLEventListener.setMakeSnapshot();
-
- System.err.println(s+" - switch - END "+ ( t1 - t0 ));
- }
- Thread.sleep(100);
- t1 = System.currentTimeMillis();
+ @Override
+ public void destroyGLAutoDrawable(final GLAutoDrawable glad) throws InterruptedException, InvocationTargetException {
+ if( glad.getChosenGLCapabilities().isOnscreen() ) {
+ final Frame frame = AWTMisc.getFrame((Component)glad);
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ final Frame _frame = frame;
+ _frame.dispose();
+ }});
+ } else {
+ glad.destroy();
}
-
- animator.stop();
- // glCanvas.destroy();
- glOffscreen.destroy();
-
- javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
- public void run() {
- final Frame _frame = frame;
- _frame.dispose();
- }});
}
- // default timing for 2 switches
- static long duration = 2900; // ms
- static long period = 1000; // ms
-
public static void main(final String args[]) throws IOException {
for(int i=0; i<args.length; i++) {
if(args[i].equals("-time")) {
@@ -180,6 +116,8 @@ public class TestGLContextDrawableSwitch02AWT extends UITestCase {
try {
period = Integer.parseInt(args[i]);
} catch (final Exception ex) { ex.printStackTrace(); }
+ } else if(args[i].equals("-testUnsafe")) {
+ testEvenUnsafeSwapGLContext = true;
}
}
/**
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch02NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch02NEWT.java
new file mode 100644
index 000000000..c8a78d05f
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch02NEWT.java
@@ -0,0 +1,100 @@
+/**
+ * Copyright 2013 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.acore.glels;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+
+import com.jogamp.newt.opengl.GLWindow;
+
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLDrawableFactory;
+
+import com.jogamp.opengl.test.junit.util.QuitAdapter;
+
+import org.junit.Assert;
+import org.junit.FixMethodOrder;
+import org.junit.runners.MethodSorters;
+
+/**
+ * Test re-association (switching) of GLWindow /GLDrawables,
+ * from GLWindow/GLOffscreenAutoDrawable to an GLOffscreenAutoDrawable and back.
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestGLContextDrawableSwitch02NEWT extends GLContextDrawableSwitchBase0 {
+ @Override
+ public GLAutoDrawable createGLAutoDrawable(final QuitAdapter quitAdapter, final GLCapabilitiesImmutable caps, final int width, final int height) throws InterruptedException, InvocationTargetException {
+ final GLAutoDrawable glad;
+ if( caps.isOnscreen() ) {
+ final GLWindow glWindow = GLWindow.create(caps);
+ Assert.assertNotNull(glWindow);
+ glad = glWindow;
+
+ if( null != quitAdapter ) {
+ glWindow.addWindowListener(quitAdapter);
+ }
+
+ glWindow.setVisible(true);
+ } else {
+ final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile());
+ glad = factory.createOffscreenAutoDrawable(null, caps, null, width, height);
+ Assert.assertNotNull(glad);
+ }
+ return glad;
+ }
+
+ @Override
+ public void destroyGLAutoDrawable(final GLAutoDrawable glad) throws InterruptedException, InvocationTargetException {
+ glad.destroy();
+ }
+
+ public static void main(final String args[]) throws IOException {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ try {
+ duration = Integer.parseInt(args[i]);
+ } catch (final Exception ex) { ex.printStackTrace(); }
+ } else if(args[i].equals("-period")) {
+ i++;
+ try {
+ period = Integer.parseInt(args[i]);
+ } catch (final Exception ex) { ex.printStackTrace(); }
+ } else if(args[i].equals("-testUnsafe")) {
+ testEvenUnsafeSwapGLContext = true;
+ }
+ }
+ /**
+ BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
+ System.err.println("Press enter to continue");
+ System.err.println(stdin.readLine()); */
+ org.junit.runner.JUnitCore.main(TestGLContextDrawableSwitch02NEWT.class.getName());
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch11NewtAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch11NewtAWT.java
index 9697869bc..f1c08c889 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch11NewtAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch11NewtAWT.java
@@ -60,7 +60,7 @@ import org.junit.runners.MethodSorters;
* </p>
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestGLContextDrawableSwitch11NewtAWT extends GLContextDrawableSwitchBase {
+public class TestGLContextDrawableSwitch11NewtAWT extends GLContextDrawableSwitchBase1 {
@Test(timeout=30000)
public void test21GLWindowGL2ES2() throws InterruptedException {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch12AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch12AWT.java
index 4ad0b1dc5..795e53768 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch12AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch12AWT.java
@@ -61,7 +61,7 @@ import org.junit.runners.MethodSorters;
* </p>
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestGLContextDrawableSwitch12AWT extends GLContextDrawableSwitchBase {
+public class TestGLContextDrawableSwitch12AWT extends GLContextDrawableSwitchBase1 {
@Test(timeout=30000)
public void test01GLCanvasOnscreenGL2ES2() throws InterruptedException {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch21Newt2AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch13Newt2AWT.java
index eaf3d37d4..27d5ff80a 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch21Newt2AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch13Newt2AWT.java
@@ -73,7 +73,7 @@ import org.junit.runners.MethodSorters;
* </p>
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestGLContextDrawableSwitch21Newt2AWT extends GLContextDrawableSwitchBase {
+public class TestGLContextDrawableSwitch13Newt2AWT extends GLContextDrawableSwitchBase1 {
@Test(timeout=30000)
public void test01GLCanvasOnScrn2GLWindowGL2ES2() throws InterruptedException {
@@ -190,6 +190,6 @@ public class TestGLContextDrawableSwitch21Newt2AWT extends GLContextDrawableSwit
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
System.err.println("Press enter to continue");
System.err.println(stdin.readLine()); */
- org.junit.runner.JUnitCore.main(TestGLContextDrawableSwitch21Newt2AWT.class.getName());
+ org.junit.runner.JUnitCore.main(TestGLContextDrawableSwitch13Newt2AWT.class.getName());
}
}