summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/jogl/classes/jogamp/opengl/GLContextImpl.java9
-rw-r--r--src/jogl/classes/jogamp/opengl/GLEventListenerState.java134
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java2
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java2
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java5
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitch01NEWT.java57
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitch11NEWT.java63
7 files changed, 219 insertions, 53 deletions
diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
index 2a2b6a8fd..b17fce569 100644
--- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
@@ -206,11 +206,12 @@ public abstract class GLContextImpl extends GLContext {
if( drawable == readWrite && ( setWriteOnly || drawableRead == readWrite ) ) {
return drawable; // no change.
}
- final boolean lockHeld = lock.isOwner(Thread.currentThread());
+ final Thread currentThread = Thread.currentThread();
+ final boolean lockHeld = lock.isOwner(currentThread);
if(lockHeld) {
release();
} else if(lock.isLockedByOtherThread()) { // still could glitch ..
- throw new GLException("GLContext current by other thread ("+lock.getOwner()+"), operation not allowed.");
+ throw new GLException("GLContext current by other thread "+lock.getOwner().getName()+", operation not allowed on this thread "+currentThread.getName());
}
if( !setWriteOnly || drawableRead == drawable ) { // if !setWriteOnly || !explicitReadDrawable
drawableRead = (GLDrawableImpl) readWrite;
@@ -339,7 +340,7 @@ public abstract class GLContextImpl extends GLContext {
}
if (contextHandle != 0) {
final int lockRes = drawable.lockSurface();
- if (NativeSurface.LOCK_SURFACE_NOT_READY == lockRes) {
+ if (NativeSurface.LOCK_SURFACE_NOT_READY >= lockRes) {
// this would be odd ..
throw new GLException("Surface not ready to lock: "+drawable);
}
@@ -413,7 +414,7 @@ public abstract class GLContextImpl extends GLContext {
}
final int lockRes = drawable.lockSurface();
- if (NativeSurface.LOCK_SURFACE_NOT_READY == lockRes) {
+ if (NativeSurface.LOCK_SURFACE_NOT_READY >= lockRes) {
// this would be odd ..
throw new GLException("Surface not ready to lock");
}
diff --git a/src/jogl/classes/jogamp/opengl/GLEventListenerState.java b/src/jogl/classes/jogamp/opengl/GLEventListenerState.java
index dea2bc85b..7a2569850 100644
--- a/src/jogl/classes/jogamp/opengl/GLEventListenerState.java
+++ b/src/jogl/classes/jogamp/opengl/GLEventListenerState.java
@@ -33,7 +33,9 @@ import java.util.List;
import javax.media.nativewindow.AbstractGraphicsConfiguration;
import javax.media.nativewindow.AbstractGraphicsDevice;
import javax.media.nativewindow.AbstractGraphicsScreen;
+import javax.media.nativewindow.NativeSurface;
import javax.media.nativewindow.NativeWindowFactory;
+import javax.media.nativewindow.ProxySurface;
import javax.media.nativewindow.VisualIDHolder;
import javax.media.opengl.GLAnimatorControl;
import javax.media.opengl.GLAutoDrawable;
@@ -43,6 +45,7 @@ import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLException;
import javax.media.opengl.GLRunnable;
+import com.jogamp.common.util.locks.RecursiveLock;
import com.jogamp.nativewindow.MutableGraphicsConfiguration;
/**
@@ -68,7 +71,11 @@ import com.jogamp.nativewindow.MutableGraphicsConfiguration;
* <p>
*/
public class GLEventListenerState {
- private GLEventListenerState(AbstractGraphicsScreen screen, GLCapabilitiesImmutable caps, GLContext context, int count, GLAnimatorControl anim) {
+ private static final boolean DEBUG = true;
+
+ private GLEventListenerState(AbstractGraphicsScreen upstreamScreen, AbstractGraphicsScreen screen, GLCapabilitiesImmutable caps,
+ GLContext context, int count, GLAnimatorControl anim) {
+ this.upstreamScreen = upstreamScreen;
this.screen = screen;
this.caps = caps;
this.context = context;
@@ -89,6 +96,7 @@ public class GLEventListenerState {
public final int listenerCount() { return listeners.length; }
+ public final AbstractGraphicsScreen upstreamScreen;
public final AbstractGraphicsScreen screen;
public final GLCapabilitiesImmutable caps;
public final GLContext context;
@@ -112,6 +120,11 @@ public class GLEventListenerState {
owner = false;
}
}
+
+ private static AbstractGraphicsScreen cloneScreen(AbstractGraphicsScreen aScreen) {
+ final AbstractGraphicsDevice aDevice2 = (AbstractGraphicsDevice) aScreen.getDevice().clone();
+ return NativeWindowFactory.createScreen( aDevice2, aScreen.getIndex() );
+ }
/**
* Moves all GLEventListenerState components from the given {@link GLAutoDrawable}
@@ -138,19 +151,45 @@ public class GLEventListenerState {
// Create new AbstractGraphicsScreen w/ cloned AbstractGraphicsDevice for future GLAutoDrawable
// allowing this AbstractGraphicsDevice to loose ownership -> not closing display/device!
- final AbstractGraphicsConfiguration aCfg1 = a.getNativeSurface().getGraphicsConfiguration();
- final GLCapabilitiesImmutable caps1 = (GLCapabilitiesImmutable) aCfg1.getChosenCapabilities();
- final AbstractGraphicsScreen aScreen1 = aCfg1.getScreen();
- final AbstractGraphicsDevice aDevice1 = aScreen1.getDevice();
- final AbstractGraphicsDevice aDevice2 = (AbstractGraphicsDevice) aDevice1.clone();
- final AbstractGraphicsScreen aScreen2 = NativeWindowFactory.createScreen( NativeWindowFactory.getNativeWindowType(false), aDevice2, aScreen1.getIndex() );
+ final NativeSurface aSurface = a.getNativeSurface();
+ final AbstractGraphicsConfiguration aCfg = aSurface.getGraphicsConfiguration();
+ final AbstractGraphicsScreen aScreen1 = aCfg.getScreen();
+ final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) aCfg.getChosenCapabilities();
+ final AbstractGraphicsScreen aScreen2 = cloneScreen(aScreen1);
+ if( DEBUG ) {
+ System.err.println("X00 NativeSurface: "+aSurface.getClass().getName()+", "+aSurface);
+ }
+ aScreen1.getDevice().clearHandleOwner(); // don't close device handle
+
+ final AbstractGraphicsScreen aUpScreen2;
+ {
+ AbstractGraphicsScreen _aUpScreen2=null;
+ if(aSurface instanceof ProxySurface) {
+ final ProxySurface aProxy = (ProxySurface)aSurface;
+ final NativeSurface aUpSurface = aProxy.getUpstreamSurface();
+ if(null != aUpSurface) {
+ System.err.println("X00 UpstreamSurface: "+aUpSurface.getClass().getName()+", "+aUpSurface);
+ }
+ aProxy.clearUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); // don't close device handle
+ if(null != aUpSurface) {
+ final AbstractGraphicsScreen aUpScreen1 = aUpSurface.getGraphicsConfiguration().getScreen();
+ _aUpScreen2 = cloneScreen(aUpScreen1);
+ if(null != aUpScreen1) {
+ aUpScreen1.getDevice().clearHandleOwner(); // don't close device handle
+ }
+ System.err.println("X0X NativeSurface: "+aSurface.getClass().getName()+", "+aSurface);
+ System.err.println("X0X UpstreamSurface: "+aUpSurface.getClass().getName()+", "+aUpSurface);
+ }
+ }
+ aUpScreen2=_aUpScreen2;
+ }
final GLAnimatorControl aAnim = a.getAnimator();
if( null != aAnim ) {
aAnim.remove(a); // also handles ECT
}
- final GLEventListenerState glls = new GLEventListenerState(aScreen2, caps1, a.getContext(), aSz, aAnim);
+ final GLEventListenerState glls = new GLEventListenerState(aUpScreen2, aScreen2, caps, a.getContext(), aSz, aAnim);
//
// remove and cache all GLEventListener and their init-state
@@ -167,7 +206,6 @@ public class GLEventListenerState {
a.invoke(true, glFinish);
a.setContext( null );
- aDevice1.clearHandleOwner(); // don't close handle
return glls;
}
@@ -195,19 +233,71 @@ public class GLEventListenerState {
final List<GLRunnable> aGLCmds = new ArrayList<GLRunnable>();
final int aSz = listenerCount();
- final MutableGraphicsConfiguration aCfg = (MutableGraphicsConfiguration) a.getNativeSurface().getGraphicsConfiguration();
+ final NativeSurface aSurface = a.getNativeSurface();
+ final MutableGraphicsConfiguration aCfg = (MutableGraphicsConfiguration) aSurface.getGraphicsConfiguration();
final GLCapabilitiesImmutable aCaps = (GLCapabilitiesImmutable) aCfg.getChosenCapabilities();
- if( caps.getVisualID(VisualIDHolder.VIDType.INTRINSIC) != aCaps.getVisualID(VisualIDHolder.VIDType.INTRINSIC) ) {
- throw new GLException("XXX: Incompatible - Prev Holder: "+caps+", New Holder "+caps);
+ if( caps.getVisualID(VisualIDHolder.VIDType.INTRINSIC) != aCaps.getVisualID(VisualIDHolder.VIDType.INTRINSIC) ||
+ caps.getVisualID(VisualIDHolder.VIDType.NATIVE) != aCaps.getVisualID(VisualIDHolder.VIDType.NATIVE) ) {
+ throw new GLException("Incompatible Capabilities - Prev-Holder: "+caps+", New-Holder "+caps);
}
- final GLContext prevContext = a.getContext();
- if( null != prevContext) {
- prevContext.destroy();
+ // Destroy and remove currently associated GLContext, if any (will be replaced)
+ {
+ final GLContext ctx = a.getContext();
+ if( null != ctx) {
+ ctx.destroy();
+ }
+ a.setContext( null );
+ }
+ final boolean aRealized = a.isRealized();
+ if( aRealized ) {
+ a.setRealized(false);
+ }
+ // Set new Screen and close previous one
+ {
+ if( DEBUG ) {
+ System.err.println("XX0 NativeSurface: "+aSurface.getClass().getName()+", "+aSurface);
+ }
+ final AbstractGraphicsScreen aScreen1 = aCfg.getScreen();
+ aCfg.setScreen( screen );
+ aScreen1.getDevice().close();
+ System.err.println("XXX NativeSurface: "+aSurface.getClass().getName()+", "+aSurface);
+ }
+ // If using a ProxySurface w/ an upstream surface, set new Screen and close previous one on it
+ {
+ boolean upstreamSet = false;
+ if(aSurface instanceof ProxySurface) {
+ final ProxySurface aProxy = (ProxySurface)aSurface;
+ final NativeSurface aUpSurface = aProxy.getUpstreamSurface();
+ if(null != aUpSurface) {
+ final MutableGraphicsConfiguration aUpCfg = (MutableGraphicsConfiguration) aUpSurface.getGraphicsConfiguration();
+ final AbstractGraphicsScreen aUpScreen1 = aUpCfg.getScreen();
+ if( null != upstreamScreen ) {
+ System.err.println("XX0 UpstreamSurface: "+aUpSurface.getClass().getName()+", "+aUpSurface);
+ aUpCfg.setScreen( upstreamScreen );
+ aUpScreen1.getDevice().close();
+ upstreamSet = true;
+ System.err.println("XXX UpstreamSurface: "+aUpSurface.getClass().getName()+", "+aUpSurface);
+ } else {
+ throw new GLException("Incompatible Surface config - Has Upstream-Surface: Prev-Holder = false, New-Holder = true");
+ }
+ }
+ }
+ if( !upstreamSet && null != upstreamScreen ) {
+ throw new GLException("Incompatible Surface config - Has Upstream-Surface: Prev-Holder = true, New-Holder = false");
+ }
+ }
+
+ if( aRealized ) {
+ a.setRealized(true);
+ }
+ final boolean surfaceLocked = false; // NativeSurface.LOCK_SURFACE_NOT_READY < aSurface.lockSurface();
+ try {
+ a.setContext( context );
+ } finally {
+ if( surfaceLocked ) {
+ aSurface.unlockSurface();
+ }
}
- final AbstractGraphicsScreen preScreen = aCfg.getScreen();
- aCfg.setScreen( screen );
- preScreen.getDevice().close();
- a.setContext( context );
owner = false;
//
@@ -220,15 +310,13 @@ public class GLEventListenerState {
}
}
aGLCmds.add(glFinish);
- a.invoke(true, aGLCmds);
+ a.invoke(aRealized, aGLCmds); // only wait if already realized
// add all cached GLEventListener to their destination and fix their init-state
for(int i=0; i<aSz; i++) {
final GLEventListener l = listeners[i];
a.addGLEventListener( l );
- if( listenersInit[i] ) {
- a.setGLEventListenerInitState(l, true);
- } // else uninitialized is default after add
+ a.setGLEventListenerInitState(l, listenersInit[i]);
listeners[i] = null;
}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java
index a2af83359..2b49f6745 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java
@@ -400,7 +400,7 @@ public class SWTAccessor {
* @return
*/
public static AbstractGraphicsScreen getScreen(AbstractGraphicsDevice device, int screen) {
- return NativeWindowFactory.createScreen(nwt, device, screen);
+ return NativeWindowFactory.createScreen(device, screen);
}
public static int getNativeVisualID(AbstractGraphicsDevice device, long windowHandle) {
diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java b/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java
index 27462ae70..a89caec76 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java
@@ -56,7 +56,7 @@ public interface NativeSurface extends SurfaceUpdatedListener {
* ie return a value other than {@link #LOCK_SURFACE_UNLOCKED} and {@link #LOCK_SURFACE_NOT_READY},
* which is
* <pre>
- * boolean ok = lockSurface() > LOCK_SURFACE_NOT_READY;
+ * boolean ok = LOCK_SURFACE_NOT_READY < lockSurface();
* </pre>
* </p>
* <p>
diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java
index 07702c762..b6a052253 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java
@@ -435,9 +435,10 @@ public abstract class NativeWindowFactory {
/**
* @param device
* @param screen -1 is default screen of the given device, e.g. maybe 0 or determined by native API. >= 0 is specific screen
- * @return newly created AbstractGraphicsScreen of given native type
+ * @return newly created AbstractGraphicsScreen matching device's native type
*/
- public static AbstractGraphicsScreen createScreen(String type, AbstractGraphicsDevice device, int screen) {
+ public static AbstractGraphicsScreen createScreen(AbstractGraphicsDevice device, int screen) {
+ final String type = device.getType();
if( TYPE_X11 == type ) {
final X11GraphicsDevice x11Device = (X11GraphicsDevice)device;
if(0 > screen) {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitch01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitch01NEWT.java
index 08a0857a9..8b1449493 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitch01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitch01NEWT.java
@@ -64,14 +64,18 @@ import org.junit.Test;
* i.e. ctx1/draw1, ctx2/draw2 -> ctx1/draw2, ctx2/draw1.
*/
public class TestGLContextDrawableSwitch01NEWT extends UITestCase {
- static GLProfile glp;
- static GLCapabilities caps;
static int width, height;
+ static GLCapabilities getCaps(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() {
- glp = GLProfile.getGL2ES2();
- caps = new GLCapabilities(glp);
width = 256;
height = 256;
}
@@ -124,7 +128,20 @@ public class TestGLContextDrawableSwitch01NEWT extends UITestCase {
}
@Test(timeout=30000)
- public void testSwitch2WindowSingleContext() throws InterruptedException {
+ public void testSwitch2WindowSingleContextGL2ES2() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2);
+ if(null == reqGLCaps) return;
+ testSwitch2WindowSingleContextImpl(reqGLCaps);
+ }
+
+ @Test(timeout=30000)
+ public void testSwitch2WindowSingleContextGLES2() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
+ if(null == reqGLCaps) return;
+ testSwitch2WindowSingleContextImpl(reqGLCaps);
+ }
+
+ private void testSwitch2WindowSingleContextImpl(GLCapabilities caps) throws InterruptedException {
final QuitAdapter quitAdapter = new QuitAdapter();
GLAutoDrawable glad1 = createGLAutoDrawable(caps, 64, 64, width, height, quitAdapter);
@@ -178,7 +195,20 @@ public class TestGLContextDrawableSwitch01NEWT extends UITestCase {
}
@Test(timeout=30000)
- public void testSwitch2GLWindowOneDemo() throws InterruptedException {
+ public void testSwitch2GLWindowOneDemoGL2ES2() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2);
+ if(null == reqGLCaps) return;
+ testSwitch2GLWindowOneDemoImpl(reqGLCaps);
+ }
+
+ @Test(timeout=30000)
+ public void testSwitch2GLWindowOneDemoGLES2() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
+ if(null == reqGLCaps) return;
+ testSwitch2GLWindowOneDemoImpl(reqGLCaps);
+ }
+
+ private void testSwitch2GLWindowOneDemoImpl(GLCapabilities caps) throws InterruptedException {
final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener();
final GearsES2 gears = new GearsES2(1);
final QuitAdapter quitAdapter = new QuitAdapter();
@@ -238,7 +268,20 @@ public class TestGLContextDrawableSwitch01NEWT extends UITestCase {
}
@Test(timeout=30000)
- public void testSwitch2GLWindowEachWithOwnDemo() throws InterruptedException {
+ public void testSwitch2GLWindowEachWithOwnDemoGL2ES2() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2);
+ if(null == reqGLCaps) return;
+ testSwitch2GLWindowEachWithOwnDemoImpl(reqGLCaps);
+ }
+
+ @Test(timeout=30000)
+ public void testSwitch2GLWindowEachWithOwnDemoGLES2() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
+ if(null == reqGLCaps) return;
+ testSwitch2GLWindowEachWithOwnDemoImpl(reqGLCaps);
+ }
+
+ public void testSwitch2GLWindowEachWithOwnDemoImpl(GLCapabilities caps) throws InterruptedException {
final GearsES2 gears = new GearsES2(1);
final RedSquareES2 rsquare = new RedSquareES2(1);
final QuitAdapter quitAdapter = new QuitAdapter();
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitch11NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitch11NEWT.java
index cd308e165..4af9a3932 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitch11NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitch11NEWT.java
@@ -69,19 +69,23 @@ import org.junit.Test;
* </p>
*/
public class TestGLContextDrawableSwitch11NEWT extends UITestCase {
- static GLProfile glp;
- static GLCapabilities caps;
static int width, height;
+ static GLCapabilities getCaps(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() {
- glp = GLProfile.getGL2ES2();
- caps = new GLCapabilities(glp);
width = 256;
height = 256;
}
- private GLAutoDrawable createGLAutoDrawable(GLCapabilities caps, int x, int y, int width, int height, WindowListener wl) throws InterruptedException {
+ private GLAutoDrawable createGLAutoDrawableWithoutContext(GLCapabilities caps, int x, int y, int width, int height, WindowListener wl) throws InterruptedException {
final Window window = NewtFactory.createWindow(caps);
Assert.assertNotNull(window);
window.setPosition(x, y);
@@ -126,7 +130,20 @@ public class TestGLContextDrawableSwitch11NEWT extends UITestCase {
}
@Test(timeout=30000)
- public void test01() throws InterruptedException {
+ public void test01GLADDelegateGL2ES2() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2);
+ if(null == reqGLCaps) return;
+ test01GLADDelegateImpl(reqGLCaps);
+ }
+
+ @Test(timeout=30000)
+ public void test01GLADDelegateGLES2() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
+ if(null == reqGLCaps) return;
+ test01GLADDelegateImpl(reqGLCaps);
+ }
+
+ private void test01GLADDelegateImpl(GLCapabilities caps) throws InterruptedException {
final QuitAdapter quitAdapter = new QuitAdapter();
final GLEventListenerCounter glelCounter = new GLEventListenerCounter();
@@ -140,7 +157,7 @@ public class TestGLContextDrawableSwitch11NEWT extends UITestCase {
// - create glad1 w/o context
// - create context using glad1 and assign it to glad1
{
- final GLAutoDrawable glad1 = createGLAutoDrawable(caps, 64, 64, width, height, quitAdapter);
+ final GLAutoDrawable glad1 = createGLAutoDrawableWithoutContext(caps, 64, 64, width, height, quitAdapter);
final GLContext context1 = glad1.createContext(null);
glad1.setContext(context1);
animator.add(glad1);
@@ -149,7 +166,7 @@ public class TestGLContextDrawableSwitch11NEWT extends UITestCase {
glad1.addGLEventListener(new GearsES2(1));
glad1.addGLEventListener(snapshotGLEventListener);
snapshotGLEventListener.setMakeSnapshot();
-
+
long t1 = System.currentTimeMillis();
while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration/2 ) {
@@ -157,8 +174,6 @@ public class TestGLContextDrawableSwitch11NEWT extends UITestCase {
t1 = System.currentTimeMillis();
}
- // - dis-associate context from glad1
- // - destroy glad1
Assert.assertEquals(1, glelCounter.initCount);
Assert.assertTrue(1 <= glelCounter.reshapeCount);
Assert.assertTrue(1 <= glelCounter.displayCount);
@@ -168,6 +183,8 @@ public class TestGLContextDrawableSwitch11NEWT extends UITestCase {
Assert.assertEquals(context1.getGLReadDrawable(), glad1.getDelegatedDrawable());
Assert.assertEquals(context1.getGLDrawable(), glad1.getDelegatedDrawable());
+ // - dis-associate context from glad1
+ // - destroy glad1
glls1 = GLEventListenerState.moveFrom(glad1);
Assert.assertEquals(1, glelCounter.initCount);
@@ -191,7 +208,7 @@ public class TestGLContextDrawableSwitch11NEWT extends UITestCase {
// - create glad2 w/ survived context
{
- final GLAutoDrawable glad2 = createGLAutoDrawable(caps, 2*64+width, 64, width+100, height+100, quitAdapter);
+ final GLAutoDrawable glad2 = createGLAutoDrawableWithoutContext(caps, 2*64+width, 64, width+100, height+100, quitAdapter);
snapshotGLEventListener.setMakeSnapshot();
Assert.assertEquals(null, glad2.getContext());
@@ -199,6 +216,8 @@ public class TestGLContextDrawableSwitch11NEWT extends UITestCase {
glls1.moveTo(glad2);
+ Assert.assertTrue(glad2.isRealized());
+
Assert.assertEquals(1, glelCounter.initCount);
Assert.assertTrue(1 <= glelCounter.reshapeCount);
Assert.assertTrue(1 <= glelCounter.displayCount);
@@ -226,7 +245,20 @@ public class TestGLContextDrawableSwitch11NEWT extends UITestCase {
}
@Test(timeout=30000)
- public void test02() throws InterruptedException {
+ public void test02GLWindowGL2ES2() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2);
+ if(null == reqGLCaps) return;
+ test02GLWindowImpl(reqGLCaps);
+ }
+
+ @Test(timeout=30000)
+ public void test02GLWindowGLES2() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
+ if(null == reqGLCaps) return;
+ test02GLWindowImpl(reqGLCaps);
+ }
+
+ private void test02GLWindowImpl(GLCapabilities caps) throws InterruptedException {
final QuitAdapter quitAdapter = new QuitAdapter();
final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener();
@@ -244,7 +276,6 @@ public class TestGLContextDrawableSwitch11NEWT extends UITestCase {
glad1.setSize(width, height);
glad1.setPosition(64, 64);
glad1.addWindowListener(quitAdapter);
- glad1.setVisible(true);
animator.add(glad1);
glad1.addGLEventListener(glelTracker);
@@ -252,6 +283,8 @@ public class TestGLContextDrawableSwitch11NEWT extends UITestCase {
glad1.addGLEventListener(snapshotGLEventListener);
snapshotGLEventListener.setMakeSnapshot();
+ glad1.setVisible(true);
+
long t1 = System.currentTimeMillis();
while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration/2 ) {
@@ -297,13 +330,13 @@ public class TestGLContextDrawableSwitch11NEWT extends UITestCase {
glad2.setSize(width+100, height+100);
glad2.setPosition(2*64+width, 64);
glad2.addWindowListener(quitAdapter);
- glad2.setVisible(true);
snapshotGLEventListener.setMakeSnapshot();
+ glad2.setVisible(true);
Assert.assertNotNull(glad2.getContext());
Assert.assertEquals(0, glad2.getGLEventListenerCount());
- glls1.moveTo(glad2);
+ glls1.moveTo(glad2);
Assert.assertEquals(1, glelTracker.initCount);
Assert.assertTrue(1 <= glelTracker.reshapeCount);