aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/com/jogamp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-10-27 17:51:08 +0100
committerSven Gothel <[email protected]>2013-10-27 17:51:08 +0100
commit7f7a23dd0ddf106e6f0c69fc2a05ff92ac56200e (patch)
tree562e5835aecbdd5994d1e85657b3b948f23ff785 /src/test/com/jogamp
parentff3832bf24f02fc44a7494be49d210cacce43977 (diff)
Bug 776 GLContext Sharing: Refine API for relaxed and lazy GLContext sharing ; Fix GLContext memory contract (volatile)
(Unit test remarks see below) - Add shared GLContext queries - Refined GLContextShareSet: - Use IdentityHashMap since GLContext's can only be identical w/ same reference (footprint, performance) - Add API doc for clarification - Add methods: - ArrayList<GLContext> getCreatedShares(final GLContext context) - ArrayList<GLContext> getDestroyedShares(final GLContext context) - Use 'final' where possible - Add GLContext methods: - boolean isShared() - List<GLContext> getCreatedShares() - List<GLContext> getDestroyedShares() - Add GLSharedContextSetter interface defining setting a shared GLContext directly (GLContext) or via a GLAutoDrawable: - setSharedContext(GLContext) - setSharedAutoDrawable(GLAutoDrawable) Both cause initialization/creation of GLAutoDrawable's drawable/context to be postponed, if the shared GLContext is not yet created natively or the shared GLAutoDrawable's GLContext does not yet exist. Most of impl. resides in GLDrawableHelper Implemented in: - GLAutoDrawableBase, GLOffscreenAutoDrawable - GLWindow - AWT GLCanvas TODO: - GLJPanel - SWT GLCanvas - GLDrawableFactory: - Add 'GLOffscreenAutoDrawable createOffscreenAutoDrawable(..)' variant w/o passing the optional shared GLContext _and_ specifying lazy GLContext creation. This allows to benefit from GLSharedContextSetter contract. Lazy GLContext creation is performed at 2st display() call at the latest. All JOGL code and unit tests use this new method now. - Mark 'createOffscreenAutoDrawable(..)' w/ shared GLContext argument and immediate GLContext creation deprecated - shall be removed in 2.2.0 - Make reference to GLContext and it's native handle volatile Since we rely on the query 'GLContext.isCreated()' to properly allow GLAutoDrawable's to query whether a shared GLContext is natively created (already), the handle must be volatile since such query and the actual creation may operate on different threads. +++++ - Add/Refine shared GLContext unit tests demonstrating diff. sharing methods. All variants of using shared GLContext: com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBO* Most convenient way to share via setSharedAutoDrawable(GLAutoDrawable): com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2[NEWT|AWT]3 AWT use w/ JTabbedPane using setSharedAutoDrawable(GLAutoDrawable): com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextWithJTabbedPaneAWT
Diffstat (limited to 'src/test/com/jogamp')
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableDeadlockAWT.java28
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableFactoryNEWT.java130
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java100
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOnThreadSharedContext1DemoES2NEWT.java89
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateNEWT.java46
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryES2OffscrnCapsNEWT.java106
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT.java118
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGLnBitmapCapsNEWT.java66
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLExtensionQueryOffscreen.java22
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java24
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java43
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT.java20
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextNewtAWTBug523.java94
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES1NEWT.java75
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java321
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT0.java270
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT1.java (renamed from src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT.java)124
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java315
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT3.java296
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextWithJTabbedPaneAWT.java264
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/GLContextDrawableSwitchBase.java96
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch02AWT.java52
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461FBOSupersamplingSwingAWT.java46
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageAWT.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageNEWT.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java18
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java85
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java114
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/glu/TestBug365TextureGenerateMipMaps.java108
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering2GL2NEWT.java26
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2NEWT.java36
-rw-r--r--src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java230
-rw-r--r--src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java73
33 files changed, 2547 insertions, 892 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableDeadlockAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableDeadlockAWT.java
index 2df14d151..1548c08b5 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableDeadlockAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableDeadlockAWT.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,7 +20,7 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
@@ -61,12 +61,8 @@ public class TestFBOAutoDrawableDeadlockAWT extends UITestCase {
}
protected void runTestGL( GLCapabilities caps ) throws InterruptedException, InvocationTargetException {
- final GLOffscreenAutoDrawable fbod = GLDrawableFactory.getFactory(caps.getGLProfile()).createOffscreenAutoDrawable(
- null,
- caps, new DefaultGLCapabilitiesChooser(),
- 512, 512,
- null
- );
+ final GLOffscreenAutoDrawable fbod = GLDrawableFactory.getFactory(caps.getGLProfile()).createOffscreenAutoDrawable(
+ null, caps, new DefaultGLCapabilitiesChooser(), 512, 512);
final boolean[] done = {false};
final Runnable pbufferCreationAction = new Runnable() {
@@ -77,30 +73,30 @@ public class TestFBOAutoDrawableDeadlockAWT extends UITestCase {
System.err.println("AA.X");
}
};
-
+
EventQueue.invokeAndWait(new Runnable() {
public void run() {
Assert.assertTrue(EventQueue.isDispatchThread());
JAWTUtil.lockToolkit();
try {
- final RunnableTask rTask = new RunnableTask(pbufferCreationAction, new Object(), false, null);
+ final RunnableTask rTask = new RunnableTask(pbufferCreationAction, new Object(), false, null);
System.err.println("BB.0: "+rTask.getSyncObject());
synchronized (rTask.getSyncObject()) {
System.err.println("BB.1: "+rTask.getSyncObject());
- new Thread(rTask, Thread.currentThread().getName()+"-Pbuffer_Creation").start();
+ new Thread(rTask, Thread.currentThread().getName()+"-Pbuffer_Creation").start();
try {
System.err.println("BB.2");
rTask.getSyncObject().wait();
System.err.println("BB.3");
} catch (InterruptedException e) {
throw new RuntimeException(e);
- }
+ }
System.err.println("BB.X");
}
} finally {
JAWTUtil.unlockToolkit();
}
- }
+ }
});
Assert.assertTrue(done[0]);
fbod.destroy();
@@ -128,4 +124,4 @@ public class TestFBOAutoDrawableDeadlockAWT extends UITestCase {
}
org.junit.runner.JUnitCore.main( TestFBOAutoDrawableDeadlockAWT.class.getName() );
}
-}
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableFactoryNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableFactoryNEWT.java
index 9151a88a5..cc06136d6 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableFactoryNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableFactoryNEWT.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,12 +20,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.opengl.test.junit.jogl.acore;
import java.io.IOException;
@@ -52,53 +52,53 @@ import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
import com.jogamp.opengl.test.junit.util.UITestCase;
/**
- * Toolkit agnostic {@link GLOffscreenAutoDrawable.FBO} tests using the
- * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}.
+ * Toolkit agnostic {@link GLOffscreenAutoDrawable.FBO} tests using the
+ * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}.
* <p>
- * The created {@link GLOffscreenAutoDrawable.FBO} is being used to run the {@link GLEventListener}.
+ * The created {@link GLOffscreenAutoDrawable.FBO} is being used to run the {@link GLEventListener}.
* </p>
* <p>
* Extensive FBO reconfiguration (size and sample buffer count) and validation are performed.
- * </p>
+ * </p>
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestFBOAutoDrawableFactoryNEWT extends UITestCase {
-
+
static final int widthStep = 800/4;
static final int heightStep = 600/4;
volatile int szStep = 2;
-
+
interface MyGLEventListener extends GLEventListener {
void setMakeSnapshot();
}
-
+
@Test
- public void testGL2ES2_Demo1_SingleBuffer_Normal() throws InterruptedException {
+ public void testGL2ES2_Demo1_SingleBuffer_Normal() throws InterruptedException {
final GLProfile glp = GLProfile.getGL2ES2();
final GLCapabilities caps = new GLCapabilities(glp);
caps.setDoubleBuffered(false);
testGLFBODrawableImpl(caps, new GearsES2(0));
}
-
+
@Test
- public void testGL2ES2_Demo1_DoubleBuffer_Normal() throws InterruptedException {
+ public void testGL2ES2_Demo1_DoubleBuffer_Normal() throws InterruptedException {
final GLProfile glp = GLProfile.getGL2ES2();
final GLCapabilities caps = new GLCapabilities(glp);
caps.setDoubleBuffered(true); // default
testGLFBODrawableImpl(caps, new GearsES2(0));
}
-
+
@Test
- public void testGL2ES2_Demo2MSAA4() throws InterruptedException {
+ public void testGL2ES2_Demo2MSAA4() throws InterruptedException {
final GLProfile glp = GLProfile.getGL2ES2();
final GLCapabilities caps = new GLCapabilities(glp);
caps.setSampleBuffers(true);
caps.setNumSamples(4);
testGLFBODrawableImpl(caps, new MultisampleDemoES2(true));
}
-
+
@Test
- public void testGL2ES2_FBODemoMSAA4() throws InterruptedException {
+ public void testGL2ES2_FBODemoMSAA4() throws InterruptedException {
final GLProfile glp = GLProfile.getGL2ES2();
final FBOMix2DemosES2 demo = new FBOMix2DemosES2(0);
demo.setDoRotation(false);
@@ -107,9 +107,9 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase {
caps.setNumSamples(4);
testGLFBODrawableImpl(caps, demo);
}
-
+
@Test
- public void testEGLES2_Demo0Normal() throws InterruptedException {
+ public void testEGLES2_Demo0Normal() throws InterruptedException {
if( GLProfile.isAvailable(GLProfile.GLES2) ) {
final GLProfile glp = GLProfile.get(GLProfile.GLES2);
final GLCapabilities caps = new GLCapabilities(glp);
@@ -118,9 +118,9 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase {
System.err.println("EGL ES2 n/a");
}
}
-
+
@Test
- public void testEGLES2_Demo0MSAA4() throws InterruptedException {
+ public void testEGLES2_Demo0MSAA4() throws InterruptedException {
if( GLProfile.isAvailable(GLProfile.GLES2) ) {
final GLProfile glp = GLProfile.get(GLProfile.GLES2);
final GLCapabilities caps = new GLCapabilities(glp);
@@ -136,71 +136,71 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase {
caps.setFBO(true);
final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile());
final GLOffscreenAutoDrawable.FBO glad = (GLOffscreenAutoDrawable.FBO)
- factory.createOffscreenAutoDrawable(null, caps, null, widthStep*szStep, heightStep*szStep, null);
+ factory.createOffscreenAutoDrawable(null, caps, null, widthStep*szStep, heightStep*szStep);
Assert.assertNotNull(glad);
-
+
System.out.println("Realized GLAD: "+glad);
System.out.println("Realized GLAD: "+glad.getChosenGLCapabilities());
Assert.assertTrue("FBO drawable is initialized before ctx creation", !glad.isInitialized());
-
+
glad.display(); // initial display incl. init!
{
final GLContext context = glad.getContext();
Assert.assertNotNull(context);
Assert.assertTrue(context.isCreated());
}
- Assert.assertTrue("FBO drawable is not initialized after ctx creation", glad.isInitialized());
-
+ Assert.assertTrue("FBO drawable is not initialized after ctx creation", glad.isInitialized());
+
//
// FBO incl. MSAA is fully initialized now
//
-
+
final GLCapabilitiesImmutable chosenCaps = glad.getChosenGLCapabilities();
System.out.println("Init GLAD: "+glad);
System.out.println("Init GLAD: "+chosenCaps);
-
+
final FBObject fboFront = glad.getFBObject(GL.GL_FRONT);
final FBObject fboBack = glad.getFBObject(GL.GL_BACK);
-
+
System.out.println("Init front FBO: "+fboFront);
System.out.println("Init back FBO: "+fboBack);
-
+
Assert.assertTrue("FBO drawable is not initialized before ctx creation", glad.isInitialized());
Assert.assertTrue("FBO Front is not initialized before ctx creation", fboFront.isInitialized());
Assert.assertTrue("FBO Back is not initialized before ctx creation", fboBack.isInitialized());
-
+
if( chosenCaps.getDoubleBuffered() ) {
Assert.assertTrue("FBO are equal: "+fboFront+" == "+fboBack, !fboFront.equals(fboBack));
Assert.assertNotSame(fboFront, fboBack);
} else {
Assert.assertTrue("FBO are not equal: "+fboFront+" != "+fboBack, fboFront.equals(fboBack));
- Assert.assertSame(fboFront, fboBack);
+ Assert.assertSame(fboFront, fboBack);
}
-
+
final FBObject.TextureAttachment texAttachA, texAttachB;
-
+
texAttachA = glad.getTextureBuffer(GL.GL_FRONT);
if(0==glad.getNumSamples()) {
texAttachB = glad.getTextureBuffer(GL.GL_BACK);
} else {
texAttachB = null;
}
-
+
final FBObject.Colorbuffer colorA, colorB;
final FBObject.RenderAttachment depthA, depthB;
-
+
colorA = fboFront.getColorbuffer(0);
Assert.assertNotNull(colorA);
colorB = fboBack.getColorbuffer(0);
Assert.assertNotNull(colorB);
-
+
depthA = fboFront.getDepthAttachment();
Assert.assertNotNull(depthA);
depthB = fboBack.getDepthAttachment();
Assert.assertNotNull(depthB);
glad.display(); // SWAP_ODD
-
+
if( chosenCaps.getDoubleBuffered() ) {
// double buffer or MSAA
Assert.assertTrue("Color attachments are equal: "+colorB+" == "+colorA, !colorB.equals(colorA));
@@ -214,16 +214,16 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase {
Assert.assertEquals(depthA, depthB);
Assert.assertSame(depthA, depthB);
}
-
+
Assert.assertEquals(texAttachA, colorA);
Assert.assertSame(texAttachA, colorA);
if(0==glad.getNumSamples()) {
Assert.assertEquals(texAttachB, colorB);
- Assert.assertSame(texAttachB, colorB);
+ Assert.assertSame(texAttachB, colorB);
}
if( chosenCaps.getNumSamples() > 0 ) {
- // MSAA
+ // MSAA
FBObject _fboFront = glad.getFBObject(GL.GL_FRONT);
FBObject _fboBack = glad.getFBObject(GL.GL_BACK);
Assert.assertTrue("FBO are not equal: "+fboFront+" != "+_fboFront, fboFront.equals(_fboFront));
@@ -251,22 +251,22 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase {
Assert.assertTrue("FBO are not equal: "+fboFront+" != "+_fboBack, fboFront.equals(_fboBack));
Assert.assertSame(fboFront, _fboBack);
}
-
+
glad.addGLEventListener(demo);
-
+
final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener();
glad.addGLEventListener(snapshotGLEventListener);
-
+
glad.display(); // - SWAP_EVEN
// 1 - szStep = 2
snapshotGLEventListener.setMakeSnapshot();
glad.display(); // - SWAP_ODD
-
+
// 2, 3 (resize + display)
szStep = 1;
glad.setSize(widthStep*szStep, heightStep*szStep); // SWAP_EVEN
- Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
+ Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep));
snapshotGLEventListener.setMakeSnapshot();
glad.display(); // - SWAP_ODD
@@ -283,34 +283,34 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase {
Assert.assertSame(fboFront, _fboFront);
Assert.assertEquals(fboBack, _fboBack);
Assert.assertSame(fboBack, _fboBack);
-
+
FBObject.Colorbuffer _color = _fboFront.getColorbuffer(0);
Assert.assertNotNull(_color);
Assert.assertEquals(colorA, _color);
Assert.assertSame(colorA, _color);
-
+
FBObject.RenderAttachment _depth = _fboFront.getDepthAttachment();
System.err.println("Resize1.oldDepth "+depthA);
System.err.println("Resize1.newDepth "+_depth);
Assert.assertNotNull(_depth);
-
+
Assert.assertEquals(depthA, _depth);
Assert.assertSame(depthA, _depth);
_depth = _fboBack.getDepthAttachment();
Assert.assertNotNull(_depth);
Assert.assertEquals(depthB, _depth);
Assert.assertSame(depthB, _depth);
-
+
_color = _fboFront.getColorbuffer(colorA);
Assert.assertNotNull(_color);
Assert.assertEquals(colorA, _color);
Assert.assertSame(colorA, _color);
}
-
+
// 4, 5 (resize + display)
szStep = 4;
glad.setSize(widthStep*szStep, heightStep*szStep); // SWAP_ODD
- Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
+ Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep));
snapshotGLEventListener.setMakeSnapshot();
glad.display(); // - SWAP_EVEN
@@ -330,47 +330,47 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase {
} else {
// single or MSAA
Assert.assertEquals(fboFront, _fboFront);
- Assert.assertEquals(fboBack, _fboBack);
+ Assert.assertEquals(fboBack, _fboBack);
}
-
+
FBObject.Colorbuffer _color = fboBack.getColorbuffer(0);
Assert.assertNotNull(_color);
Assert.assertEquals(colorB, _color);
Assert.assertSame(colorB, _color);
-
+
FBObject.RenderAttachment _depth = fboBack.getDepthAttachment();
- Assert.assertNotNull(_depth); // MSAA back w/ depth
+ Assert.assertNotNull(_depth); // MSAA back w/ depth
Assert.assertEquals(depthB, _depth);
Assert.assertSame(depthB, _depth);
-
+
_depth = fboFront.getDepthAttachment();
Assert.assertNotNull(_depth);
Assert.assertEquals(depthA, _depth);
Assert.assertSame(depthA, _depth);
-
+
_color = fboBack.getColorbuffer(colorB);
Assert.assertNotNull(_color);
Assert.assertEquals(colorB, _color);
Assert.assertSame(colorB, _color);
}
-
+
// 6 + 7 (samples + display)
glad.setNumSamples(glad.getGL(), chosenCaps.getNumSamples() > 0 ? 0 : 4); // triggers repaint
snapshotGLEventListener.setMakeSnapshot();
glad.display(); // actual screenshot
-
+
// 8, 9 (resize + samples + display)
szStep = 3;
glad.setSize(widthStep*szStep, heightStep*szStep);
- Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
+ Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep));
snapshotGLEventListener.setMakeSnapshot();
glad.display();
-
+
glad.destroy();
System.out.println("Fin: "+glad);
}
-
+
public static void main(String args[]) throws IOException {
org.junit.runner.JUnitCore.main(TestFBOAutoDrawableFactoryNEWT.class.getName());
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java
index b3e5e95b0..51dd9df37 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,12 +20,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.opengl.test.junit.jogl.acore;
import java.io.BufferedReader;
@@ -68,10 +68,10 @@ import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
/**
- * Toolkit agnostic {@link GLOffscreenAutoDrawable.FBO} tests using the
- * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}.
+ * Toolkit agnostic {@link GLOffscreenAutoDrawable.FBO} tests using the
+ * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}.
* <p>
- * The created {@link GLOffscreenAutoDrawable.FBO} is being used to run the {@link GLEventListener}.
+ * The created {@link GLOffscreenAutoDrawable.FBO} is being used to run the {@link GLEventListener}.
* </p>
* <p>
* This test simulates shared off-thread GL context / texture usage,
@@ -81,7 +81,7 @@ import org.junit.runners.MethodSorters;
* <ul>
* <li>2 {@link GLOffscreenAutoDrawable.FBO} double buffered
* <ul>
- * <li>each with their own {@link GLContext}, which is shares the {@link GLWindow} one (see below)</li>
+ * <li>each with their own {@link GLContext}, which is shares the {@link GLWindow} one (see below)</li>
* <li>both run within one {@link FPSAnimator} @ 30fps</li>
* <li>produce a texture</li>
* <li>notify the onscreen renderer about new textureID (swapping double buffer)</li>
@@ -91,18 +91,18 @@ import org.junit.runners.MethodSorters;
* <li>shares it's {@link GLContext} w/ above FBOs</li>
* <li>running within one {@link Animator} at v-sync</li>
* <li>uses the shared FBO textures and blends them onscreen</li>
- * </ul></li>
- * </ul>
- * </p>
+ * </ul></li>
+ * </ul>
+ * </p>
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestFBOOffThreadSharedContextMix2DemosES2NEWT extends UITestCase {
+public class TestFBOOffThreadSharedContextMix2DemosES2NEWT extends UITestCase {
static long duration = 500; // ms
static int swapInterval = 1;
static boolean showFPS = false;
static boolean forceES2 = false;
static boolean mainRun = false;
-
+
@AfterClass
public static void releaseClass() {
}
@@ -110,37 +110,38 @@ public class TestFBOOffThreadSharedContextMix2DemosES2NEWT extends UITestCase {
protected void runTestGL(GLCapabilitiesImmutable caps) throws InterruptedException {
final GLReadBufferUtil screenshot = new GLReadBufferUtil(false, false);
System.err.println("requested: vsync "+swapInterval+", "+caps);
-
+
final GLWindow glWindow = GLWindow.create(caps);
Assert.assertNotNull(glWindow);
glWindow.setTitle("Gears NEWT Test (translucent "+!caps.isBackgroundOpaque()+"), swapInterval "+swapInterval);
if(mainRun) {
- glWindow.setSize(512, 512);
+ glWindow.setSize(512, 512);
} else {
glWindow.setSize(256, 256);
}
// eager initialization of context
glWindow.setVisible(true);
- glWindow.display();
+ glWindow.display();
final int fbod1_texUnit = 0;
final int fbod2_texUnit = 1;
-
+
final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile());
GLCapabilities fbodCaps = (GLCapabilities) caps.cloneMutable();
// fbodCaps.setDoubleBuffered(false);
-
+
final Mix2TexturesES2 mixerDemo = new Mix2TexturesES2(1, fbod1_texUnit, fbod2_texUnit);
- // FBOD1
+ // FBOD1
final GLOffscreenAutoDrawable.FBO fbod1 = (GLOffscreenAutoDrawable.FBO)
- factory.createOffscreenAutoDrawable(null, fbodCaps, null, glWindow.getWidth(), glWindow.getHeight(), glWindow.getContext());
+ factory.createOffscreenAutoDrawable(null, fbodCaps, null, glWindow.getWidth(), glWindow.getHeight());
+ fbod1.setSharedAutoDrawable(glWindow);
fbod1.setUpstreamWidget(glWindow); // connect the real GLWindow (mouse/key) to offscreen!
fbod1.setTextureUnit(fbod1_texUnit);
{
GearsES2 demo0 = new GearsES2(-1);
fbod1.addGLEventListener(demo0);
- fbod1.addGLEventListener(new GLFinishOnDisplay());
+ fbod1.addGLEventListener(new GLFinishOnDisplay());
demo0.setIgnoreFocus(true);
}
fbod1.getNativeSurface().addSurfaceUpdatedListener(new SurfaceUpdatedListener() {
@@ -151,13 +152,14 @@ public class TestFBOOffThreadSharedContextMix2DemosES2NEWT extends UITestCase {
fbod1.display(); // init
System.err.println("FBOD1 "+fbod1);
Assert.assertTrue(fbod1.isInitialized());
-
+
// FBOD2
final GLOffscreenAutoDrawable.FBO fbod2 = (GLOffscreenAutoDrawable.FBO)
- factory.createOffscreenAutoDrawable(null, fbodCaps, null, glWindow.getWidth(), glWindow.getHeight(), glWindow.getContext());
+ factory.createOffscreenAutoDrawable(null, fbodCaps, null, glWindow.getWidth(), glWindow.getHeight());
+ fbod2.setSharedAutoDrawable(glWindow);
fbod2.setTextureUnit(fbod2_texUnit);
fbod2.addGLEventListener(new RedSquareES2(-1));
- fbod2.addGLEventListener(new GLFinishOnDisplay());
+ fbod2.addGLEventListener(new GLFinishOnDisplay());
fbod2.getNativeSurface().addSurfaceUpdatedListener(new SurfaceUpdatedListener() {
@Override
public void surfaceUpdated(Object updater, NativeSurface ns, long when) {
@@ -170,7 +172,7 @@ public class TestFBOOffThreadSharedContextMix2DemosES2NEWT extends UITestCase {
// preinit texIDs
mixerDemo.setTexID0(fbod1.getTextureBuffer(GL.GL_FRONT).getName());
mixerDemo.setTexID1(fbod2.getTextureBuffer(GL.GL_FRONT).getName());
-
+
glWindow.addGLEventListener(mixerDemo);
glWindow.addGLEventListener(new GLEventListener() {
int i=0, c=0;
@@ -178,39 +180,39 @@ public class TestFBOOffThreadSharedContextMix2DemosES2NEWT extends UITestCase {
public void dispose(GLAutoDrawable drawable) {}
public void display(GLAutoDrawable drawable) {
if(mainRun) return;
-
+
final int dw = drawable.getWidth();
final int dh = drawable.getHeight();
c++;
-
+
if(dw<800) {
System.err.println("XXX: "+dw+"x"+dh+", c "+c);
if(8 == c) {
- snapshot(i++, "msaa"+fbod1.getNumSamples(), drawable.getGL(), screenshot, TextureIO.PNG, null);
+ snapshot(i++, "msaa"+fbod1.getNumSamples(), drawable.getGL(), screenshot, TextureIO.PNG, null);
}
if(9 == c) {
c=0;
- new Thread() {
+ new Thread() {
@Override
public void run() {
glWindow.setSize(dw+256, dh+256);
- } }.start();
+ } }.start();
}
}
}
- public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
fbod1.setSize(width, height);
fbod2.setSize(width, height);
}
});
-
+
final FPSAnimator animator0 = new FPSAnimator(30);
animator0.add(fbod1);
animator0.add(fbod2);
-
+
final Animator animator1 = new Animator();
animator1.add(glWindow);
-
+
QuitAdapter quitAdapter = new QuitAdapter();
//glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter));
@@ -224,22 +226,22 @@ public class TestFBOOffThreadSharedContextMix2DemosES2NEWT extends UITestCase {
}
public void windowMoved(WindowEvent e) {
System.err.println("window moved: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight());
- }
+ }
});
-
+
animator0.start();
animator1.start();
// glWindow.setSkipContextReleaseThread(animator.getThread());
glWindow.setVisible(true);
-
+
System.err.println("NW chosen: "+glWindow.getDelegatedWindow().getChosenCapabilities());
System.err.println("GL chosen: "+glWindow.getChosenCapabilities());
System.err.println("window pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets());
-
+
animator0.setUpdateFPSFrames(30, showFPS ? System.err : null);
animator1.setUpdateFPSFrames(60, showFPS ? System.err : null);
-
+
while(!quitAdapter.shouldQuit() && animator1.isAnimating() && animator1.getTotalFPSDuration()<duration) {
Thread.sleep(100);
}
@@ -247,14 +249,14 @@ public class TestFBOOffThreadSharedContextMix2DemosES2NEWT extends UITestCase {
animator0.stop();
Assert.assertFalse(animator0.isAnimating());
Assert.assertFalse(animator0.isStarted());
-
+
animator1.stop();
Assert.assertFalse(animator1.isAnimating());
Assert.assertFalse(animator1.isStarted());
-
+
fbod1.destroy();
fbod2.destroy();
-
+
glWindow.destroy();
Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow, false));
}
@@ -263,14 +265,14 @@ public class TestFBOOffThreadSharedContextMix2DemosES2NEWT extends UITestCase {
public void test01() throws InterruptedException {
GLCapabilities caps = new GLCapabilities(forceES2 ? GLProfile.get(GLProfile.GLES2) : GLProfile.getGL2ES2());
caps.setAlphaBits(1);
- runTestGL(caps);
+ runTestGL(caps);
}
-
- public static void main(String args[]) throws IOException {
+
+ public static void main(String args[]) throws IOException {
boolean waitForKey = false;
-
+
mainRun = true;
-
+
for(int i=0; i<args.length; i++) {
if(args[i].equals("-time")) {
i++;
@@ -288,7 +290,7 @@ public class TestFBOOffThreadSharedContextMix2DemosES2NEWT extends UITestCase {
mainRun = false;
}
}
-
+
System.err.println("swapInterval "+swapInterval);
System.err.println("forceES2 "+forceES2);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOnThreadSharedContext1DemoES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOnThreadSharedContext1DemoES2NEWT.java
index 0f8ee56aa..3c6c61f80 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOnThreadSharedContext1DemoES2NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOnThreadSharedContext1DemoES2NEWT.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,12 +20,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.opengl.test.junit.jogl.acore;
import java.io.BufferedReader;
@@ -66,10 +66,10 @@ import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
/**
- * Toolkit agnostic {@link GLOffscreenAutoDrawable.FBO} tests using the
- * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}.
+ * Toolkit agnostic {@link GLOffscreenAutoDrawable.FBO} tests using the
+ * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}.
* <p>
- * The created {@link GLOffscreenAutoDrawable.FBO} is being used to run the {@link GLEventListener}.
+ * The created {@link GLOffscreenAutoDrawable.FBO} is being used to run the {@link GLEventListener}.
* </p>
* <p>
* This test simulates shared on-thread GL context / texture usage,
@@ -79,7 +79,7 @@ import org.junit.runners.MethodSorters;
* <ul>
* <li>1 {@link GLOffscreenAutoDrawable.FBO} double buffered
* <ul>
- * <liwith its own {@link GLContext}, which is shares the {@link GLWindow} one (see below)</li>
+ * <liwith its own {@link GLContext}, which is shares the {@link GLWindow} one (see below)</li>
* <li>running within common {@link Animator} @ 60fps</li>
* <li>produce a texture</li>
* <li>notify the onscreen renderer about new textureID (swapping double buffer)</li>
@@ -89,18 +89,18 @@ import org.junit.runners.MethodSorters;
* <li>shares it's {@link GLContext} w/ above FBO</li>
* <li>running within common {@link Animator} @ 60fps</li>
* <li>uses the shared FBO texture and draws it onscreen</li>
- * </ul></li>
- * </ul>
- * </p>
+ * </ul></li>
+ * </ul>
+ * </p>
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestFBOOnThreadSharedContext1DemoES2NEWT extends UITestCase {
+public class TestFBOOnThreadSharedContext1DemoES2NEWT extends UITestCase {
static long duration = 500; // ms
static int swapInterval = 1;
static boolean showFPS = false;
static boolean forceES2 = false;
static boolean mainRun = false;
-
+
@AfterClass
public static void releaseClass() {
}
@@ -108,30 +108,31 @@ public class TestFBOOnThreadSharedContext1DemoES2NEWT extends UITestCase {
protected void runTestGL(GLCapabilitiesImmutable caps) throws InterruptedException {
final GLReadBufferUtil screenshot = new GLReadBufferUtil(false, false);
System.err.println("requested: vsync "+swapInterval+", "+caps);
-
+
final GLWindow glWindow = GLWindow.create(caps);
Assert.assertNotNull(glWindow);
glWindow.setTitle("Gears NEWT Test (translucent "+!caps.isBackgroundOpaque()+"), swapInterval "+swapInterval);
if(mainRun) {
- glWindow.setSize(512, 512);
+ glWindow.setSize(512, 512);
} else {
glWindow.setSize(256, 256);
}
// eager initialization of context
glWindow.setVisible(true);
- glWindow.display();
+ glWindow.display();
final int fbod1_texUnit = 0;
-
+
final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile());
GLCapabilities fbodCaps = (GLCapabilities) caps.cloneMutable();
// fbodCaps.setDoubleBuffered(false);
-
+
final Mix2TexturesES2 mixerDemo = new Mix2TexturesES2(1, fbod1_texUnit, 0);
- // FBOD1
+ // FBOD1
final GLOffscreenAutoDrawable.FBO fbod1 = (GLOffscreenAutoDrawable.FBO)
- factory.createOffscreenAutoDrawable(null, fbodCaps, null, glWindow.getWidth(), glWindow.getHeight(), glWindow.getContext());
+ factory.createOffscreenAutoDrawable(null, fbodCaps, null, glWindow.getWidth(), glWindow.getHeight());
+ fbod1.setSharedAutoDrawable(glWindow);
fbod1.setUpstreamWidget(glWindow); // connect the real GLWindow (mouse/key) to offscreen!
fbod1.setTextureUnit(fbod1_texUnit);
{
@@ -148,10 +149,10 @@ public class TestFBOOnThreadSharedContext1DemoES2NEWT extends UITestCase {
fbod1.display(); // init
System.err.println("FBOD1 "+fbod1);
Assert.assertTrue(fbod1.isInitialized());
-
+
// preinit texIDs
mixerDemo.setTexID0(fbod1.getTextureBuffer(GL.GL_FRONT).getName());
-
+
glWindow.addWindowListener(new WindowAdapter() {
@Override
public void windowResized(WindowEvent e) {
@@ -165,33 +166,33 @@ public class TestFBOOnThreadSharedContext1DemoES2NEWT extends UITestCase {
public void dispose(GLAutoDrawable drawable) {}
public void display(GLAutoDrawable drawable) {
if(mainRun) return;
-
+
final int dw = drawable.getWidth();
final int dh = drawable.getHeight();
c++;
-
+
if(dw<800) {
System.err.println("XXX: "+dw+"x"+dh+", c "+c);
if(8 == c) {
- snapshot(i++, "msaa"+fbod1.getNumSamples(), drawable.getGL(), screenshot, TextureIO.PNG, null);
+ snapshot(i++, "msaa"+fbod1.getNumSamples(), drawable.getGL(), screenshot, TextureIO.PNG, null);
}
if(9 == c) {
c=0;
- new Thread() {
+ new Thread() {
@Override
public void run() {
glWindow.setSize(dw+256, dh+256);
- } }.start();
+ } }.start();
}
}
}
- public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { }
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { }
});
-
+
final Animator animator1 = new Animator();
animator1.add(fbod1);
animator1.add(glWindow);
-
+
QuitAdapter quitAdapter = new QuitAdapter();
//glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter));
@@ -205,20 +206,20 @@ public class TestFBOOnThreadSharedContext1DemoES2NEWT extends UITestCase {
}
public void windowMoved(WindowEvent e) {
System.err.println("window moved: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight());
- }
+ }
});
-
+
animator1.start();
// glWindow.setSkipContextReleaseThread(animator.getThread());
glWindow.setVisible(true);
-
+
System.err.println("NW chosen: "+glWindow.getDelegatedWindow().getChosenCapabilities());
System.err.println("GL chosen: "+glWindow.getChosenCapabilities());
System.err.println("window pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets());
-
+
animator1.setUpdateFPSFrames(60, showFPS ? System.err : null);
-
+
while(!quitAdapter.shouldQuit() && animator1.isAnimating() && animator1.getTotalFPSDuration()<duration) {
Thread.sleep(100);
}
@@ -226,9 +227,9 @@ public class TestFBOOnThreadSharedContext1DemoES2NEWT extends UITestCase {
animator1.stop();
Assert.assertFalse(animator1.isAnimating());
Assert.assertFalse(animator1.isStarted());
-
+
fbod1.destroy();
-
+
glWindow.destroy();
Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow, false));
}
@@ -237,14 +238,14 @@ public class TestFBOOnThreadSharedContext1DemoES2NEWT extends UITestCase {
public void test01() throws InterruptedException {
GLCapabilities caps = new GLCapabilities(forceES2 ? GLProfile.get(GLProfile.GLES2) : GLProfile.getGL2ES2());
caps.setAlphaBits(1);
- runTestGL(caps);
+ runTestGL(caps);
}
-
- public static void main(String args[]) throws IOException {
+
+ public static void main(String args[]) throws IOException {
boolean waitForKey = false;
-
+
mainRun = true;
-
+
for(int i=0; i<args.length; i++) {
if(args[i].equals("-time")) {
i++;
@@ -262,7 +263,7 @@ public class TestFBOOnThreadSharedContext1DemoES2NEWT extends UITestCase {
mainRun = false;
}
}
-
+
System.err.println("swapInterval "+swapInterval);
System.err.println("forceES2 "+forceES2);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateNEWT.java
index 0585bfaf8..91bae16d7 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateNEWT.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,12 +20,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.opengl.test.junit.jogl.acore;
import java.io.IOException;
@@ -59,25 +59,25 @@ import com.jogamp.opengl.util.Animator;
/**
* Test using a NEWT {@link Window} for onscreen case.
* <p>
- * Creates a {@link GLDrawable} using the
+ * Creates a {@link GLDrawable} using the
* {@link GLDrawableFactory#createGLDrawable(javax.media.nativewindow.NativeSurface) factory model}.
* The {@link GLContext} is derived {@link GLDrawable#createContext(GLContext) from the drawable}.
* </p>
* <p>
* Finally a {@link GLAutoDrawableDelegate} is created with the just created {@link GLDrawable} and {@link GLContext}.
- * It is being used to run the {@link GLEventListener}.
- * </p>
+ * It is being used to run the {@link GLEventListener}.
+ * </p>
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestGLAutoDrawableDelegateNEWT extends UITestCase {
static long duration = 500; // ms
-
+
void doTest(GLCapabilitiesImmutable reqGLCaps, GLEventListener demo) throws InterruptedException {
final GLDrawableFactory factory = GLDrawableFactory.getFactory(reqGLCaps.getGLProfile());
-
+
//
// Create native windowing resources .. X11/Win/OSX
- //
+ //
final Window window = NewtFactory.createWindow(reqGLCaps);
Assert.assertNotNull(window);
window.setSize(640, 400);
@@ -85,24 +85,24 @@ public class TestGLAutoDrawableDelegateNEWT extends UITestCase {
Assert.assertTrue(AWTRobotUtil.waitForVisible(window, true));
Assert.assertTrue(AWTRobotUtil.waitForRealized(window, true));
System.out.println("Window: "+window.getClass().getName());
-
+
final GLDrawable drawable = factory.createGLDrawable(window);
Assert.assertNotNull(drawable);
drawable.setRealized(true);
-
- final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(drawable, drawable.createContext(null), window, false, null) {
+
+ final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(drawable, null, window, false, null) {
@Override
protected void destroyImplInLock() {
super.destroyImplInLock(); // destroys drawable/context
window.destroy(); // destroys the actual window, incl. the device
}
};
-
+
window.setWindowDestroyNotifyAction( new Runnable() {
public void run() {
glad.windowDestroyNotifyOp();
} } );
-
+
window.addWindowListener(new WindowAdapter() {
@Override
public void windowRepaint(WindowUpdateEvent e) {
@@ -116,13 +116,13 @@ public class TestGLAutoDrawableDelegateNEWT extends UITestCase {
});
glad.addGLEventListener(demo);
-
+
QuitAdapter quitAdapter = new QuitAdapter();
//glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter));
//glWindow.addWindowListener(new TraceWindowAdapter(quitAdapter));
window.addKeyListener(quitAdapter);
window.addWindowListener(quitAdapter);
-
+
Animator animator = new Animator();
animator.setUpdateFPSFrames(60, System.err);
animator.setModeBits(false, Animator.MODE_EXPECT_AWT_RENDERING_THREAD);
@@ -130,17 +130,17 @@ public class TestGLAutoDrawableDelegateNEWT extends UITestCase {
animator.start();
Assert.assertTrue(animator.isStarted());
Assert.assertTrue(animator.isAnimating());
-
+
while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
Thread.sleep(100);
- }
+ }
System.out.println("Fin start ...");
-
+
animator.stop();
Assert.assertFalse(animator.isAnimating());
Assert.assertFalse(animator.isStarted());
glad.destroy();
- System.out.println("Fin Drawable: "+drawable);
+ System.out.println("Fin Drawable: "+drawable);
System.out.println("Fin Window: "+window);
}
@@ -149,7 +149,7 @@ public class TestGLAutoDrawableDelegateNEWT extends UITestCase {
final GLCapabilities reqGLCaps = new GLCapabilities( GLProfile.getGL2ES2() );
doTest(reqGLCaps, new GearsES2(1));
}
-
+
public static void main(String args[]) throws IOException {
for(int i=0; i<args.length; i++) {
if(args[i].equals("-time")) {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryES2OffscrnCapsNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryES2OffscrnCapsNEWT.java
index 7bcb5b56d..a5799a6cb 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryES2OffscrnCapsNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryES2OffscrnCapsNEWT.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,12 +20,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.opengl.test.junit.jogl.acore;
import java.io.IOException;
@@ -52,11 +52,11 @@ import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
import com.jogamp.opengl.test.junit.util.UITestCase;
/**
- * Toolkit agnostic {@link GLOffscreenAutoDrawable} tests using the
- * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}.
+ * Toolkit agnostic {@link GLOffscreenAutoDrawable} tests using the
+ * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}.
* <p>
- * The created {@link GLOffscreenAutoDrawable} is being used to run the {@link GLEventListener}.
- * </p>
+ * The created {@link GLOffscreenAutoDrawable} is being used to run the {@link GLEventListener}.
+ * </p>
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
@@ -71,7 +71,7 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
}
return new GLCapabilities(GLProfile.get(profile));
}
-
+
void doTest(GLCapabilitiesImmutable reqGLCaps, GLEventListener demo) throws InterruptedException {
System.out.println("Requested GL Caps: "+reqGLCaps);
final GLDrawableFactory factory = GLDrawableFactory.getFactory(reqGLCaps.getGLProfile());
@@ -79,15 +79,15 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
System.out.println("Expected GL Caps: "+expGLCaps);
//
- // Create native OpenGL resources .. XGL/WGL/CGL ..
+ // Create native OpenGL resources .. XGL/WGL/CGL ..
// equivalent to GLAutoDrawable methods: setVisible(true)
//
- final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, reqGLCaps, null, widthStep*szStep, heightStep*szStep, null);
-
+ final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, reqGLCaps, null, widthStep*szStep, heightStep*szStep);
+
Assert.assertNotNull(glad);
- System.out.println("Drawable Pre-GL(0): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName());
+ System.out.println("Drawable Pre-GL(0): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName());
Assert.assertTrue(glad.isRealized());
-
+
// Check caps of NativeWindow config w/o GL
final CapabilitiesImmutable chosenCaps = glad.getChosenGLCapabilities();
System.out.println("Drawable Caps Pre_GL : "+chosenCaps);
@@ -95,7 +95,7 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
Assert.assertTrue(chosenCaps.getGreenBits()>4);
Assert.assertTrue(chosenCaps.getBlueBits()>4);
Assert.assertTrue(chosenCaps.getRedBits()>4);
-
+
glad.display(); // force native context creation
// Check caps of GLDrawable after realization
@@ -113,45 +113,45 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
Assert.assertEquals(expGLCaps.isFBO(), chosenGLCaps.isFBO());
Assert.assertEquals(expGLCaps.isPBuffer(), chosenGLCaps.isPBuffer());
Assert.assertEquals(expGLCaps.isBitmap(), chosenGLCaps.isBitmap());
- /** Single/Double buffer cannot be checked since result may vary ..
+ /** Single/Double buffer cannot be checked since result may vary ..
if(chosenGLCaps.isOnscreen() || chosenGLCaps.isFBO()) {
// dbl buffer may be disabled w/ offscreen pbuffer and bitmap
Assert.assertEquals(expGLCaps.getDoubleBuffered(), chosenGLCaps.getDoubleBuffered());
- } */
+ } */
glad.addGLEventListener(demo);
-
+
final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener();
glad.addGLEventListener(snapshotGLEventListener);
-
+
glad.display(); // initial resize/display
-
+
// 1 - szStep = 2
- Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
+ Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep));
snapshotGLEventListener.setMakeSnapshot();
glad.display();
-
+
// 2, 3 (resize + display)
szStep = 1;
glad.setSize(widthStep*szStep, heightStep*szStep);
- Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
+ Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep));
snapshotGLEventListener.setMakeSnapshot();
glad.display();
-
+
// 4, 5 (resize + display)
szStep = 4;
glad.setSize(widthStep*szStep, heightStep*szStep);
- Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
+ Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep));
snapshotGLEventListener.setMakeSnapshot();
glad.display();
-
+
Thread.sleep(50);
-
+
glad.destroy();
- System.out.println("Fin Drawable: "+glad);
+ System.out.println("Fin Drawable: "+glad);
}
@Test
@@ -164,8 +164,8 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
if(null != f) {
System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString());
}
- }
-
+ }
+
@Test
public void testES2OffScreenAutoDblBuf() throws InterruptedException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
@@ -182,7 +182,7 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setFBO(true);
doTest(reqGLCaps, new GearsES2(1));
}
-
+
@Test
public void testES2OffScreenFBOSglBuf() throws InterruptedException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
@@ -191,8 +191,8 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setFBO(true);
reqGLCaps.setDoubleBuffered(false);
doTest(reqGLCaps, new GearsES2(1));
- }
-
+ }
+
@Test
public void testES2OffScreenFBODblBufStencil() throws InterruptedException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
@@ -202,7 +202,7 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setStencilBits(1);
doTest(reqGLCaps, new GearsES2(1));
}
-
+
@Test
public void testES2OffScreenFBODblBufMSAA() throws InterruptedException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
@@ -212,8 +212,8 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setSampleBuffers(true);
reqGLCaps.setNumSamples(4);
doTest(reqGLCaps, new GearsES2(1));
- }
-
+ }
+
@Test
public void testES2OffScreenFBODblBufStencilMSAA() throws InterruptedException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
@@ -224,8 +224,8 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setSampleBuffers(true);
reqGLCaps.setNumSamples(4);
doTest(reqGLCaps, new GearsES2(1));
- }
-
+ }
+
@Test
public void testES2OffScreenPbufferDblBuf() throws InterruptedException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
@@ -233,8 +233,8 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setOnscreen(false);
reqGLCaps.setPBuffer(true);
doTest(reqGLCaps, new GearsES2(1));
- }
-
+ }
+
@Test
public void testES2OffScreenPbufferSglBuf() throws InterruptedException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
@@ -244,7 +244,7 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setDoubleBuffered(false);
doTest(reqGLCaps, new GearsES2(1));
}
-
+
// Might be reduced to !stencil
@Test
public void testES2OffScreenPbufferDblBufStencil() throws InterruptedException {
@@ -255,7 +255,7 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setStencilBits(1);
doTest(reqGLCaps, new GearsES2(1));
}
-
+
// Might be reduced to !MSAA
@Test
public void testES2OffScreenPbufferDblBufMSAA() throws InterruptedException {
@@ -266,8 +266,8 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setSampleBuffers(true);
reqGLCaps.setNumSamples(4);
doTest(reqGLCaps, new GearsES2(1));
- }
-
+ }
+
// Might be reduced to !stencil && !MSAA
@Test
public void testES2OffScreenPbufferDblBufStencilMSAA() throws InterruptedException {
@@ -279,9 +279,9 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setSampleBuffers(true);
reqGLCaps.setNumSamples(4);
doTest(reqGLCaps, new GearsES2(1));
- }
+ }
- /** NOT Implemented:
+ /** NOT Implemented:
// Might be reduced to !double-buff
@Test
public void testES2OffScreenBitmapDblBuf() throws InterruptedException {
@@ -291,7 +291,7 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setBitmap(true);
doTest(reqGLCaps, new Gears(1));
}
-
+
@Test
public void testES2OffScreenBitmapSglBuf() throws InterruptedException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
@@ -301,7 +301,7 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setDoubleBuffered(false);
doTest(reqGLCaps, new Gears(1));
}
-
+
// Might be reduced to !stencil
@Test
public void testES2OffScreenBitmapDblBufStencil() throws InterruptedException {
@@ -312,7 +312,7 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setStencilBits(1);
doTest(reqGLCaps, new GearsES2(1));
}
-
+
// Might be reduced to !MSAA
@Test
public void testES2OffScreenBitmapDblBufMSAA() throws InterruptedException {
@@ -323,8 +323,8 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setSampleBuffers(true);
reqGLCaps.setNumSamples(4);
doTest(reqGLCaps, new GearsES2(1));
- }
-
+ }
+
// Might be reduced to !stencil && !MSAA
@Test
public void testES2OffScreenBitmapDblBufStencilMSAA() throws InterruptedException {
@@ -337,7 +337,7 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setNumSamples(4);
doTest(reqGLCaps, new GearsES2(1));
} */
-
+
public static void main(String args[]) throws IOException {
org.junit.runner.JUnitCore.main(TestGLAutoDrawableFactoryES2OffscrnCapsNEWT.class.getName());
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT.java
index 06dc7c83e..09e211332 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,12 +20,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.opengl.test.junit.jogl.acore;
import java.io.IOException;
@@ -52,11 +52,11 @@ import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
import com.jogamp.opengl.test.junit.util.UITestCase;
/**
- * Toolkit agnostic {@link GLOffscreenAutoDrawable} tests using the
- * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}.
+ * Toolkit agnostic {@link GLOffscreenAutoDrawable} tests using the
+ * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}.
* <p>
- * The created {@link GLOffscreenAutoDrawable} is being used to run the {@link GLEventListener}.
- * </p>
+ * The created {@link GLOffscreenAutoDrawable} is being used to run the {@link GLEventListener}.
+ * </p>
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
@@ -71,7 +71,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
}
return new GLCapabilities(GLProfile.get(profile));
}
-
+
void doTest(GLCapabilitiesImmutable reqGLCaps, GLEventListener demo) throws InterruptedException {
System.out.println("Requested GL Caps: "+reqGLCaps);
final GLDrawableFactory factory = GLDrawableFactory.getFactory(reqGLCaps.getGLProfile());
@@ -79,15 +79,15 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
System.out.println("Expected GL Caps: "+expGLCaps);
//
- // Create native OpenGL resources .. XGL/WGL/CGL ..
+ // Create native OpenGL resources .. XGL/WGL/CGL ..
// equivalent to GLAutoDrawable methods: setVisible(true)
//
- final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, reqGLCaps, null, widthStep*szStep, heightStep*szStep, null);
-
+ final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, reqGLCaps, null, widthStep*szStep, heightStep*szStep);
+
Assert.assertNotNull(glad);
- System.out.println("Drawable Pre-GL(0): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName());
+ System.out.println("Drawable Pre-GL(0): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName());
Assert.assertTrue(glad.isRealized());
-
+
// Check caps of NativeWindow config w/o GL
final CapabilitiesImmutable chosenCaps = glad.getChosenGLCapabilities();
System.out.println("Drawable Caps Pre_GL : "+chosenCaps);
@@ -95,7 +95,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
Assert.assertTrue(chosenCaps.getGreenBits()>4);
Assert.assertTrue(chosenCaps.getBlueBits()>4);
Assert.assertTrue(chosenCaps.getRedBits()>4);
-
+
glad.display(); // force native context creation
// Check caps of GLDrawable after realization
@@ -113,45 +113,45 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
Assert.assertEquals(expGLCaps.isFBO(), chosenGLCaps.isFBO());
Assert.assertEquals(expGLCaps.isPBuffer(), chosenGLCaps.isPBuffer());
Assert.assertEquals(expGLCaps.isBitmap(), chosenGLCaps.isBitmap());
- /** Single/Double buffer cannot be checked since result may vary ..
+ /** Single/Double buffer cannot be checked since result may vary ..
if(chosenGLCaps.isOnscreen() || chosenGLCaps.isFBO()) {
// dbl buffer may be disabled w/ offscreen pbuffer and bitmap
Assert.assertEquals(expGLCaps.getDoubleBuffered(), chosenGLCaps.getDoubleBuffered());
- } */
+ } */
glad.addGLEventListener(demo);
-
+
final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener();
glad.addGLEventListener(snapshotGLEventListener);
-
+
glad.display(); // initial resize/display
-
+
// 1 - szStep = 2
- Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
+ Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep));
snapshotGLEventListener.setMakeSnapshot();
glad.display();
-
+
// 2, 3 (resize + display)
szStep = 1;
glad.setSize(widthStep*szStep, heightStep*szStep);
- Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
+ Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep));
snapshotGLEventListener.setMakeSnapshot();
glad.display();
-
+
// 4, 5 (resize + display)
szStep = 4;
glad.setSize(widthStep*szStep, heightStep*szStep);
- Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
+ Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep));
snapshotGLEventListener.setMakeSnapshot();
glad.display();
-
+
Thread.sleep(50);
-
+
glad.destroy();
- System.out.println("Fin Drawable: "+glad);
+ System.out.println("Fin Drawable: "+glad);
}
@Test
@@ -164,8 +164,8 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
if(null != f) {
System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString());
}
- }
-
+ }
+
@Test
public void testGL2OffScreenAutoDblBuf() throws InterruptedException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
@@ -182,7 +182,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setFBO(true);
doTest(reqGLCaps, new Gears(1));
}
-
+
@Test
public void testGL2OffScreenFBOSglBuf() throws InterruptedException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
@@ -191,8 +191,8 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setFBO(true);
reqGLCaps.setDoubleBuffered(false);
doTest(reqGLCaps, new Gears(1));
- }
-
+ }
+
@Test
public void testGL2OffScreenFBODblBufStencil() throws InterruptedException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
@@ -202,7 +202,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setStencilBits(1);
doTest(reqGLCaps, new Gears(1));
}
-
+
@Test
public void testGL2OffScreenFBODblBufMSAA() throws InterruptedException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
@@ -212,8 +212,8 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setSampleBuffers(true);
reqGLCaps.setNumSamples(4);
doTest(reqGLCaps, new Gears(1));
- }
-
+ }
+
@Test
public void testGL2OffScreenFBODblBufStencilMSAA() throws InterruptedException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
@@ -224,8 +224,8 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setSampleBuffers(true);
reqGLCaps.setNumSamples(4);
doTest(reqGLCaps, new Gears(1));
- }
-
+ }
+
@Test
public void testGL2OffScreenPbufferDblBuf() throws InterruptedException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
@@ -233,8 +233,8 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setOnscreen(false);
reqGLCaps.setPBuffer(true);
doTest(reqGLCaps, new Gears(1));
- }
-
+ }
+
@Test
public void testGL2OffScreenPbufferSglBuf() throws InterruptedException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
@@ -244,8 +244,8 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setDoubleBuffered(false);
doTest(reqGLCaps, new Gears(1));
}
-
- // Might be reduced to !stencil
+
+ // Might be reduced to !stencil
@Test
public void testGL2OffScreenPbufferDblBufStencil() throws InterruptedException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
@@ -255,7 +255,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setStencilBits(1);
doTest(reqGLCaps, new Gears(1));
}
-
+
// Might be reduced to !MSAA
@Test
public void testGL2OffScreenPbufferDblBufMSAA() throws InterruptedException {
@@ -266,8 +266,8 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setSampleBuffers(true);
reqGLCaps.setNumSamples(4);
doTest(reqGLCaps, new Gears(1));
- }
-
+ }
+
// Might be reduced to !stencil && !MSAA
@Test
public void testGL2OffScreenPbufferDblBufStencilMSAA() throws InterruptedException {
@@ -279,9 +279,9 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setSampleBuffers(true);
reqGLCaps.setNumSamples(4);
doTest(reqGLCaps, new Gears(1));
- }
-
-
+ }
+
+
// Might be reduced to !double-buff
@Test
public void testGL2OffScreenBitmapDblBuf() throws InterruptedException {
@@ -291,7 +291,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setBitmap(true);
doTest(reqGLCaps, new Gears(1));
}
-
+
@Test
public void testGL2OffScreenBitmapDblBufRGBA8881() throws InterruptedException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
@@ -304,7 +304,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setBitmap(true);
doTest(reqGLCaps, new Gears(1));
}
-
+
@Test
public void testGL2OffScreenBitmapDblBufRGB555() throws InterruptedException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
@@ -317,7 +317,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setBitmap(true);
doTest(reqGLCaps, new Gears(1));
}
-
+
@Test
public void testGL2OffScreenBitmapDblBufRGBA5551() throws InterruptedException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
@@ -330,7 +330,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setBitmap(true);
doTest(reqGLCaps, new Gears(1));
}
-
+
@Test
public void testGL2OffScreenBitmapSglBuf() throws InterruptedException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
@@ -340,7 +340,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setDoubleBuffered(false);
doTest(reqGLCaps, new Gears(1));
}
-
+
// Might be reduced to !stencil
@Test
public void testGL2OffScreenBitmapDblBufStencil() throws InterruptedException {
@@ -351,7 +351,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setStencilBits(1);
doTest(reqGLCaps, new Gears(1));
}
-
+
// Might be reduced to !MSAA
@Test
public void testGL2OffScreenBitmapDblBufMSAA() throws InterruptedException {
@@ -362,8 +362,8 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setSampleBuffers(true);
reqGLCaps.setNumSamples(4);
doTest(reqGLCaps, new Gears(1));
- }
-
+ }
+
// Might be reduced to !stencil && !MSAA
@Test
public void testGL2OffScreenBitmapDblBufStencilMSAA() throws InterruptedException {
@@ -375,8 +375,8 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setSampleBuffers(true);
reqGLCaps.setNumSamples(4);
doTest(reqGLCaps, new Gears(1));
- }
-
+ }
+
public static void main(String args[]) throws IOException {
org.junit.runner.JUnitCore.main(TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT.class.getName());
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGLnBitmapCapsNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGLnBitmapCapsNEWT.java
index 75609224e..f35f8c8b0 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGLnBitmapCapsNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGLnBitmapCapsNEWT.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,12 +20,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.opengl.test.junit.jogl.acore;
import java.io.IOException;
@@ -52,11 +52,11 @@ import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
import com.jogamp.opengl.test.junit.util.UITestCase;
/**
- * Toolkit agnostic {@link GLOffscreenAutoDrawable} tests using the
- * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}.
+ * Toolkit agnostic {@link GLOffscreenAutoDrawable} tests using the
+ * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}.
* <p>
- * The created {@link GLOffscreenAutoDrawable} is being used to run the {@link GLEventListener}.
- * </p>
+ * The created {@link GLOffscreenAutoDrawable} is being used to run the {@link GLEventListener}.
+ * </p>
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestGLAutoDrawableFactoryGLnBitmapCapsNEWT extends UITestCase {
@@ -71,15 +71,15 @@ public class TestGLAutoDrawableFactoryGLnBitmapCapsNEWT extends UITestCase {
System.out.println("Expected GL Caps: "+expGLCaps);
//
- // Create native OpenGL resources .. XGL/WGL/CGL ..
+ // Create native OpenGL resources .. XGL/WGL/CGL ..
// equivalent to GLAutoDrawable methods: setVisible(true)
//
- final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, reqGLCaps, null, widthStep*szStep, heightStep*szStep, null);
-
+ final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, reqGLCaps, null, widthStep*szStep, heightStep*szStep);
+
Assert.assertNotNull(glad);
- System.out.println("Drawable Pre-GL(0): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName());
+ System.out.println("Drawable Pre-GL(0): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName());
Assert.assertTrue(glad.isRealized());
-
+
// Check caps of NativeWindow config w/o GL
final CapabilitiesImmutable chosenCaps = glad.getChosenGLCapabilities();
System.out.println("Drawable Caps Pre_GL : "+chosenCaps);
@@ -87,7 +87,7 @@ public class TestGLAutoDrawableFactoryGLnBitmapCapsNEWT extends UITestCase {
Assert.assertTrue(chosenCaps.getGreenBits()>4);
Assert.assertTrue(chosenCaps.getBlueBits()>4);
Assert.assertTrue(chosenCaps.getRedBits()>4);
-
+
glad.display(); // force native context creation
// Check caps of GLDrawable after realization
@@ -105,45 +105,45 @@ public class TestGLAutoDrawableFactoryGLnBitmapCapsNEWT extends UITestCase {
Assert.assertEquals(expGLCaps.isFBO(), chosenGLCaps.isFBO());
Assert.assertEquals(expGLCaps.isPBuffer(), chosenGLCaps.isPBuffer());
Assert.assertEquals(expGLCaps.isBitmap(), chosenGLCaps.isBitmap());
- /** Single/Double buffer cannot be checked since result may vary ..
+ /** Single/Double buffer cannot be checked since result may vary ..
if(chosenGLCaps.isOnscreen() || chosenGLCaps.isFBO()) {
// dbl buffer may be disabled w/ offscreen pbuffer and bitmap
Assert.assertEquals(expGLCaps.getDoubleBuffered(), chosenGLCaps.getDoubleBuffered());
- } */
+ } */
glad.addGLEventListener(demo);
-
+
final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener();
glad.addGLEventListener(snapshotGLEventListener);
-
+
glad.display(); // initial resize/display
-
+
// 1 - szStep = 2
- Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
+ Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep));
snapshotGLEventListener.setMakeSnapshot();
glad.display();
-
+
// 2, 3 (resize + display)
szStep = 1;
glad.setSize(widthStep*szStep, heightStep*szStep);
- Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
+ Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep));
snapshotGLEventListener.setMakeSnapshot();
glad.display();
-
+
// 4, 5 (resize + display)
szStep = 4;
glad.setSize(widthStep*szStep, heightStep*szStep);
- Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
+ Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep));
snapshotGLEventListener.setMakeSnapshot();
glad.display();
-
+
Thread.sleep(50);
-
+
glad.destroy();
- System.out.println("Fin Drawable: "+glad);
+ System.out.println("Fin Drawable: "+glad);
}
@Test
@@ -156,8 +156,8 @@ public class TestGLAutoDrawableFactoryGLnBitmapCapsNEWT extends UITestCase {
if(null != f) {
System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString());
}
- }
-
+ }
+
// Might be reduced to !double-buff
@Test
public void testGL2OffScreenBitmapDblBuf() throws InterruptedException {
@@ -166,7 +166,7 @@ public class TestGLAutoDrawableFactoryGLnBitmapCapsNEWT extends UITestCase {
reqGLCaps.setBitmap(true);
doTest(reqGLCaps, new Gears(1));
}
-
+
// Might be reduced to !MSAA
@Test
public void testGL2OffScreenBitmapDblBufMSAA() throws InterruptedException {
@@ -176,8 +176,8 @@ public class TestGLAutoDrawableFactoryGLnBitmapCapsNEWT extends UITestCase {
reqGLCaps.setSampleBuffers(true);
reqGLCaps.setNumSamples(4);
doTest(reqGLCaps, new Gears(1));
- }
-
+ }
+
public static void main(String args[]) throws IOException {
org.junit.runner.JUnitCore.main(TestGLAutoDrawableFactoryGLnBitmapCapsNEWT.class.getName());
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLExtensionQueryOffscreen.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLExtensionQueryOffscreen.java
index f9ab6c4b3..4bc8e7ee3 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLExtensionQueryOffscreen.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLExtensionQueryOffscreen.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,12 +20,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.opengl.test.junit.jogl.acore;
import java.util.Collections;
@@ -47,14 +47,14 @@ import org.junit.runners.MethodSorters;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestGLExtensionQueryOffscreen {
-
+
public static void main(String[] args) {
TestGLExtensionQueryOffscreen instance = new TestGLExtensionQueryOffscreen();
instance.testJogl2ExtensionCheck1();
instance.testJogl2ExtensionCheck2();
}
- /**
+ /**
* @deprecated This test uses a non public API in jogamp.opengl.* and hence is not recommended
*/
@Test
@@ -74,13 +74,13 @@ public class TestGLExtensionQueryOffscreen {
System.out.println("SharedContext: "+sharedContext);
System.out.println("SharedContext: "+setExtensions);
}
-
+
@Test
public void testJogl2ExtensionCheck2() {
final GLCapabilities caps = new GLCapabilities(GLProfile.getDefault());
- final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile());
- final GLOffscreenAutoDrawable drawable = factory.createOffscreenAutoDrawable(null, caps, null, 256, 256, null);
-
+ final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile());
+ final GLOffscreenAutoDrawable drawable = factory.createOffscreenAutoDrawable(null, caps, null, 256, 256);
+ drawable.display(); // trigger context creation ..
final GLContext context = drawable.getContext();
context.makeCurrent();
String extensions;
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java
index c8cc294a2..83e55b7e0 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java
@@ -30,16 +30,16 @@ public class TestNEWTCloseX11DisplayBug565 {
try {
for ( int j = 0; j < 10; j++ ) {
final int open0;
- if(NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false)) {
+ if(NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false)) {
open0 = X11Util.getOpenDisplayConnectionNumber();
} else {
open0 = 0;
}
-
+
GLCapabilitiesImmutable caps = new GLCapabilities( GLProfile.getDefault( ) );
-
+
GLWindow window = GLWindow.create(caps);
- window.setTitle("NEWT Resource X11 Leak - #" + j );
+ window.setTitle("NEWT Resource X11 Leak - #" + j );
window.setSize( 128, 128 );
window.setVisible(true);
window.display();
@@ -69,7 +69,7 @@ public class TestNEWTCloseX11DisplayBug565 {
try {
for ( int j = 0; j < 10; j++ ) {
final int open0;
- if(NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false)) {
+ if(NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false)) {
open0 = X11Util.getOpenDisplayConnectionNumber();
} else {
open0 = 0;
@@ -111,7 +111,7 @@ public class TestNEWTCloseX11DisplayBug565 {
try {
for ( int j = 0; j < 10; j++ ) {
final int open0;
- if(NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false)) {
+ if(NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false)) {
open0 = X11Util.getOpenDisplayConnectionNumber();
} else {
open0 = 0;
@@ -121,13 +121,7 @@ public class TestNEWTCloseX11DisplayBug565 {
GLOffscreenAutoDrawable buffer = GLDrawableFactory.getFactory( glp ).createOffscreenAutoDrawable(
- null,
- caps,
- new DefaultGLCapabilitiesChooser(),
- 256,
- 256,
- null
- );
+ null, caps, new DefaultGLCapabilitiesChooser(), 256, 256);
buffer.display();
buffer.destroy();
@@ -146,10 +140,10 @@ public class TestNEWTCloseX11DisplayBug565 {
Assert.fail(e.getMessage());
}
}
-
+
public static void main(String args[]) {
org.junit.runner.JUnitCore.main(TestNEWTCloseX11DisplayBug565.class.getName());
}
-
+
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java
index a3eb6db84..77657f6f1 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,12 +20,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.opengl.test.junit.jogl.acore;
import javax.media.opengl.GLCapabilities;
@@ -73,7 +73,7 @@ public class TestSharedContextListAWT extends UITestCase {
}
private void initShared() {
- sharedDrawable = GLDrawableFactory.getFactory(glp).createOffscreenAutoDrawable(null, caps, null, width, height, null);
+ sharedDrawable = GLDrawableFactory.getFactory(glp).createOffscreenAutoDrawable(null, caps, null, width, height);
Assert.assertNotNull(sharedDrawable);
sharedGears = new Gears();
Assert.assertNotNull(sharedGears);
@@ -86,8 +86,8 @@ public class TestSharedContextListAWT extends UITestCase {
Assert.assertNotNull(sharedDrawable);
sharedDrawable.destroy();
}
-
- protected void setFrameTitle(final Frame f, final boolean useShared)
+
+ protected void setFrameTitle(final Frame f, final boolean useShared)
throws InterruptedException, InvocationTargetException {
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
@@ -99,12 +99,13 @@ public class TestSharedContextListAWT extends UITestCase {
protected GLCanvas runTestGL(final Frame frame, final Animator animator, final int x, final int y, final boolean useShared, final boolean vsync)
throws InterruptedException, InvocationTargetException
{
- final GLCanvas glCanvas = new GLCanvas(caps, useShared ? sharedDrawable.getContext() : null);
+ final GLCanvas glCanvas = new GLCanvas(caps);
Assert.assertNotNull(glCanvas);
+ glCanvas.setSharedAutoDrawable(sharedDrawable);
frame.add(glCanvas);
frame.setLocation(x, y);
frame.setSize(width, height);
-
+
Gears gears = new Gears(vsync ? 1 : 0);
if(useShared) {
gears.setGears(sharedGears.getGear1(), sharedGears.getGear2(), sharedGears.getGear3());
@@ -133,22 +134,22 @@ public class TestSharedContextListAWT extends UITestCase {
final GLCanvas glc1 = runTestGL(f1, animator, 0, 0, true, false);
int x0 = f1.getX();
int y0 = f1.getY();
-
- final GLCanvas glc2 = runTestGL(f2, animator,
+
+ final GLCanvas glc2 = runTestGL(f2, animator,
x0+width,
- y0+0,
+ y0+0,
true, false);
-
- final GLCanvas glc3 = runTestGL(f3, animator,
- x0+0,
- y0+height,
+
+ final GLCanvas glc3 = runTestGL(f3, animator,
+ x0+0,
+ y0+height,
false, true);
setFrameTitle(f1, true);
setFrameTitle(f2, true);
setFrameTitle(f3, false);
-
- animator.setUpdateFPSFrames(1, null);
+
+ animator.setUpdateFPSFrames(1, null);
animator.start();
while(animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
Thread.sleep(100);
@@ -172,8 +173,8 @@ public class TestSharedContextListAWT extends UITestCase {
} catch( Throwable throwable ) {
throwable.printStackTrace();
Assume.assumeNoException( throwable );
- }
-
+ }
+
releaseShared();
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT.java
index 1e34b83cc..09173fb24 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,12 +20,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.opengl.test.junit.jogl.acore;
import java.io.IOException;
@@ -72,7 +72,7 @@ public class TestSharedContextListNEWT extends UITestCase {
}
private void initShared() {
- sharedDrawable = GLDrawableFactory.getFactory(glp).createOffscreenAutoDrawable(null, caps, null, width, height, null);
+ sharedDrawable = GLDrawableFactory.getFactory(glp).createOffscreenAutoDrawable(null, caps, null, width, height);
Assert.assertNotNull(sharedDrawable);
sharedGears = new Gears();
Assert.assertNotNull(sharedGears);
@@ -119,11 +119,11 @@ public class TestSharedContextListNEWT extends UITestCase {
Animator animator = new Animator();
GLWindow f1 = runTestGL(animator, 0, 0, true, false);
InsetsImmutable insets = f1.getInsets();
- GLWindow f2 = runTestGL(animator, f1.getX()+width+insets.getTotalWidth(),
+ GLWindow f2 = runTestGL(animator, f1.getX()+width+insets.getTotalWidth(),
f1.getY()+0, true, false);
- GLWindow f3 = runTestGL(animator, f1.getX()+0,
+ GLWindow f3 = runTestGL(animator, f1.getX()+0,
f1.getY()+height+insets.getTotalHeight(), false, true);
- animator.setUpdateFPSFrames(1, null);
+ animator.setUpdateFPSFrames(1, null);
animator.start();
while(animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
Thread.sleep(100);
@@ -151,7 +151,7 @@ public class TestSharedContextListNEWT extends UITestCase {
/**
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
System.err.println("Press enter to continue");
- System.err.println(stdin.readLine()); */
+ System.err.println(stdin.readLine()); */
org.junit.runner.JUnitCore.main(TestSharedContextListNEWT.class.getName());
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextNewtAWTBug523.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextNewtAWTBug523.java
index 434a64fad..90344fb0b 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextNewtAWTBug523.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextNewtAWTBug523.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,12 +20,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.opengl.test.junit.jogl.acore;
import java.awt.Component;
@@ -77,7 +77,7 @@ import com.jogamp.opengl.util.GLBuffers;
/**
* TestSharedContextNewtAWTBug523
- *
+ *
* Opens a single JFrame with two OpenGL windows and sliders to adjust the view orientation.
*
* Each window renders a red triangle and a blue triangle.
@@ -91,18 +91,18 @@ import com.jogamp.opengl.util.GLBuffers;
* so that they share the vertex buffer and array objects and display lists.
* If shareContext is false, then the two OpenGL windows each have their own context, and the blue
* triangle fails to render in one of the windows.
- *
+ *
* The four test cases run through the four combinations of useNewt and shareContext.
- *
- * Similar test cases are {@link TestSharedContextListNEWT}, {@link TestSharedContextListAWT},
- * {@link TestSharedContextVBOES2NEWT} and {@link TestSharedContextVBOES1NEWT}.
- *
+ *
+ * Similar test cases are {@link TestSharedContextListNEWT}, {@link TestSharedContextListAWT},
+ * {@link TestSharedContextVBOES2NEWT1} and {@link TestSharedContextVBOES1NEWT}.
+ *
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestSharedContextNewtAWTBug523 extends UITestCase {
static long durationPerTest = 1000;
-
+
// counters for instances of event listener TwoTriangles
// private static int instanceCounter;
private static int initializationCounter;
@@ -111,7 +111,7 @@ public class TestSharedContextNewtAWTBug523 extends UITestCase {
// The main thread waits twice on this semaphore to ensure both canvases have finished cleaning up.
private static Semaphore disposalCompleteSemaphore = new Semaphore(0);
- // Buffer objects can be shared across shared OpenGL context.
+ // Buffer objects can be shared across shared OpenGL context.
// If we run with sharedContext, then the tests will use these shared buffer objects,
// otherwise each event listener allocates its own buffer objects.
private static int [] sharedVertexBufferObjects = {0};
@@ -125,9 +125,9 @@ public class TestSharedContextNewtAWTBug523 extends UITestCase {
setTestSupported(false);
}
}
-
+
static private GLOffscreenAutoDrawable initShared(GLCapabilities caps) {
- final GLOffscreenAutoDrawable sharedDrawable = GLDrawableFactory.getFactory(caps.getGLProfile()).createOffscreenAutoDrawable(null, caps, null, 64, 64, null);
+ final GLOffscreenAutoDrawable sharedDrawable = GLDrawableFactory.getFactory(caps.getGLProfile()).createOffscreenAutoDrawable(null, caps, null, 64, 64);
Assert.assertNotNull(sharedDrawable);
// init and render one frame, which will setup the Gears display lists
sharedDrawable.display();
@@ -139,34 +139,34 @@ public class TestSharedContextNewtAWTBug523 extends UITestCase {
sharedDrawable.destroy();
}
}
-
+
// inner class that implements the event listener
static class TwoTriangles implements GLEventListener {
boolean useShared;
int canvasWidth;
int canvasHeight;
- private float boundsRadius = 2f;
+ private final float boundsRadius = 2f;
private float viewDistance;
private float viewDistanceFactor = 1.0f;
private float xAxisRotation;
private float yAxisRotation;
- private float viewFovDegrees = 15f;
+ private final float viewFovDegrees = 15f;
// vertex array objects cannot be shared across open gl canvases;
//
// However, display lists can be shared across GLCanvas instances (if those canvases are initialized with the same GLContext),
- // including a display list created in one context that uses a VAO.
- private int [] vertexArrayObjects = {0};
+ // including a display list created in one context that uses a VAO.
+ private final int [] vertexArrayObjects = {0};
// Buffer objects can be shared across canvas instances, if those canvases are initialized with the same GLContext.
// If we run with sharedBufferObjects true, then the tests will use these shared buffer objects.
// If we run with sharedBufferObjects false, then each event listener allocates its own buffer objects.
- private int [] privateVertexBufferObjects = {0};
- private int [] privateIndexBufferObjects = {0};
+ private final int [] privateVertexBufferObjects = {0};
+ private final int [] privateIndexBufferObjects = {0};
private FloatBuffer privateVertexBuffer;
private IntBuffer privateIndexBuffer;
-
+
TwoTriangles (int canvasWidth, int canvasHeight, boolean useShared) {
// instanceNum = instanceCounter++;
this.canvasWidth = canvasWidth;
@@ -205,7 +205,7 @@ public class TestSharedContextNewtAWTBug523 extends UITestCase {
gl2.glBindVertexArray(vertexArrayObjects[0]);
- // use either the shared or private vertex buffers, as
+ // use either the shared or private vertex buffers, as
int [] vertexBufferObjects;
int [] indexBufferObjects;
FloatBuffer vertexBuffer;
@@ -222,7 +222,7 @@ public class TestSharedContextNewtAWTBug523 extends UITestCase {
vertexBuffer = privateVertexBuffer;
indexBuffer = privateIndexBuffer;
}
-
+
// if buffer sharing is enabled, then the first of the two event listeners to be
// initialized will allocate the buffers, and the other will re-use the allocated one
if (vertexBufferObjects[0] == 0) {
@@ -241,7 +241,7 @@ public class TestSharedContextNewtAWTBug523 extends UITestCase {
gl2.glBindBuffer(GL2.GL_ARRAY_BUFFER, vertexBufferObjects[0]);
gl2.glBufferData(GL2.GL_ARRAY_BUFFER, vertexBuffer.capacity() * Buffers.SIZEOF_FLOAT, vertexBuffer, GL2.GL_STATIC_DRAW);
}
-
+
// A check in the case that buffer sharing is enabled but context sharing is not enabled -- in that
// case, the buffer objects are not shareable, and the blue triangle cannot be rendereds.
// Furthermore, although the calls to bind and draw elements do not cause an error from glGetError
@@ -268,7 +268,7 @@ public class TestSharedContextNewtAWTBug523 extends UITestCase {
gl2.glBufferData(GL2.GL_ELEMENT_ARRAY_BUFFER, indexBuffer.capacity() * Buffers.SIZEOF_INT, indexBuffer, GL2.GL_STATIC_DRAW);
}
- // again, a check in the case that buffer sharing is enabled but context sharing is not enabled
+ // again, a check in the case that buffer sharing is enabled but context sharing is not enabled
if (gl2.glIsBuffer(indexBufferObjects[0])) {
gl2.glBindBuffer(GL2.GL_ELEMENT_ARRAY_BUFFER, indexBufferObjects[0]);
}
@@ -298,9 +298,9 @@ public class TestSharedContextNewtAWTBug523 extends UITestCase {
vertexArrayObjects[0] = 0;
logAnyErrorCodes(gl2, "display");
- // release shared resources
+ // release shared resources
if (initializationCounter == 0 || !useShared) {
- // use either the shared or private vertex buffers, as
+ // use either the shared or private vertex buffers, as
int [] vertexBufferObjects;
int [] indexBufferObjects;
if (useShared) {
@@ -395,7 +395,7 @@ public class TestSharedContextNewtAWTBug523 extends UITestCase {
// synchronizing to deal with potential liveness issues if the data is intialized from one
// thread and used on another
boolean vaoBound = false;
- // use either the shared or private vertex buffers, as
+ // use either the shared or private vertex buffers, as
int [] vertexBufferObjects;
int [] indexBufferObjects;
synchronized (this) {
@@ -407,20 +407,20 @@ public class TestSharedContextNewtAWTBug523 extends UITestCase {
indexBufferObjects = privateIndexBufferObjects;
}
} // synchronized (this)
-
+
// A check in the case that buffer sharing is enabled but context sharing is not enabled -- in that
// case, the buffer objects are not shareable, and the blue triangle cannot be rendereds.
// Furthermore, although the calls to bind and draw elements do not cause an error from glGetError
// when this check is removed, true blue triangle is not rendered anyways, and more importantly,
// I found that with my system glDrawElements causes a runtime exception 50% of the time. Executing the binds
// to unshareable buffers sets up glDrawElements for unpredictable crashes -- sometimes it does, sometimes not.
- if (gl2.glIsVertexArray(vertexArrayObjects[0]) &&
+ if (gl2.glIsVertexArray(vertexArrayObjects[0]) &&
gl2.glIsBuffer(indexBufferObjects[0]) && gl2.glIsBuffer(vertexBufferObjects[0])) {
gl2.glBindVertexArray(vertexArrayObjects[0]);
gl2.glBindBuffer(GL2.GL_ELEMENT_ARRAY_BUFFER, indexBufferObjects[0]);
vaoBound = true;
}
-
+
logAnyErrorCodes(gl2, "drawTwoTriangles");
if (vaoBound) {
@@ -428,12 +428,12 @@ public class TestSharedContextNewtAWTBug523 extends UITestCase {
gl2.glDrawElements(GL2.GL_TRIANGLES, 3, GL2.GL_UNSIGNED_INT, 0);
gl2.glBindVertexArray(0);
gl2.glBindBuffer(GL2.GL_ELEMENT_ARRAY_BUFFER, 0);
- }
+ }
}
public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {
}
-
+
} // inner class TwoTriangles
public static void logAnyErrorCodes(GL2 gl2, String prefix) {
@@ -522,7 +522,7 @@ public class TestSharedContextNewtAWTBug523 extends UITestCase {
glCapabilities.setNumSamples(4);
final GLOffscreenAutoDrawable sharedDrawable;
- final GLContext sharedContext;
+ final GLContext sharedContext;
if(shareContext) {
sharedDrawable = initShared(glCapabilities);
sharedContext = sharedDrawable.getContext();
@@ -530,7 +530,7 @@ public class TestSharedContextNewtAWTBug523 extends UITestCase {
sharedDrawable = null;
sharedContext = null;
}
-
+
final TwoTriangles eventListener1 = new TwoTriangles(640, 480, shareContext);
final TwoTriangles eventListener2 = new TwoTriangles(320, 480, shareContext);
@@ -541,7 +541,9 @@ public class TestSharedContextNewtAWTBug523 extends UITestCase {
if (useNewt) {
GLWindow glWindow1 = GLWindow.create(glCapabilities);
- glWindow1.setSharedContext(sharedContext);
+ if(shareContext) {
+ glWindow1.setSharedContext(sharedContext);
+ }
NewtCanvasAWT newtCanvasAWT1 = new NewtCanvasAWT(glWindow1);
newtCanvasAWT1.setPreferredSize(new Dimension(eventListener1.canvasWidth, eventListener1.canvasHeight));
glWindow1.addGLEventListener(eventListener1);
@@ -563,8 +565,10 @@ public class TestSharedContextNewtAWTBug523 extends UITestCase {
final GLCanvas canvas2;
if (shareContext) {
- canvas1 = new GLCanvas(glCapabilities, sharedContext);
- canvas2 = new GLCanvas(glCapabilities, sharedContext);
+ canvas1 = new GLCanvas(glCapabilities);
+ canvas1.setSharedContext(sharedContext);
+ canvas2 = new GLCanvas(glCapabilities);
+ canvas2.setSharedContext(sharedContext);
} else {
canvas1 = new GLCanvas(glCapabilities);
canvas2 = new GLCanvas(glCapabilities);
@@ -622,8 +626,8 @@ public class TestSharedContextNewtAWTBug523 extends UITestCase {
viewDistanceFactorSlider.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
- eventListener1.setViewDistanceFactor((float) viewDistanceFactorSlider.getValue() / 10.0f);
- eventListener2.setViewDistanceFactor((float) viewDistanceFactorSlider.getValue() / 10.0f);
+ eventListener1.setViewDistanceFactor(viewDistanceFactorSlider.getValue() / 10.0f);
+ eventListener2.setViewDistanceFactor(viewDistanceFactorSlider.getValue() / 10.0f);
}
});
JLabel viewDistanceFactorLabel = new JLabel("View Distance Factor");
@@ -753,7 +757,7 @@ public class TestSharedContextNewtAWTBug523 extends UITestCase {
}
Assert.assertEquals(true, disposalSuccesses == 2);
-
+
releaseShared(sharedDrawable);
}
@@ -771,9 +775,9 @@ public class TestSharedContextNewtAWTBug523 extends UITestCase {
if (++i < args.length) {
durationPerTest = atoi(args[i]);
}
- }
+ }
}
-
+
String testname = TestSharedContextNewtAWTBug523.class.getName();
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(new String[] {
testname,
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES1NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES1NEWT.java
index 19089e165..05d060f0b 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES1NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES1NEWT.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,24 +20,28 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.opengl.test.junit.jogl.acore;
import com.jogamp.newt.opengl.GLWindow;
import javax.media.nativewindow.util.InsetsImmutable;
+import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLDrawable;
import javax.media.opengl.GLDrawableFactory;
-import javax.media.opengl.GLOffscreenAutoDrawable;
import javax.media.opengl.GLProfile;
-import com.jogamp.opengl.util.Animator;
+import com.jogamp.opengl.GLAutoDrawableDelegate;
+import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.test.junit.jogl.demos.es1.GearsES1;
@@ -47,12 +51,30 @@ import org.junit.Test;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
+/**
+ * Sharing the VBO of 3 GearsES1 instances, each in their own GLWindow.
+ * <p>
+ * This is achieved by creating a <i>master</i> GLContext to an offscreen invisible GLAutoDrawable,
+ * which is then shared by the 3 GLContext of the three GLWindow instances.
+ * </p>
+ * <p>
+ * The original VBO is created by attaching a GearsES1 instance to
+ * the <i>master</i> GLAutoDrawable and initializing it.
+ * </p>
+ * <p>
+ * Above method allows random creation of all GLWindow instances.
+ * </p>
+ * <p>
+ * One animator is being used, hence the GLWindow, GLDrawable and GLContext
+ * creation of all 3 GLWindows is sequential.
+ * </p>
+ */
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestSharedContextVBOES1NEWT extends UITestCase {
static GLProfile glp;
static GLCapabilities caps;
static int width, height;
- GLOffscreenAutoDrawable sharedDrawable;
+ GLAutoDrawable sharedDrawable;
GearsES1 sharedGears;
@BeforeClass
@@ -69,14 +91,22 @@ public class TestSharedContextVBOES1NEWT extends UITestCase {
}
}
- private void initShared() {
- sharedDrawable = GLDrawableFactory.getFactory(glp).createOffscreenAutoDrawable(null, caps, null, width, height, null);
+ private void initShared() throws InterruptedException {
+ GLDrawable dummyDrawable = GLDrawableFactory.getFactory(glp).createDummyDrawable(null, true /* createNewDevice */, caps.getGLProfile());
+ dummyDrawable.setRealized(true);
+ sharedDrawable = new GLAutoDrawableDelegate(dummyDrawable, null, null, true /*ownDevice*/, null) { };
Assert.assertNotNull(sharedDrawable);
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(sharedDrawable, true));
+
sharedGears = new GearsES1();
Assert.assertNotNull(sharedGears);
sharedDrawable.addGLEventListener(sharedGears);
// init and render one frame, which will setup the Gears display lists
sharedDrawable.display();
+ final GLContext ctxM = sharedDrawable.getContext();
+ Assert.assertTrue("Master ctx not created", AWTRobotUtil.waitForCreated(ctxM, true));
+ Assert.assertTrue("Master Ctx is shared before shared creation", !ctxM.isShared());
+ Assert.assertTrue("Master Gears is shared", !sharedGears.usesSharedGears());
}
private void releaseShared() {
@@ -87,6 +117,7 @@ public class TestSharedContextVBOES1NEWT extends UITestCase {
protected GLWindow runTestGL(Animator animator, int x, int y, boolean useShared, boolean vsync) throws InterruptedException {
GLWindow glWindow = GLWindow.create(caps);
Assert.assertNotNull(glWindow);
+ glWindow.setPosition(x, y);
glWindow.setTitle("Shared Gears NEWT Test: "+x+"/"+y+" shared "+useShared);
if(useShared) {
glWindow.setSharedContext(sharedDrawable.getContext());
@@ -96,7 +127,7 @@ public class TestSharedContextVBOES1NEWT extends UITestCase {
GearsES1 gears = new GearsES1(vsync ? 1 : 0);
if(useShared) {
- gears.setGears(sharedGears.getGear1(), sharedGears.getGear2(), sharedGears.getGear3());
+ gears.setSharedGearsObjects(sharedGears.getGear1(), sharedGears.getGear2(), sharedGears.getGear3());
}
glWindow.addGLEventListener(gears);
@@ -105,9 +136,17 @@ public class TestSharedContextVBOES1NEWT extends UITestCase {
glWindow.setVisible(true);
Assert.assertTrue(AWTRobotUtil.waitForRealized(glWindow, true));
Assert.assertTrue(AWTRobotUtil.waitForVisible(glWindow, true));
-
- glWindow.setPosition(x, y);
-
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(glWindow.getContext(), true));
+
+ System.err.println("Master Context: ");
+ MiscUtils.dumpSharedGLContext(sharedDrawable.getContext());
+ System.err.println("New Context: ");
+ MiscUtils.dumpSharedGLContext(glWindow.getContext());
+ if( useShared ) {
+ Assert.assertEquals("Master Context not shared as expected", true, sharedDrawable.getContext().isShared());
+ }
+ Assert.assertEquals("New Context not shared as expected", useShared, glWindow.getContext().isShared());
+ Assert.assertEquals("Gears is not shared as expected", useShared, gears.usesSharedGears());
return glWindow;
}
@@ -117,11 +156,11 @@ public class TestSharedContextVBOES1NEWT extends UITestCase {
Animator animator = new Animator();
GLWindow f1 = runTestGL(animator, 0, 0, true, false);
InsetsImmutable insets = f1.getInsets();
- GLWindow f2 = runTestGL(animator, f1.getX()+width+insets.getTotalWidth(),
+ GLWindow f2 = runTestGL(animator, f1.getX()+width+insets.getTotalWidth(),
f1.getY()+0, true, false);
- GLWindow f3 = runTestGL(animator, f1.getX()+0,
- f1.getY()+height+insets.getTotalHeight(), false, true);
- animator.setUpdateFPSFrames(1, null);
+ GLWindow f3 = runTestGL(animator, f1.getX()+0,
+ f1.getY()+height+insets.getTotalHeight(), false, true);
+ animator.setUpdateFPSFrames(1, null);
animator.start();
while(animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
Thread.sleep(100);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java
new file mode 100644
index 000000000..d3b5042fc
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java
@@ -0,0 +1,321 @@
+/**
+ * Copyright 2010 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;
+
+import java.awt.Frame;
+import java.lang.reflect.InvocationTargetException;
+import java.util.List;
+
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLProfile;
+import javax.media.opengl.awt.GLCanvas;
+
+import com.jogamp.opengl.util.Animator;
+import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.FixMethodOrder;
+import org.junit.runners.MethodSorters;
+
+/**
+ * Sharing the VBO of 3 GearsES2 instances, each in their own GLCanvas.
+ * <p>
+ * This is achieved by using the 1st GLCanvas as the <i>master</i>
+ * and using the build-in blocking mechanism to postpone creation
+ * of the 2nd and 3rd GLCanvas until the 1st GLCanvas's GLContext becomes created.
+ * </p>
+ * <p>
+ * Above method allows random creation of the 1st GLCanvas, which triggers
+ * creation of the <i>dependent</i> other GLCanvas sharing it's GLContext.
+ * </p>
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestSharedContextVBOES2AWT3 extends UITestCase {
+ static GLProfile glp;
+ static GLCapabilities caps;
+ static int width, height;
+
+ @BeforeClass
+ public static void initClass() {
+ if(GLProfile.isAvailable(GLProfile.GL2ES2)) {
+ glp = GLProfile.get(GLProfile.GL2ES2);
+ Assert.assertNotNull(glp);
+ caps = new GLCapabilities(glp);
+ Assert.assertNotNull(caps);
+ width = 256;
+ height = 256;
+ } else {
+ setTestSupported(false);
+ }
+ }
+
+ protected GLCanvas createGLCanvas(final Frame frame, int x, int y, GearsES2 gears) throws InterruptedException {
+ final GLCanvas glCanvas = new GLCanvas(caps);
+ Assert.assertNotNull(glCanvas);
+ glCanvas.addGLEventListener(gears);
+ frame.add(glCanvas);
+ frame.setLocation(x, y);
+ frame.setSize(width, height);
+ frame.setTitle("Shared Gears NEWT Test: "+x+"/"+y+" shared true");
+ return glCanvas;
+ }
+
+ @Test
+ public void test01SyncedCommonAnimatorSharedOffscreen() throws InterruptedException, InvocationTargetException {
+ final Frame f1 = new Frame();
+ final Animator animator = new Animator();
+ final GearsES2 g1 = new GearsES2(0);
+ final GLCanvas c1 = createGLCanvas(f1, 0, 0, g1);
+ animator.add(c1);
+
+ final Frame f2 = new Frame();
+ final GearsES2 g2 = new GearsES2(0);
+ g2.setSharedGears(g1);
+ final GLCanvas c2 = createGLCanvas(f2, f1.getX()+width,
+ f1.getY()+0, g2);
+ c2.setSharedAutoDrawable(c1);
+ animator.add(c2);
+
+ final Frame f3 = new Frame();
+ final GearsES2 g3 = new GearsES2(0);
+ g3.setSharedGears(g1);
+ final GLCanvas c3 = createGLCanvas(f3, f1.getX()+0,
+ f1.getY()+height, g3);
+ c3.setSharedAutoDrawable(c1);
+ animator.add(c3);
+
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ f2.setVisible(true); // shall wait until f1 is ready
+ f1.setVisible(true); // master ..
+ f3.setVisible(true); // shall wait until f1 is ready
+ } } );
+ animator.start(); // kicks off GLContext .. and hence gears of f2 + f3 completion
+
+ Thread.sleep(1000/60*10); // wait ~10 frames giving a chance to create (blocking until master share is valid)
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(c1, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(c1, true));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(c1.getContext(), true));
+ Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true));
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(c2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(c2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(c2.getContext(), true));
+ Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true));
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(c3, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(c3, true));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(c3.getContext(), true));
+ Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true));
+
+ final GLContext ctx1 = c1.getContext();
+ final GLContext ctx2 = c2.getContext();
+ final GLContext ctx3 = c3.getContext();
+ {
+ final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
+ final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
+ final List<GLContext> ctx3Shares = ctx3.getCreatedShares();
+ System.err.println("XXX-C-3.1:");
+ MiscUtils.dumpSharedGLContext(ctx1);
+ System.err.println("XXX-C-3.2:");
+ MiscUtils.dumpSharedGLContext(ctx2);
+ System.err.println("XXX-C-3.3:");
+ MiscUtils.dumpSharedGLContext(ctx3);
+
+ Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
+ Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
+ Assert.assertTrue("Ctx3 is not shared", ctx3.isShared());
+ Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size());
+ Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size());
+ Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size());
+ }
+
+ Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears());
+ Assert.assertTrue("Gears2 is not shared", g2.usesSharedGears());
+ Assert.assertTrue("Gears3 is not shared", g3.usesSharedGears());
+
+ try {
+ Thread.sleep(duration);
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ animator.stop();
+
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ try {
+ f1.dispose();
+ f2.dispose();
+ f3.dispose();
+ } catch (Throwable t) {
+ throw new RuntimeException(t);
+ }
+ }});
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(c1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(c2, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(c3, false));
+ }
+
+ @Test
+ public void test02AsyncEachWithAnimatorSharedOffscreen() throws InterruptedException, InvocationTargetException {
+ final Frame f1 = new Frame();
+ final Animator a1 = new Animator();
+ final GearsES2 g1 = new GearsES2(0);
+ final GLCanvas c1 = createGLCanvas(f1, 0, 0, g1);
+ a1.add(c1);
+ a1.start();
+ // f1.setVisible(true); // we do this post f2 .. to test pending creation!
+
+ final Frame f2 = new Frame();
+ final Animator a2 = new Animator();
+ final GearsES2 g2 = new GearsES2(0);
+ g2.setSharedGears(g1);
+ final GLCanvas c2 = createGLCanvas(f2, f1.getX()+width, f1.getY()+0, g2);
+ c2.setSharedAutoDrawable(c1);
+ a2.add(c2);
+ a2.start();
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ f2.setVisible(true);
+ } } );
+
+ Thread.sleep(200); // wait a while ..
+
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ f1.setVisible(true); // test pending creation of f2
+ } } );
+
+ final Frame f3 = new Frame();
+ final Animator a3 = new Animator();
+ final GearsES2 g3 = new GearsES2(0);
+ g3.setSharedGears(g1);
+ final GLCanvas c3 = createGLCanvas(f3, f1.getX()+0, f1.getY()+height, g3);
+ c3.setSharedAutoDrawable(c1);
+ a3.add(c3);
+ a3.start();
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ f3.setVisible(true);
+ } } );
+
+ Thread.sleep(1000/60*10); // wait ~10 frames giving a chance to create (blocking until master share is valid)
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(c1, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(c1, true));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(c1.getContext(), true));
+ Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true));
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(c2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(c2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(c2.getContext(), true));
+ Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true));
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(c3, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(c3, true));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(c3.getContext(), true));
+ Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true));
+
+ final GLContext ctx1 = c1.getContext();
+ final GLContext ctx2 = c2.getContext();
+ final GLContext ctx3 = c3.getContext();
+ {
+ final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
+ final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
+ final List<GLContext> ctx3Shares = ctx3.getCreatedShares();
+ System.err.println("XXX-C-3.1:");
+ MiscUtils.dumpSharedGLContext(ctx1);
+ System.err.println("XXX-C-3.2:");
+ MiscUtils.dumpSharedGLContext(ctx2);
+ System.err.println("XXX-C-3.3:");
+ MiscUtils.dumpSharedGLContext(ctx3);
+
+ Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
+ Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
+ Assert.assertTrue("Ctx3 is not shared", ctx3.isShared());
+ Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size());
+ Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size());
+ Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size());
+ }
+
+ Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears());
+ Assert.assertTrue("Gears2 is not shared", g2.usesSharedGears());
+ Assert.assertTrue("Gears3 is not shared", g3.usesSharedGears());
+
+ try {
+ Thread.sleep(duration);
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ a1.stop();
+ a2.stop();
+ a3.stop();
+
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ try {
+ f1.dispose();
+ f2.dispose();
+ f3.dispose();
+ } catch (Throwable t) {
+ throw new RuntimeException(t);
+ }
+ }});
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(c1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(c2, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(c3, false));
+ }
+
+ static long duration = 1000; // ms
+
+ public static void main(String args[]) {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ try {
+ duration = Integer.parseInt(args[i]);
+ } catch (Exception ex) { ex.printStackTrace(); }
+ }
+ }
+ /**
+ 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(TestSharedContextVBOES2AWT3.class.getName());
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT0.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT0.java
new file mode 100644
index 000000000..76ae5c69d
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT0.java
@@ -0,0 +1,270 @@
+/**
+ * Copyright 2010 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;
+
+import java.util.List;
+
+import com.jogamp.newt.opengl.GLWindow;
+
+import javax.media.nativewindow.util.InsetsImmutable;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLProfile;
+
+import com.jogamp.opengl.util.Animator;
+import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.FixMethodOrder;
+import org.junit.runners.MethodSorters;
+
+/**
+ * Sharing the VBO of 3 GearsES2 instances, each in their own GLWindow.
+ * <p>
+ * This is achieved by relying on the sequential creation
+ * of the 3 GLWindows with their GLDrawable and GLContext.
+ * </p>
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestSharedContextVBOES2NEWT0 extends UITestCase {
+ static GLProfile glp;
+ static GLCapabilities caps;
+ static int width, height;
+
+ @BeforeClass
+ public static void initClass() {
+ if(GLProfile.isAvailable(GLProfile.GL2ES2)) {
+ glp = GLProfile.get(GLProfile.GL2ES2);
+ Assert.assertNotNull(glp);
+ caps = new GLCapabilities(glp);
+ Assert.assertNotNull(caps);
+ width = 256;
+ height = 256;
+ } else {
+ setTestSupported(false);
+ }
+ }
+
+ protected GLWindow runTestGL(Animator animator, int x, int y, GearsES2 gears, GLContext sharedContext) throws InterruptedException {
+ final boolean useShared = null != sharedContext;
+ GLWindow glWindow = GLWindow.create(caps);
+ Assert.assertNotNull(glWindow);
+ glWindow.setPosition(x, y);
+ glWindow.setTitle("Shared Gears NEWT Test: "+x+"/"+y+" shared "+useShared);
+ if(useShared) {
+ glWindow.setSharedContext(sharedContext);
+ }
+ glWindow.setSize(width, height);
+ glWindow.addGLEventListener(gears);
+
+ animator.add(glWindow);
+ glWindow.setVisible(true);
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(glWindow, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(glWindow, true));
+ glWindow.display();
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(glWindow.getContext(), true));
+ Assert.assertTrue("Gears not initialized", gears.waitForInit(true));
+
+ return glWindow;
+ }
+
+ @Test
+ public void testCommonAnimatorShared() throws InterruptedException {
+ final Animator animator = new Animator();
+
+ //
+ // 1st
+ //
+ final GearsES2 g1 = new GearsES2(0);
+ final GLWindow f1 = runTestGL(animator, 0, 0, g1, null);
+ final GLContext ctx1 = f1.getContext();
+ Assert.assertTrue("Ctx is shared before shared creation", !ctx1.isShared());
+ final InsetsImmutable insets = f1.getInsets();
+
+ System.err.println("XXX-C-2.1:");
+ MiscUtils.dumpSharedGLContext(ctx1);
+
+ //
+ // 2nd
+ //
+ final GearsES2 g2 = new GearsES2(0);
+ g2.setSharedGearsObjects(g1.getGear1(), g1.getGear2(), g1.getGear3());
+ final GLWindow f2 = runTestGL(animator, f1.getX()+width+insets.getTotalWidth(),
+ f1.getY()+0, g2, f1.getContext());
+ final GLContext ctx2 = f2.getContext();
+ Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
+ Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
+
+ {
+ final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
+ final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
+ System.err.println("XXX-C-2.1:");
+ MiscUtils.dumpSharedGLContext(ctx1);
+ System.err.println("XXX-C-2.2:");
+ MiscUtils.dumpSharedGLContext(ctx2);
+
+ Assert.assertEquals("Ctx1 has unexpected number of created shares", 1, ctx1Shares.size());
+ Assert.assertEquals("Ctx2 has unexpected number of created shares", 1, ctx2Shares.size());
+ }
+
+ //
+ // 3rd
+ //
+ final GearsES2 g3 = new GearsES2(0);
+ g3.setSharedGearsObjects(g1.getGear1(), g1.getGear2(), g1.getGear3());
+ final GLWindow f3 = runTestGL(animator, f1.getX()+0,
+ f1.getY()+height+insets.getTotalHeight(), g3, f1.getContext());
+
+ final GLContext ctx3 = f3.getContext();
+ Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
+ Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
+ Assert.assertTrue("Ctx3 is not shared", ctx3.isShared());
+
+ {
+ final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
+ final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
+ final List<GLContext> ctx3Shares = ctx3.getCreatedShares();
+ System.err.println("XXX-C-3.1:");
+ MiscUtils.dumpSharedGLContext(ctx1);
+ System.err.println("XXX-C-3.2:");
+ MiscUtils.dumpSharedGLContext(ctx2);
+ System.err.println("XXX-C-3.3:");
+ MiscUtils.dumpSharedGLContext(ctx3);
+
+ Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size());
+ Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size());
+ Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size());
+ }
+
+ Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears());
+ Assert.assertTrue("Gears2 is not shared", g2.usesSharedGears());
+ Assert.assertTrue("Gears3 is not shared", g3.usesSharedGears());
+
+ animator.start();
+
+ try {
+ Thread.sleep(duration);
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ animator.stop();
+
+ f1.destroy();
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), false));
+ {
+ final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
+ final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
+ final List<GLContext> ctx3Shares = ctx3.getCreatedShares();
+ System.err.println("XXX-D-2.1:");
+ MiscUtils.dumpSharedGLContext(ctx1);
+ System.err.println("XXX-D-2.2:");
+ MiscUtils.dumpSharedGLContext(ctx2);
+ System.err.println("XXX-D-2.3:");
+ MiscUtils.dumpSharedGLContext(ctx3);
+
+ Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
+ Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
+ Assert.assertTrue("Ctx3 is not shared", ctx3.isShared());
+ Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size());
+ Assert.assertEquals("Ctx2 has unexpected number of created shares", 1, ctx2Shares.size());
+ Assert.assertEquals("Ctx3 has unexpected number of created shares", 1, ctx3Shares.size());
+ }
+
+ f2.destroy();
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), false));
+ {
+ final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
+ final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
+ final List<GLContext> ctx3Shares = ctx3.getCreatedShares();
+ System.err.println("XXX-D-1.1:");
+ MiscUtils.dumpSharedGLContext(ctx1);
+ System.err.println("XXX-D-1.2:");
+ MiscUtils.dumpSharedGLContext(ctx2);
+ System.err.println("XXX-D-1.3:");
+ MiscUtils.dumpSharedGLContext(ctx3);
+
+ Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
+ Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
+ Assert.assertTrue("Ctx3 is not shared", ctx3.isShared());
+ Assert.assertEquals("Ctx1 has unexpected number of created shares", 1, ctx1Shares.size());
+ Assert.assertEquals("Ctx2 has unexpected number of created shares", 1, ctx2Shares.size());
+ Assert.assertEquals("Ctx3 has unexpected number of created shares", 0, ctx3Shares.size());
+ }
+
+ f3.destroy();
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), false));
+ {
+ final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
+ final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
+ final List<GLContext> ctx3Shares = ctx3.getCreatedShares();
+ System.err.println("XXX-D-0.1:");
+ MiscUtils.dumpSharedGLContext(ctx1);
+ System.err.println("XXX-D-0.2:");
+ MiscUtils.dumpSharedGLContext(ctx2);
+ System.err.println("XXX-D-0.3:");
+ MiscUtils.dumpSharedGLContext(ctx3);
+
+ Assert.assertTrue("Ctx1 is shared", !ctx1.isShared());
+ Assert.assertTrue("Ctx2 is shared", !ctx2.isShared());
+ Assert.assertTrue("Ctx3 is shared", !ctx3.isShared());
+ Assert.assertEquals("Ctx1 has unexpected number of created shares", 0, ctx1Shares.size());
+ Assert.assertEquals("Ctx2 has unexpected number of created shares", 0, ctx2Shares.size());
+ Assert.assertEquals("Ctx3 has unexpected number of created shares", 0, ctx3Shares.size());
+ }
+ }
+
+ static long duration = 1000; // ms
+
+ public static void main(String args[]) {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ try {
+ duration = Integer.parseInt(args[i]);
+ } catch (Exception ex) { ex.printStackTrace(); }
+ }
+ }
+ /**
+ 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(TestSharedContextVBOES2NEWT0.class.getName());
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT1.java
index 361ae597c..e3b1fe396 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT1.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,26 +20,28 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.opengl.test.junit.jogl.acore;
-import com.jogamp.common.os.Platform;
-import com.jogamp.common.util.VersionNumber;
import com.jogamp.newt.opengl.GLWindow;
import javax.media.nativewindow.util.InsetsImmutable;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLDrawable;
import javax.media.opengl.GLDrawableFactory;
import javax.media.opengl.GLProfile;
-import com.jogamp.opengl.util.Animator;
+import com.jogamp.opengl.GLAutoDrawableDelegate;
+import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
@@ -49,8 +51,34 @@ import org.junit.Test;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
+/**
+ * Sharing the VBO of 3 GearsES2 instances, each in their own GLWindow.
+ * <p>
+ * This is achieved by creating a <i>master</i> GLContext to an offscreen invisible GLAutoDrawable,
+ * which is then shared by the 3 GLContext of the three GLWindow instances.
+ * </p>
+ * <p>
+ * The original VBO is created by attaching a GearsES2 instance to
+ * the <i>master</i> GLAutoDrawable and initializing it.
+ * </p>
+ * <p>
+ * Above method allows random creation of all GLWindow instances.
+ * </p>
+ * <p>
+ * One tests uses only one animator, where the GLWindow, GLDrawable and GLContext
+ * creation of all 3 GLWindows is sequential.
+ * </p>
+ * <p>
+ * Another tests uses 3 animator, one for each GLWindow,
+ * where the GLWindow, GLDrawable and GLContext creation
+ * of all 3 GLWindows is <i>random</i>.
+ * This fact benefits from the <i>master</i> GLContext/GLAutoDrawable,
+ * since it is guaranteed it exist and is realized at the time of the <i>shared</i>
+ * GLWindow creation.
+ * </p>
+ */
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestSharedContextVBOES2NEWT extends UITestCase {
+public class TestSharedContextVBOES2NEWT1 extends UITestCase {
static GLProfile glp;
static GLCapabilities caps;
static int width, height;
@@ -71,22 +99,31 @@ public class TestSharedContextVBOES2NEWT extends UITestCase {
}
}
- private void initShared(boolean onscreen) {
+ private void initShared(boolean onscreen) throws InterruptedException {
if(onscreen) {
GLWindow glWindow = GLWindow.create(caps);
Assert.assertNotNull(glWindow);
glWindow.setSize(width, height);
glWindow.setVisible(true);
sharedDrawable = glWindow;
- } else {
- sharedDrawable = GLDrawableFactory.getFactory(glp).createOffscreenAutoDrawable(null, caps, null, width, height, null);
+ } else {
+ GLDrawable dummyDrawable = GLDrawableFactory.getFactory(glp).createDummyDrawable(null, true /* createNewDevice */, caps.getGLProfile());
+ dummyDrawable.setRealized(true);
+ sharedDrawable = new GLAutoDrawableDelegate(dummyDrawable, null, null, true /*ownDevice*/, null) { };
}
Assert.assertNotNull(sharedDrawable);
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(sharedDrawable, true));
+
sharedGears = new GearsES2();
Assert.assertNotNull(sharedGears);
sharedDrawable.addGLEventListener(sharedGears);
// init and render one frame, which will setup the Gears display lists
sharedDrawable.display();
+ final GLContext ctxM = sharedDrawable.getContext();
+ Assert.assertTrue("Master ctx not created", AWTRobotUtil.waitForCreated(ctxM, true));
+ Assert.assertTrue("Master Ctx is shared before shared creation", !ctxM.isShared());
+ Assert.assertTrue("Master Gears not initialized", sharedGears.waitForInit(true));
+ Assert.assertTrue("Master Gears is shared", !sharedGears.usesSharedGears());
}
private void releaseShared() {
@@ -98,6 +135,7 @@ public class TestSharedContextVBOES2NEWT extends UITestCase {
protected GLWindow runTestGL(Animator animator, int x, int y, boolean useShared, boolean vsync) throws InterruptedException {
GLWindow glWindow = GLWindow.create(caps);
Assert.assertNotNull(glWindow);
+ glWindow.setPosition(x, y);
glWindow.setTitle("Shared Gears NEWT Test: "+x+"/"+y+" shared "+useShared);
if(useShared) {
glWindow.setSharedContext(sharedDrawable.getContext());
@@ -107,30 +145,41 @@ public class TestSharedContextVBOES2NEWT extends UITestCase {
GearsES2 gears = new GearsES2(vsync ? 1 : 0);
if(useShared) {
- gears.setGears(sharedGears.getGear1(), sharedGears.getGear2(), sharedGears.getGear3());
+ gears.setSharedGearsObjects(sharedGears.getGear1(), sharedGears.getGear2(), sharedGears.getGear3());
}
glWindow.addGLEventListener(gears);
animator.add(glWindow);
- animator.start();
+ animator.start();
glWindow.setVisible(true);
Assert.assertTrue(AWTRobotUtil.waitForRealized(glWindow, true));
Assert.assertTrue(AWTRobotUtil.waitForVisible(glWindow, true));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(glWindow.getContext(), true));
- glWindow.setPosition(x, y);
+ System.err.println("Master Context: ");
+ MiscUtils.dumpSharedGLContext(sharedDrawable.getContext());
+ System.err.println("New Context: ");
+ MiscUtils.dumpSharedGLContext(glWindow.getContext());
+ if( useShared ) {
+ Assert.assertEquals("Master Context not shared as expected", true, sharedDrawable.getContext().isShared());
+ }
+ Assert.assertEquals("New Context not shared as expected", useShared, glWindow.getContext().isShared());
+
+ Assert.assertTrue("Gears not initialized", sharedGears.waitForInit(true));
+ Assert.assertEquals("Gears is not shared as expected", useShared, gears.usesSharedGears());
return glWindow;
}
@Test
- public void testCommonAnimatorSharedOnscreen() throws InterruptedException {
+ public void test01CommonAnimatorSharedOnscreen() throws InterruptedException {
initShared(true);
Animator animator = new Animator();
GLWindow f1 = runTestGL(animator, 0, 0, true, false);
InsetsImmutable insets = f1.getInsets();
- GLWindow f2 = runTestGL(animator, f1.getX()+width+insets.getTotalWidth(),
+ GLWindow f2 = runTestGL(animator, f1.getX()+width+insets.getTotalWidth(),
f1.getY()+0, true, false);
- GLWindow f3 = runTestGL(animator, f1.getX()+0,
+ GLWindow f3 = runTestGL(animator, f1.getX()+0,
f1.getY()+height+insets.getTotalHeight(), true, false);
try {
Thread.sleep(duration);
@@ -144,23 +193,26 @@ public class TestSharedContextVBOES2NEWT extends UITestCase {
f3.destroy();
Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false));
Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), false));
Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false));
Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), false));
Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false));
Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), false));
releaseShared();
}
@Test
- public void testCommonAnimatorSharedOffscreen() throws InterruptedException {
+ public void test02CommonAnimatorSharedOffscreen() throws InterruptedException {
initShared(false);
Animator animator = new Animator();
GLWindow f1 = runTestGL(animator, 0, 0, true, false);
InsetsImmutable insets = f1.getInsets();
- GLWindow f2 = runTestGL(animator, f1.getX()+width+insets.getTotalWidth(),
+ GLWindow f2 = runTestGL(animator, f1.getX()+width+insets.getTotalWidth(),
f1.getY()+0, true, false);
- GLWindow f3 = runTestGL(animator, f1.getX()+0,
+ GLWindow f3 = runTestGL(animator, f1.getX()+0,
f1.getY()+height+insets.getTotalHeight(), true, false);
try {
Thread.sleep(duration);
@@ -174,33 +226,28 @@ public class TestSharedContextVBOES2NEWT extends UITestCase {
f3.destroy();
Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false));
Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), false));
Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false));
Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), false));
Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false));
Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), false));
releaseShared();
}
-
+
@Test
- public void testEachWithAnimatorSharedOffscreen() throws InterruptedException {
- VersionNumber osx1070 = new VersionNumber(10,7,0);
- if( Platform.getOSType() == Platform.OSType.MACOS && Platform.getOSVersionNumber().compareTo(osx1070) > 0 ) {
- // instable on OSX .. driver/OS bug when multi threading (3 animator)
- System.err.println("Shared context w/ 3 context each running in there own thread is instable here on OSX 10.7.4/NVidia,");
- System.err.println("SIGSEGV @ glDrawArrays / glBindBuffer .. any shared VBO.");
- System.err.println("Seems to run fine on 10.6.8/NVidia.");
- return;
- }
+ public void test03EachWithAnimatorSharedOffscreen() throws InterruptedException {
initShared(false);
Animator animator1 = new Animator();
Animator animator2 = new Animator();
Animator animator3 = new Animator();
GLWindow f1 = runTestGL(animator1, 0, 0, true, false);
InsetsImmutable insets = f1.getInsets();
- GLWindow f2 = runTestGL(animator2, f1.getX()+width+insets.getTotalWidth(),
+ GLWindow f2 = runTestGL(animator2, f1.getX()+width+insets.getTotalWidth(),
f1.getY()+0, true, false);
- GLWindow f3 = runTestGL(animator3, f1.getX()+0,
+ GLWindow f3 = runTestGL(animator3, f1.getX()+0,
f1.getY()+height+insets.getTotalHeight(), true, false);
try {
@@ -217,15 +264,18 @@ public class TestSharedContextVBOES2NEWT extends UITestCase {
f3.destroy();
Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false));
Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), false));
Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false));
Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), false));
Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false));
Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), false));
releaseShared();
}
-
- static long duration = 2000; // ms
+
+ static long duration = 1000; // ms
public static void main(String args[]) {
for(int i=0; i<args.length; i++) {
@@ -239,7 +289,7 @@ public class TestSharedContextVBOES2NEWT extends UITestCase {
/**
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(TestSharedContextVBOES2NEWT.class.getName());
+ System.err.println(stdin.readLine()); */
+ org.junit.runner.JUnitCore.main(TestSharedContextVBOES2NEWT1.class.getName());
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java
new file mode 100644
index 000000000..9b283d6cd
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java
@@ -0,0 +1,315 @@
+/**
+ * Copyright 2010 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;
+
+import java.util.List;
+
+import com.jogamp.newt.opengl.GLWindow;
+
+import javax.media.nativewindow.util.InsetsImmutable;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLProfile;
+import javax.media.opengl.GLRunnable;
+
+import com.jogamp.opengl.util.Animator;
+import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.FixMethodOrder;
+import org.junit.runners.MethodSorters;
+
+/**
+ * Sharing the VBO of 3 GearsES2 instances, each in their own GLWindow.
+ * <p>
+ * This is achieved by using the 1st GLWindow's GLContext as the <i>master</i>
+ * and manually triggering creation of the 2nd and 3rd GLWindow when the 1st GLWindow's
+ * GLContext becomes created. The trigger is performed by simply
+ * inserting a GLRunnable in the 1st GLWindow, which makes the other visible.
+ * </p>
+ * <p>
+ * Above method allows random creation of the 1st GLWindow, which triggers
+ * creation of the <i>dependent</i> other GLWindow sharing it's GLContext.
+ * </p>
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestSharedContextVBOES2NEWT2 extends UITestCase {
+ static GLProfile glp;
+ static GLCapabilities caps;
+ static int width, height;
+
+ @BeforeClass
+ public static void initClass() {
+ if(GLProfile.isAvailable(GLProfile.GL2ES2)) {
+ glp = GLProfile.get(GLProfile.GL2ES2);
+ Assert.assertNotNull(glp);
+ caps = new GLCapabilities(glp);
+ Assert.assertNotNull(caps);
+ width = 256;
+ height = 256;
+ } else {
+ setTestSupported(false);
+ }
+ }
+
+ protected GLWindow createGLWindow(int x, int y, GearsES2 gears) throws InterruptedException {
+ GLWindow glWindow = GLWindow.create(caps);
+ Assert.assertNotNull(glWindow);
+ glWindow.setPosition(x, y);
+ glWindow.setTitle("Shared Gears NEWT Test: "+x+"/"+y+" shared true");
+ glWindow.setSize(width, height);
+ glWindow.addGLEventListener(gears);
+
+ return glWindow;
+ }
+
+ @Test
+ public void test01SyncedCommonAnimatorSharedOffscreen() throws InterruptedException {
+ final Animator animator = new Animator();
+ final GearsES2 g1 = new GearsES2(0);
+ final GLWindow f1 = createGLWindow(0, 0, g1);
+ animator.add(f1);
+ InsetsImmutable insets = f1.getInsets();
+
+ final GearsES2 g2 = new GearsES2(0);
+ g2.setSharedGears(g1);
+ final GLWindow f2 = createGLWindow(f1.getX()+width+insets.getTotalWidth(),
+ f1.getY()+0, g2);
+ animator.add(f2);
+
+ final GearsES2 g3 = new GearsES2(0);
+ g3.setSharedGears(g1);
+ final GLWindow f3 = createGLWindow(f1.getX()+0,
+ f1.getY()+height+insets.getTotalHeight(), g3);
+ animator.add(f3);
+
+ // f1's shared GLContext is ready !
+ f1.invoke(false, new GLRunnable() {
+ @Override
+ public boolean run(GLAutoDrawable drawable) {
+ final GLContext ctx1 = f1.getContext();
+ Assert.assertTrue("Ctx is shared before shared creation", !ctx1.isShared());
+ f2.setSharedContext(ctx1);
+ f2.setVisible(true);
+ f2.display(); // kick off GLContext ..
+ f3.setSharedContext(ctx1);
+ f3.setVisible(true);
+ f3.display(); // kick off GLContext ..
+ return true;
+ }
+ });
+
+ f1.setVisible(true);
+ f1.display(); // kick off GLContext .. and hence f2 + f3 creation
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, true));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), true));
+ Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true));
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), true));
+ Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true));
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, true));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), true));
+ Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true));
+
+ animator.start(); // post start animator, otherwise display will be suppressed
+
+ final GLContext ctx1 = f1.getContext();
+ final GLContext ctx2 = f2.getContext();
+ final GLContext ctx3 = f3.getContext();
+ {
+ final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
+ final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
+ final List<GLContext> ctx3Shares = ctx3.getCreatedShares();
+ System.err.println("XXX-C-3.1:");
+ MiscUtils.dumpSharedGLContext(ctx1);
+ System.err.println("XXX-C-3.2:");
+ MiscUtils.dumpSharedGLContext(ctx2);
+ System.err.println("XXX-C-3.3:");
+ MiscUtils.dumpSharedGLContext(ctx3);
+
+ Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
+ Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
+ Assert.assertTrue("Ctx3 is not shared", ctx3.isShared());
+ Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size());
+ Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size());
+ Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size());
+ }
+
+ Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears());
+ Assert.assertTrue("Gears2 is not shared", g2.usesSharedGears());
+ Assert.assertTrue("Gears3 is not shared", g3.usesSharedGears());
+
+ try {
+ Thread.sleep(duration);
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ animator.stop();
+
+ f1.destroy();
+ f2.destroy();
+ f3.destroy();
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false));
+ }
+
+ @Test
+ public void test02AsyncEachWithAnimatorSharedOffscreen() throws InterruptedException {
+ final Animator a1 = new Animator();
+ final GearsES2 g1 = new GearsES2(0);
+ final GLWindow f1 = createGLWindow(0, 0, g1);
+ a1.add(f1);
+ a1.start();
+ f1.setVisible(true);
+
+ InsetsImmutable insets = f1.getInsets();
+
+ final Animator a2 = new Animator();
+ final GearsES2 g2 = new GearsES2(0);
+ g2.setSharedGears(g1);
+ final GLWindow f2 = createGLWindow(f1.getX()+width+insets.getTotalWidth(),
+ f1.getY()+0, g2);
+ a2.add(f2);
+ a2.start();
+
+ final Animator a3 = new Animator();
+ final GearsES2 g3 = new GearsES2(0);
+ g3.setSharedGears(g1);
+ final GLWindow f3 = createGLWindow(f1.getX()+0,
+ f1.getY()+height+insets.getTotalHeight(), g3);
+ a3.add(f3);
+ a3.start();
+
+ // f1's shared GLContext is ready !
+ f1.invoke(false, new GLRunnable() {
+ @Override
+ public boolean run(GLAutoDrawable drawable) {
+ final GLContext ctx1 = f1.getContext();
+ Assert.assertTrue("Ctx is shared before shared creation", !ctx1.isShared());
+ f2.setSharedContext(ctx1);
+ f2.setVisible(true);
+ f3.setSharedContext(ctx1);
+ f3.setVisible(true);
+ return true;
+ }
+ });
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, true));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), true));
+ Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true));
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), true));
+ Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, true));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), true));
+ Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true));
+
+ final GLContext ctx1 = f1.getContext();
+ final GLContext ctx2 = f2.getContext();
+ final GLContext ctx3 = f3.getContext();
+ {
+ final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
+ final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
+ final List<GLContext> ctx3Shares = ctx3.getCreatedShares();
+ System.err.println("XXX-C-3.1:");
+ MiscUtils.dumpSharedGLContext(ctx1);
+ System.err.println("XXX-C-3.2:");
+ MiscUtils.dumpSharedGLContext(ctx2);
+ System.err.println("XXX-C-3.3:");
+ MiscUtils.dumpSharedGLContext(ctx3);
+
+ Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
+ Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
+ Assert.assertTrue("Ctx3 is not shared", ctx3.isShared());
+ Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size());
+ Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size());
+ Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size());
+ }
+
+ Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears());
+ Assert.assertTrue("Gears2 is not shared", g2.usesSharedGears());
+ Assert.assertTrue("Gears3 is not shared", g3.usesSharedGears());
+
+ try {
+ Thread.sleep(duration);
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ a1.stop();
+ a2.stop();
+ a3.stop();
+
+ f1.destroy();
+ f2.destroy();
+ f3.destroy();
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false));
+ }
+
+ static long duration = 1000; // ms
+
+ public static void main(String args[]) {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ try {
+ duration = Integer.parseInt(args[i]);
+ } catch (Exception ex) { ex.printStackTrace(); }
+ }
+ }
+ /**
+ 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(TestSharedContextVBOES2NEWT2.class.getName());
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT3.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT3.java
new file mode 100644
index 000000000..e2928855c
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT3.java
@@ -0,0 +1,296 @@
+/**
+ * Copyright 2010 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;
+
+import java.util.List;
+
+import com.jogamp.newt.opengl.GLWindow;
+
+import javax.media.nativewindow.util.InsetsImmutable;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLProfile;
+
+import com.jogamp.opengl.util.Animator;
+import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.FixMethodOrder;
+import org.junit.runners.MethodSorters;
+
+/**
+ * Sharing the VBO of 3 GearsES2 instances, each in their own GLWindow.
+ * <p>
+ * This is achieved by using the 1st GLWindow as the <i>master</i>
+ * and using the build-in blocking mechanism to postpone creation
+ * of the 2nd and 3rd GLWindow until the 1st GLWindow's GLContext becomes created.
+ * </p>
+ * <p>
+ * Above method allows random creation of the 1st GLWindow, which triggers
+ * creation of the <i>dependent</i> other GLWindow sharing it's GLContext.
+ * </p>
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestSharedContextVBOES2NEWT3 extends UITestCase {
+ static GLProfile glp;
+ static GLCapabilities caps;
+ static int width, height;
+
+ @BeforeClass
+ public static void initClass() {
+ if(GLProfile.isAvailable(GLProfile.GL2ES2)) {
+ glp = GLProfile.get(GLProfile.GL2ES2);
+ Assert.assertNotNull(glp);
+ caps = new GLCapabilities(glp);
+ Assert.assertNotNull(caps);
+ width = 256;
+ height = 256;
+ } else {
+ setTestSupported(false);
+ }
+ }
+
+ protected GLWindow createGLWindow(int x, int y, GearsES2 gears) throws InterruptedException {
+ GLWindow glWindow = GLWindow.create(caps);
+ Assert.assertNotNull(glWindow);
+ glWindow.setPosition(x, y);
+ glWindow.setTitle("Shared Gears NEWT Test: "+x+"/"+y+" shared true");
+ glWindow.setSize(width, height);
+ glWindow.addGLEventListener(gears);
+
+ return glWindow;
+ }
+
+ @Test
+ public void test01SyncedCommonAnimatorSharedOffscreen() throws InterruptedException {
+ final Animator animator = new Animator();
+ final GearsES2 g1 = new GearsES2(0);
+ final GLWindow f1 = createGLWindow(0, 0, g1);
+ animator.add(f1);
+ InsetsImmutable insets = f1.getInsets();
+
+ final GearsES2 g2 = new GearsES2(0);
+ g2.setSharedGears(g1);
+ final GLWindow f2 = createGLWindow(f1.getX()+width+insets.getTotalWidth(),
+ f1.getY()+0, g2);
+ f2.setSharedAutoDrawable(f1);
+ animator.add(f2);
+
+ final GearsES2 g3 = new GearsES2(0);
+ g3.setSharedGears(g1);
+ final GLWindow f3 = createGLWindow(f1.getX()+0,
+ f1.getY()+height+insets.getTotalHeight(), g3);
+ f3.setSharedAutoDrawable(f1);
+ animator.add(f3);
+
+ f2.setVisible(true); // shall wait until f1 is ready
+ f1.setVisible(true); // master ..
+ f3.setVisible(true); // shall wait until f1 is ready
+ animator.start(); // kicks off GLContext .. and hence gears of f2 + f3 completion
+
+ Thread.sleep(1000/60*10); // wait ~10 frames giving a chance to create (blocking until master share is valid)
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, true));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), true));
+ Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true));
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), true));
+ Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true));
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, true));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), true));
+ Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true));
+
+ final GLContext ctx1 = f1.getContext();
+ final GLContext ctx2 = f2.getContext();
+ final GLContext ctx3 = f3.getContext();
+ {
+ final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
+ final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
+ final List<GLContext> ctx3Shares = ctx3.getCreatedShares();
+ System.err.println("XXX-C-3.1:");
+ MiscUtils.dumpSharedGLContext(ctx1);
+ System.err.println("XXX-C-3.2:");
+ MiscUtils.dumpSharedGLContext(ctx2);
+ System.err.println("XXX-C-3.3:");
+ MiscUtils.dumpSharedGLContext(ctx3);
+
+ Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
+ Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
+ Assert.assertTrue("Ctx3 is not shared", ctx3.isShared());
+ Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size());
+ Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size());
+ Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size());
+ }
+
+ Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears());
+ Assert.assertTrue("Gears2 is not shared", g2.usesSharedGears());
+ Assert.assertTrue("Gears3 is not shared", g3.usesSharedGears());
+
+ try {
+ Thread.sleep(duration);
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ animator.stop();
+
+ f1.destroy();
+ f2.destroy();
+ f3.destroy();
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false));
+ }
+
+ @Test
+ public void test02AsyncEachWithAnimatorSharedOffscreen() throws InterruptedException {
+ final Animator a1 = new Animator();
+ final GearsES2 g1 = new GearsES2(0);
+ final GLWindow f1 = createGLWindow(0, 0, g1);
+ a1.add(f1);
+ a1.start();
+ // f1.setVisible(true); // we do this post f2 .. to test pending creation!
+
+ InsetsImmutable insets = f1.getInsets();
+
+ final Animator a2 = new Animator();
+ final GearsES2 g2 = new GearsES2(0);
+ g2.setSharedGears(g1);
+ final GLWindow f2 = createGLWindow(f1.getX()+width+insets.getTotalWidth(),
+ f1.getY()+0, g2);
+ f2.setSharedAutoDrawable(f1);
+ a2.add(f2);
+ a2.start();
+ f2.setVisible(true);
+
+ f1.setVisible(true); // test pending creation of f2
+
+ final Animator a3 = new Animator();
+ final GearsES2 g3 = new GearsES2(0);
+ g3.setSharedGears(g1);
+ final GLWindow f3 = createGLWindow(f1.getX()+0,
+ f1.getY()+height+insets.getTotalHeight(), g3);
+ f3.setSharedAutoDrawable(f1);
+ a3.add(f3);
+ a3.start();
+ f3.setVisible(true);
+
+ Thread.sleep(1000/60*10); // wait ~10 frames giving a chance to create (blocking until master share is valid)
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, true));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), true));
+ Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true));
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), true));
+ Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true));
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, true));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), true));
+ Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true));
+
+ final GLContext ctx1 = f1.getContext();
+ final GLContext ctx2 = f2.getContext();
+ final GLContext ctx3 = f3.getContext();
+ {
+ final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
+ final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
+ final List<GLContext> ctx3Shares = ctx3.getCreatedShares();
+ System.err.println("XXX-C-3.1:");
+ MiscUtils.dumpSharedGLContext(ctx1);
+ System.err.println("XXX-C-3.2:");
+ MiscUtils.dumpSharedGLContext(ctx2);
+ System.err.println("XXX-C-3.3:");
+ MiscUtils.dumpSharedGLContext(ctx3);
+
+ Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
+ Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
+ Assert.assertTrue("Ctx3 is not shared", ctx3.isShared());
+ Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size());
+ Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size());
+ Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size());
+ }
+
+ Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears());
+ Assert.assertTrue("Gears2 is not shared", g2.usesSharedGears());
+ Assert.assertTrue("Gears3 is not shared", g3.usesSharedGears());
+
+ try {
+ Thread.sleep(duration);
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ a1.stop();
+ a2.stop();
+ a3.stop();
+
+ f1.destroy();
+ f2.destroy();
+ f3.destroy();
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false));
+ }
+
+ static long duration = 1000; // ms
+
+ public static void main(String args[]) {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ try {
+ duration = Integer.parseInt(args[i]);
+ } catch (Exception ex) { ex.printStackTrace(); }
+ }
+ }
+ /**
+ 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(TestSharedContextVBOES2NEWT3.class.getName());
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextWithJTabbedPaneAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextWithJTabbedPaneAWT.java
new file mode 100644
index 000000000..e49f4e27e
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextWithJTabbedPaneAWT.java
@@ -0,0 +1,264 @@
+/**
+ * Copyright (C) 2013 United States Government as represented by the Administrator of the
+ * National Aeronautics and Space Administration.
+ * All Rights Reserved.
+ *
+ * Copyright 2010 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;
+
+import java.awt.BorderLayout;
+import java.lang.reflect.InvocationTargetException;
+import java.nio.FloatBuffer;
+
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLProfile;
+import javax.media.opengl.awt.GLCanvas;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JTabbedPane;
+import javax.swing.SwingUtilities;
+import javax.swing.WindowConstants;
+
+import org.junit.Assert;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
+
+import com.jogamp.common.nio.Buffers;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestSharedContextWithJTabbedPaneAWT extends UITestCase {
+
+ static class DemoInstance {
+ protected static GLCapabilities getCaps() {
+ GLCapabilities caps = new GLCapabilities(GLProfile.getMaxFixedFunc(true));
+
+ caps.setAlphaBits(8);
+ caps.setRedBits(8);
+ caps.setGreenBits(8);
+ caps.setBlueBits(8);
+ caps.setDepthBits(24);
+ caps.setDoubleBuffered(true);
+
+ return caps;
+ }
+
+ int[] bufferId;
+
+ @SuppressWarnings("serial")
+ class SharedGLPanel extends JPanel implements GLEventListener {
+ final GLCanvas canvas;
+ final boolean shared;
+
+ public SharedGLPanel(GLCanvas shareWith, int width, int height) {
+ GLContext sharedCtx = shareWith != null ? shareWith.getContext() : null;
+ System.err.println("XXX WWPanel: shareWith "+shareWith+", sharedCtx "+sharedCtx);
+ canvas = new GLCanvas(getCaps()); // same caps for 1st and 2nd shared ctx !
+ if( null != shareWith) {
+ canvas.setSharedAutoDrawable(shareWith);
+ shared = true;
+ } else {
+ shared = false;
+ }
+ canvas.setSize(new java.awt.Dimension(width, height));
+
+ setLayout(new BorderLayout(5, 5));
+ add(canvas, BorderLayout.CENTER);
+ setOpaque(false);
+
+ canvas.addGLEventListener(this);
+ }
+
+ @Override
+ public void init(GLAutoDrawable glAutoDrawable) {
+ if (!shared) {
+ Assert.assertNull("Buffer is set, but instance is share master", bufferId);
+ makeVBO(glAutoDrawable);
+ System.err.println("XXX Create Buffer "+bufferId[0]);
+ } else {
+ Assert.assertNotNull("Buffer is not set, but instance is share slave", bufferId);
+ Assert.assertTrue("Context is not shared", glAutoDrawable.getContext().isShared());
+ System.err.println("XXX Reuse Buffer "+bufferId[0]);
+ }
+ final GL2 gl = glAutoDrawable.getGL().getGL2();
+ if( shared ) {
+ gl.glColor3f(1, 1, 1);
+ gl.glClearColor(0.3f, 0.3f, 0.3f, 1f);
+ } else {
+ gl.glColor3f(0, 0, 0);
+ gl.glClearColor(1f, 1f, 1f, 1f);
+ }
+ gl.glShadeModel(GL2.GL_FLAT);
+ }
+
+ @Override
+ public void dispose(GLAutoDrawable glAutoDrawable) {}
+
+ @Override
+ public void display(GLAutoDrawable glAutoDrawable) {
+ final GL2 gl = glAutoDrawable.getGL().getGL2();
+
+ gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
+
+ gl.glEnableClientState(GL2.GL_VERTEX_ARRAY);
+ gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, bufferId[0]);
+ gl.glVertexPointer(3, GL2.GL_FLOAT, 0, 0);
+ gl.glDrawArrays(GL2.GL_LINES, 0, 2);
+ }
+
+ @Override
+ public void reshape(GLAutoDrawable glAutoDrawable, int i, int i1, int i2, int i3) {
+ int w = getWidth();
+ int h = getHeight();
+
+ final GL2 gl = glAutoDrawable.getGL().getGL2();
+
+ gl.glViewport(0, 0, w, h);
+ gl.glMatrixMode(GL2.GL_PROJECTION);
+ gl.glLoadIdentity();
+ gl.glOrtho(0, 1, 0, 1, -1, 1);
+ gl.glMatrixMode(GL2.GL_MODELVIEW);
+ gl.glLoadIdentity();
+ }
+ }
+
+ protected void makeVBO(GLAutoDrawable drawable) {
+ GL2 gl = drawable.getGL().getGL2();
+
+ bufferId = new int[1];
+ gl.glGenBuffers(1, bufferId, 0);
+ gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, bufferId[0]);
+
+ FloatBuffer vertices = Buffers.newDirectFloatBuffer(6);
+ vertices.put(0).put(0).put(0);
+ vertices.put(1).put(1).put(0);
+ gl.glBufferData(GL2.GL_ARRAY_BUFFER, vertices.capacity() * 4, vertices.rewind(), GL2.GL_STATIC_DRAW);
+ }
+
+ public JTabbedPane tabbedPanel;
+
+ public DemoInstance(JFrame f) {
+ try
+ {
+ GLProfile.initSingleton(); // Lets have init debug messages above below marker
+ System.err.println("XXX START DEMO XXX");
+
+ // Create the application frame and the tabbed pane and add the pane to the frame.
+ tabbedPanel = new JTabbedPane();
+ f.add(tabbedPanel, BorderLayout.CENTER);
+
+ // Create two World Windows that share resources.
+ SharedGLPanel wwpA = new SharedGLPanel(null, 600, 600);
+ SharedGLPanel wwpB = new SharedGLPanel(wwpA.canvas, wwpA.getWidth(), wwpA.getHeight());
+
+ tabbedPanel.add(wwpA, "Window A");
+ tabbedPanel.add(wwpB, "Window B");
+
+ // Add the card panel to the frame.
+ f.add(tabbedPanel, BorderLayout.CENTER);
+
+ // Position and display the frame.
+ f.setTitle("Multi-Window Tabbed Pane");
+ f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
+ f.pack();
+ f.setResizable(true);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ static long durationPerTest = 500*4; // ms
+ static boolean manual = false;
+ static volatile boolean shouldStop = false;
+
+ @Test
+ public void test01() throws InterruptedException, InvocationTargetException {
+ final JFrame f = new JFrame();
+ final DemoInstance demo = new DemoInstance(f);
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ System.err.println("XXX SetVisible XXX");
+ f.setVisible(true);
+ } });
+
+ if(manual) {
+ for(long w=durationPerTest; !shouldStop && w>0; w-=100) {
+ Thread.sleep(100);
+ }
+ } else {
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ demo.tabbedPanel.setSelectedIndex(0);
+ }});
+ Thread.sleep(durationPerTest/4);
+
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ demo.tabbedPanel.setSelectedIndex(1);
+ }});
+ Thread.sleep(durationPerTest/4);
+
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ demo.tabbedPanel.setSelectedIndex(0);
+ }});
+ Thread.sleep(durationPerTest/4);
+
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ demo.tabbedPanel.setSelectedIndex(1);
+ }});
+ Thread.sleep(durationPerTest/4);
+ }
+
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ System.err.println("XXX SetVisible XXX");
+ f.dispose();
+ } });
+ }
+
+ public static void main(String args[]) {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ durationPerTest = MiscUtils.atoi(args[++i], (int)durationPerTest);
+ } else if(args[i].equals("-manual")) {
+ manual = true;
+ }
+ }
+ org.junit.runner.JUnitCore.main(TestSharedContextWithJTabbedPaneAWT.class.getName());
+ }
+}
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/GLContextDrawableSwitchBase.java
index 905cbcf25..8c9d6c24a 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/GLContextDrawableSwitchBase.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,12 +20,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.opengl.test.junit.jogl.acore.glels;
import java.awt.Dimension;
@@ -57,11 +57,11 @@ import org.junit.BeforeClass;
/**
* Test re-association of GLContext/GLDrawables,
- * here GLContext's survival of GLDrawable destruction
+ * here GLContext's survival of GLDrawable destruction
* and reuse w/ new or recreated GLDrawable.
* <p>
- * Test utilizes {@link GLEventListenerState} for preserving the
- * GLAutoDrawable state, i.e. GLContext, all GLEventListener
+ * Test utilizes {@link GLEventListenerState} for preserving the
+ * GLAutoDrawable state, i.e. GLContext, all GLEventListener
* and the GLAnimatorControl association.
* </p>
* <p>
@@ -70,7 +70,7 @@ import org.junit.BeforeClass;
*/
public abstract class GLContextDrawableSwitchBase extends UITestCase {
static protected enum GLADType { GLCanvasOnscreen, GLCanvasOffscreen, GLWindow, GLOffscreen };
-
+
// default period for 1 GLAD cycle
static long duration = 1000; // ms
@@ -83,7 +83,7 @@ public abstract class GLContextDrawableSwitchBase extends UITestCase {
}
return new GLCapabilities(GLProfile.get(profile));
}
-
+
@BeforeClass
public static void initClass() {
width = 256;
@@ -101,37 +101,37 @@ public abstract class GLContextDrawableSwitchBase extends UITestCase {
} catch( Throwable throwable ) {
throwable.printStackTrace();
Assume.assumeNoException( throwable );
- }
+ }
}
-
+
static void setFrameVisible(final Frame frame) throws InterruptedException {
try {
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
frame.pack();
- frame.setVisible(true);
- }});
+ frame.setVisible(true);
+ }});
} catch( Throwable throwable ) {
throwable.printStackTrace();
Assume.assumeNoException( throwable );
}
}
-
+
static void destroyFrame(final Frame frame) throws InterruptedException {
try {
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
frame.dispose();
- }});
+ }});
} catch( Throwable throwable ) {
throwable.printStackTrace();
Assume.assumeNoException( throwable );
- }
+ }
}
-
+
private GLOffscreenAutoDrawable createGLOffscreenAutoDrawable(GLCapabilities caps, int width, int height) throws InterruptedException {
final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile());
- return factory.createOffscreenAutoDrawable(null, caps, null, width, height, null);
+ return factory.createOffscreenAutoDrawable(null, caps, null, width, height);
}
protected static boolean validateOnOffscreenLayer(GLADType gladType1, GLADType gladType2) {
@@ -150,37 +150,37 @@ public abstract class GLContextDrawableSwitchBase extends UITestCase {
}
return true;
}
-
- protected void testGLADOneLifecycle(Screen screen, GLCapabilities caps, GLADType gladType, int width,
+
+ protected void testGLADOneLifecycle(Screen screen, GLCapabilities caps, GLADType gladType, int width,
int height, GLEventListenerCounter glelTracker,
- SnapshotGLEventListener snapshotGLEventListener, final GLEventListenerState glelsIn, final GLEventListenerState glelsOut[], GLAnimatorControl animator)
+ SnapshotGLEventListener snapshotGLEventListener, final GLEventListenerState glelsIn, final GLEventListenerState glelsOut[], GLAnimatorControl animator)
throws InterruptedException {
-
+
System.err.println("GLAD Lifecycle.0 "+gladType+", restoring "+((null!=glelsIn)?true:false)+", preserving "+((null!=glelsOut)?true:false));
final Frame frame;
final GLAutoDrawable glad;
- if( GLADType.GLCanvasOnscreen == gladType ) {
+ if( GLADType.GLCanvasOnscreen == gladType ) {
if( jogamp.nativewindow.jawt.JAWTUtil.isOffscreenLayerRequired() ) {
throw new InternalError("Platform requires offscreen rendering, but onscreen requested: "+gladType);
}
frame = new Frame("AWT GLCanvas");
-
+
glad = new GLCanvas(caps);
setGLCanvasSize((GLCanvas)glad, new Dimension(width, height));
frame.add((GLCanvas)glad);
- } else if( GLADType.GLCanvasOffscreen == gladType ) {
+ } else if( GLADType.GLCanvasOffscreen == gladType ) {
if( !jogamp.nativewindow.jawt.JAWTUtil.isOffscreenLayerSupported() ) {
throw new InternalError("Platform doesn't support offscreen rendering: "+gladType);
}
frame = new Frame("AWT GLCanvas");
-
+
glad = new GLCanvas(caps);
((GLCanvas)glad).setShallUseOffscreenLayer(true);
setGLCanvasSize((GLCanvas)glad, new Dimension(width, height));
frame.add((GLCanvas)glad);
} else if( GLADType.GLWindow == gladType ) {
frame = null;
-
+
if( null != screen ) {
glad = GLWindow.create(screen, caps);
} else {
@@ -190,60 +190,60 @@ public abstract class GLContextDrawableSwitchBase extends UITestCase {
((GLWindow)glad).setSize(width, height);
} else if( GLADType.GLOffscreen == gladType ) {
frame = null;
-
+
glad = this.createGLOffscreenAutoDrawable(caps, width, height);
} else {
throw new InternalError("Unsupported: "+gladType);
}
-
+
if( null == glelsIn ) {
if( null != animator ) {
animator.add(glad);
}
glad.addGLEventListener(glelTracker);
glad.addGLEventListener(new GearsES2(1));
- glad.addGLEventListener(snapshotGLEventListener);
+ glad.addGLEventListener(snapshotGLEventListener);
}
snapshotGLEventListener.setMakeSnapshot();
-
- if( GLADType.GLCanvasOnscreen == gladType || GLADType.GLCanvasOffscreen == gladType ) {
- setFrameVisible(frame);
+
+ if( GLADType.GLCanvasOnscreen == gladType || GLADType.GLCanvasOffscreen == gladType ) {
+ setFrameVisible(frame);
Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true));
} else if( GLADType.GLWindow == gladType ) {
((GLWindow)glad).setVisible(true);
- }
- Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glad, true));
+ }
+ Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glad, true));
Assert.assertNotNull(glad.getContext());
Assert.assertTrue(glad.isRealized());
-
+
if( null != glelsIn ) {
Assert.assertEquals(0, glad.getGLEventListenerCount());
System.err.println(".. restoring.0");
- glelsIn.moveTo(glad);
+ glelsIn.moveTo(glad);
System.err.println(".. restoring.X");
-
+
Assert.assertEquals(1, glelTracker.initCount);
Assert.assertTrue(1 <= glelTracker.reshapeCount);
Assert.assertTrue(1 <= glelTracker.displayCount);
Assert.assertEquals(0, glelTracker.disposeCount);
Assert.assertEquals(3, glad.getGLEventListenerCount());
-
+
Assert.assertEquals(glelsIn.context, glad.getContext());
Assert.assertEquals(glelsIn.listenerCount(), glad.getGLEventListenerCount());
Assert.assertEquals(glelsIn.context.getGLReadDrawable(), glad.getDelegatedDrawable());
Assert.assertEquals(glelsIn.context.getGLDrawable(), glad.getDelegatedDrawable());
Assert.assertEquals(false, glelsIn.isOwner());
}
-
- for (int wait=0; wait<AWTRobotUtil.POLL_DIVIDER &&
+
+ for (int wait=0; wait<AWTRobotUtil.POLL_DIVIDER &&
( 1 > glelTracker.initCount || 1 > glelTracker.reshapeCount || 1 > glelTracker.displayCount );
wait++) {
Thread.sleep(AWTRobotUtil.TIME_SLICE);
}
-
+
final long t0 = System.currentTimeMillis();
long t1 = t0;
-
+
while( ( t1 - t0 ) < duration ) {
Thread.sleep(100);
t1 = System.currentTimeMillis();
@@ -253,13 +253,13 @@ public abstract class GLContextDrawableSwitchBase extends UITestCase {
Assert.assertTrue(1 <= glelTracker.reshapeCount);
Assert.assertTrue(1 <= glelTracker.displayCount);
Assert.assertEquals(0, glelTracker.disposeCount);
-
+
if( null != glelsOut ) {
final GLContext context1 = glad.getContext();
System.err.println(".. preserving.0");
glelsOut[0] = GLEventListenerState.moveFrom(glad);
System.err.println(".. preserving.X");
-
+
Assert.assertEquals(context1, glelsOut[0].context);
Assert.assertNull(context1.getGLReadDrawable());
Assert.assertNull(context1.getGLDrawable());
@@ -276,8 +276,8 @@ public abstract class GLContextDrawableSwitchBase extends UITestCase {
} else if( GLADType.GLOffscreen == gladType ) {
glad.destroy();
}
- Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glad, false));
-
+ Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glad, false));
+
Assert.assertEquals(1, glelTracker.initCount);
Assert.assertTrue(1 <= glelTracker.reshapeCount);
Assert.assertTrue(1 <= glelTracker.displayCount);
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 e568f87a1..316199d07 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
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,12 +20,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.opengl.test.junit.jogl.acore.glels;
import java.awt.BorderLayout;
@@ -71,7 +71,7 @@ public class TestGLContextDrawableSwitch02AWT extends UITestCase {
}
return new GLCapabilities(GLProfile.get(profile));
}
-
+
@BeforeClass
public static void initClass() {
width = 256;
@@ -82,13 +82,13 @@ public class TestGLContextDrawableSwitch02AWT extends UITestCase {
final GLAutoDrawable glad;
if( caps.isOnscreen() ) {
GLCanvas glCanvas = new GLCanvas(caps);
- Assert.assertNotNull(glCanvas);
+ Assert.assertNotNull(glCanvas);
Dimension glc_sz = new Dimension(width, height);
glCanvas.setMinimumSize(glc_sz);
glCanvas.setPreferredSize(glc_sz);
glCanvas.setSize(glc_sz);
glad = glCanvas;
-
+
frame.setLayout(new BorderLayout());
frame.add(glCanvas, BorderLayout.CENTER);
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
@@ -96,48 +96,48 @@ public class TestGLContextDrawableSwitch02AWT extends UITestCase {
frame.pack();
frame.setVisible(true);
}});
-
- } else {
+
+ } else {
final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile());
- glad = factory.createOffscreenAutoDrawable(null, caps, null, width, height, null);
+ glad = factory.createOffscreenAutoDrawable(null, caps, null, width, height);
Assert.assertNotNull(glad);
}
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(GLCapabilities capsOnscreen) throws InterruptedException, InvocationTargetException {
final GLCapabilities capsOffscreen = (GLCapabilities) capsOnscreen.clone();
capsOffscreen.setOnscreen(false);
-
+
final QuitAdapter quitAdapter = new QuitAdapter();
-
+
final Frame frame = new Frame("Gears AWT Test");
Assert.assertNotNull(frame);
new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame);
-
+
GLAutoDrawable glCanvas = createGLAutoDrawable(frame, capsOnscreen, width, height);
-
- final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener();
+
+ final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener();
GearsES2 gears = new GearsES2(1);
glCanvas.addGLEventListener(gears);
glCanvas.addGLEventListener(snapshotGLEventListener);
snapshotGLEventListener.setMakeSnapshot();
-
+
Animator animator = new Animator();
animator.add(glCanvas);
animator.start();
-
+
int s = 0;
long t0 = System.currentTimeMillis();
long t1 = t0;
-
+
GLAutoDrawable glOffscreen = createGLAutoDrawable(null, capsOffscreen, width, height);
while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration ) {
if( ( t1 - t0 ) / period > s) {
@@ -147,8 +147,8 @@ public class TestGLContextDrawableSwitch02AWT extends UITestCase {
// switch context _and_ the demo synchronously
GLDrawableUtil.swapGLContextAndAllGLEventListener(glCanvas, glOffscreen);
snapshotGLEventListener.setMakeSnapshot();
-
- System.err.println(s+" - switch - END "+ ( t1 - t0 ));
+
+ System.err.println(s+" - switch - END "+ ( t1 - t0 ));
}
Thread.sleep(100);
t1 = System.currentTimeMillis();
@@ -157,14 +157,14 @@ public class TestGLContextDrawableSwitch02AWT extends UITestCase {
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
@@ -186,7 +186,7 @@ public class TestGLContextDrawableSwitch02AWT extends UITestCase {
/**
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
System.err.println("Press enter to continue");
- System.err.println(stdin.readLine()); */
+ System.err.println(stdin.readLine()); */
org.junit.runner.JUnitCore.main(TestGLContextDrawableSwitch02AWT.class.getName());
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461FBOSupersamplingSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461FBOSupersamplingSwingAWT.java
index 033e55da3..96ec8ab75 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461FBOSupersamplingSwingAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461FBOSupersamplingSwingAWT.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,7 +20,7 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
@@ -31,7 +31,7 @@ package com.jogamp.opengl.test.junit.jogl.awt;
import java.awt.Container;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
-
+
import java.awt.image.BufferedImage;
import java.lang.reflect.InvocationTargetException;
@@ -68,11 +68,11 @@ public class TestBug461FBOSupersamplingSwingAWT extends UITestCase implements GL
JFrame jframe;
GLOffscreenAutoDrawable offScreenBuffer;
AWTGLReadBufferUtil awtGLReadBufferUtil;
-
+
private void render(GLAutoDrawable drawable) {
GL2 gl = drawable.getGL().getGL2();
Assert.assertNotNull(gl);
- gl.glClear(GL.GL_COLOR_BUFFER_BIT);
+ gl.glClear(GL.GL_COLOR_BUFFER_BIT);
// draw a triangle filling the window
gl.glBegin(GL.GL_TRIANGLES);
@@ -84,7 +84,7 @@ public class TestBug461FBOSupersamplingSwingAWT extends UITestCase implements GL
gl.glVertex2d(1, -1);
gl.glEnd();
}
-
+
/* @Override */
public void init(GLAutoDrawable drawable) {
awtGLReadBufferUtil = new AWTGLReadBufferUtil(drawable.getGLProfile(), false);
@@ -92,16 +92,16 @@ public class TestBug461FBOSupersamplingSwingAWT extends UITestCase implements GL
/* @Override */
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
- }
-
+ }
+
/* @Override */
- public void display(GLAutoDrawable drawable) {
+ public void display(GLAutoDrawable drawable) {
render(offScreenBuffer);
// BufferedImage outputImage = com.jogamp.opengl.util.awt.Screenshot.readToBufferedImage(200, 200, false);
BufferedImage outputImage = awtGLReadBufferUtil.readPixelsToBufferedImage(drawable.getGL(), 0, 0, 200, 200, true /* awtOrientation */);
Assert.assertNotNull(outputImage);
ImageIcon imageIcon = new ImageIcon(outputImage);
- final JLabel imageLabel = new JLabel(imageIcon);
+ final JLabel imageLabel = new JLabel(imageIcon);
try {
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
@@ -116,7 +116,7 @@ public class TestBug461FBOSupersamplingSwingAWT extends UITestCase implements GL
}
/* @Override */
- public void dispose(GLAutoDrawable drawable) {
+ public void dispose(GLAutoDrawable drawable) {
try {
awtGLReadBufferUtil.dispose(drawable.getGL());
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
@@ -141,29 +141,29 @@ public class TestBug461FBOSupersamplingSwingAWT extends UITestCase implements GL
GLProfile glp = GLProfile.get(GLProfile.GL2);
Assert.assertNotNull(glp);
-
+
GLDrawableFactory fac = GLDrawableFactory.getFactory(glp);
Assert.assertNotNull(fac);
-
+
Assert.assertTrue( fac.canCreateGLPbuffer(GLProfile.getDefaultDevice(), glp) );
-
+
GLCapabilities glCap = new GLCapabilities(glp);
Assert.assertNotNull(glCap);
-
- // COMMENTING OUT THIS LINE FIXES THE ISSUE.
+
+ // COMMENTING OUT THIS LINE FIXES THE ISSUE.
// Setting this in JOGL1 works. Thus this is a JOGL2 issue.
glCap.setSampleBuffers(true);
-
+
// Without line below, there is an error on Windows.
// glCap.setDoubleBuffered(false); // implicit double buffer -> MSAA + FBO
-
+
// Needed for drop shadows
glCap.setStencilBits(1);
//makes a new buffer
- offScreenBuffer = fac.createOffscreenAutoDrawable(GLProfile.getDefaultDevice(), glCap, null, 200, 200, null);
+ offScreenBuffer = fac.createOffscreenAutoDrawable(GLProfile.getDefaultDevice(), glCap, null, 200, 200);
Assert.assertNotNull(offScreenBuffer);
- offScreenBuffer.addGLEventListener(this);
+ offScreenBuffer.addGLEventListener(this);
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
jframe.setSize( 300, 300);
@@ -171,7 +171,7 @@ public class TestBug461FBOSupersamplingSwingAWT extends UITestCase implements GL
}});
offScreenBuffer.display(); // read from front buffer due to FBO+MSAA -> double-buffer
offScreenBuffer.display(); // now we have prev. image in front buffer to be read out
-
+
Thread.sleep(durationPerTest);
offScreenBuffer.destroy();
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageAWT.java
index 89470a922..e87c34419 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageAWT.java
@@ -132,7 +132,7 @@ public class TestBug605FlippedImageAWT extends UITestCase {
private void test(GLCapabilitiesImmutable caps) {
final GLDrawableFactory glFactory = GLDrawableFactory.getFactory(caps.getGLProfile());
- final GLAutoDrawable glad = glFactory.createOffscreenAutoDrawable(null, caps, null, 256, 256, null);
+ final GLAutoDrawable glad = glFactory.createOffscreenAutoDrawable(null, caps, null, 256, 256);
final FlippedImageTest tglel = new FlippedImageTest();
glad.addGLEventListener(tglel);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageNEWT.java
index 8d4710ad3..28fcb9885 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageNEWT.java
@@ -119,7 +119,7 @@ public class TestBug605FlippedImageNEWT extends UITestCase {
private void test(GLCapabilitiesImmutable caps) {
final GLReadBufferUtil rbu = new GLReadBufferUtil(false, false);
final GLDrawableFactory glFactory = GLDrawableFactory.getFactory(caps.getGLProfile());
- final GLAutoDrawable glad = glFactory.createOffscreenAutoDrawable(null, caps, null, 256, 256, null);
+ final GLAutoDrawable glad = glFactory.createOffscreenAutoDrawable(null, caps, null, 256, 256);
final FlippedImageTest tglel = new FlippedImageTest();
glad.addGLEventListener(tglel);
final SnapshotGLEventListener snap = new SnapshotGLEventListener(rbu);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java
index 521224c01..ba93dcdcd 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java
@@ -1,22 +1,22 @@
/*
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Copyright (c) 2010 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:
- *
+ *
* - Redistribution of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* - Redistribution 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.
- *
+ *
* Neither the name of Sun Microsystems, Inc. or the names of
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
- *
+ *
* This software is provided "AS IS," without a warranty of any kind. ALL
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
* INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
@@ -29,11 +29,11 @@
* DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
* SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
+ *
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
- *
+ *
* Sun gratefully acknowledges that this software was originally authored
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
@@ -104,7 +104,7 @@ public class TestMultisampleES1AWT extends UITestCase {
caps.setNumSamples(reqSamples);
}
- canvas = new GLCanvas(caps, chooser, null, null);
+ canvas = new GLCanvas(caps, chooser, null);
canvas.addGLEventListener(new MultisampleDemoES1(reqSamples>0?true:false));
canvas.addGLEventListener(new GLEventListener() {
int displayCount = 0;
@@ -115,7 +115,7 @@ public class TestMultisampleES1AWT extends UITestCase {
}
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { }
});
-
+
final Frame frame = new Frame("Multi Samples "+reqSamples);
frame.setLayout(new BorderLayout());
canvas.setSize(512, 512);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java
index 63e89952f..db1f217ba 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java
@@ -7,10 +7,10 @@
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
- *
+ *
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
@@ -55,16 +55,18 @@ public class GearsES1 implements GLEventListener {
private boolean forceFFPEmu = false;
private boolean debug = false ;
private boolean trace = false ;
-
+
private final float pos[] = { 5.0f, 5.0f, 10.0f, 0.0f };
- private float view_rotx = 20.0f, view_roty = 30.0f, view_rotz = 0.0f;
+ private float view_rotx = 20.0f, view_roty = 30.0f;
+ private final float view_rotz = 0.0f;
private GearsObject gear1=null, gear2=null, gear3=null;
private FloatBuffer gear1Color=GearsObject.red, gear2Color=GearsObject.green, gear3Color=GearsObject.blue;
+ private volatile boolean usesSharedGears = false;
private float angle = 0.0f;
- private int swapInterval;
- private MouseListener gearsMouse = new GearsMouseAdapter();
- private KeyListener gearsKeys = new GearsKeyAdapter();
+ private final int swapInterval;
+ private final MouseListener gearsMouse = new GearsMouseAdapter();
+ private final KeyListener gearsKeys = new GearsKeyAdapter();
private int prevMouseX, prevMouseY;
@@ -76,21 +78,21 @@ public class GearsES1 implements GLEventListener {
public GearsES1() {
this.swapInterval = 1;
}
-
+
public void setForceFFPEmu(boolean forceFFPEmu, boolean verboseFFPEmu, boolean debugFFPEmu, boolean traceFFPEmu) {
this.forceFFPEmu = forceFFPEmu;
this.verboseFFPEmu = verboseFFPEmu;
this.debugFFPEmu = debugFFPEmu;
this.traceFFPEmu = traceFFPEmu;
}
-
+
public void setGearsColors(FloatBuffer gear1Color, FloatBuffer gear2Color, FloatBuffer gear3Color) {
this.gear1Color = gear1Color;
this.gear2Color = gear2Color;
this.gear3Color = gear3Color;
}
-
- public void setGears(GearsObject g1, GearsObject g2, GearsObject g3) {
+
+ public void setSharedGearsObjects(GearsObject g1, GearsObject g2, GearsObject g3) {
gear1 = g1;
gear2 = g2;
gear3 = g3;
@@ -110,15 +112,17 @@ public class GearsES1 implements GLEventListener {
* @return gear3
*/
public GearsObject getGear3() { return gear3; }
-
+
+ public boolean usesSharedGears() { return usesSharedGears; }
+
public void init(GLAutoDrawable drawable) {
System.err.println(Thread.currentThread()+" GearsES1.init ...");
-
+
// Use debug pipeline
// drawable.setGL(new DebugGL(drawable.getGL()));
GL _gl = drawable.getGL();
-
+
if(debugFFPEmu) {
// Debug ..
_gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", GL2ES2.class, _gl, null) );
@@ -130,12 +134,12 @@ public class GearsES1 implements GLEventListener {
trace = false;
}
GL2ES1 gl = FixedFuncUtil.wrapFixedFuncEmul(_gl, ShaderSelectionMode.AUTO, null, forceFFPEmu, verboseFFPEmu);
-
+
if(debug) {
try {
// Debug ..
gl = (GL2ES1) gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", GL2ES1.class, gl, null) );
- } catch (Exception e) {e.printStackTrace();}
+ } catch (Exception e) {e.printStackTrace();}
}
if(trace) {
try {
@@ -143,7 +147,7 @@ public class GearsES1 implements GLEventListener {
gl = (GL2ES1) gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", GL2ES1.class, gl, new Object[] { System.err } ) );
} catch (Exception e) {e.printStackTrace();}
}
-
+
System.err.println("GearsES1 init on "+Thread.currentThread());
System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities());
System.err.println("INIT GL IS: " + gl.getClass().getName());
@@ -154,33 +158,36 @@ public class GearsES1 implements GLEventListener {
gl.glEnable(GL2ES1.GL_LIGHTING);
gl.glEnable(GL2ES1.GL_LIGHT0);
gl.glEnable(GL2ES1.GL_DEPTH_TEST);
-
+
/* make the gears */
if(null == gear1) {
gear1 = new GearsObjectES1(gear1Color, 1.0f, 4.0f, 1.0f, 20, 0.7f);
System.err.println("gear1 created: "+gear1);
} else {
+ usesSharedGears = true;
System.err.println("gear1 reused: "+gear1);
}
-
+
if(null == gear2) {
gear2 = new GearsObjectES1(gear2Color, 0.5f, 2.0f, 2.0f, 10, 0.7f);
System.err.println("gear2 created: "+gear2);
} else {
+ usesSharedGears = true;
System.err.println("gear2 reused: "+gear2);
}
-
+
if(null == gear3) {
gear3 = new GearsObjectES1(gear3Color, 1.3f, 2.0f, 0.5f, 10, 0.7f);
System.err.println("gear3 created: "+gear3);
} else {
+ usesSharedGears = true;
System.err.println("gear3 reused: "+gear3);
}
-
+
gl.glEnable(GL2ES1.GL_NORMALIZE);
-
+
final Object upstreamWidget = drawable.getUpstreamWidget();
- if (upstreamWidget instanceof Window) {
+ if (upstreamWidget instanceof Window) {
final Window window = (Window) upstreamWidget;
window.addMouseListener(gearsMouse);
window.addKeyListener(gearsKeys);
@@ -191,7 +198,7 @@ public class GearsES1 implements GLEventListener {
}
System.err.println(Thread.currentThread()+" GearsES1.init FIN");
}
-
+
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
System.err.println(Thread.currentThread()+" GearsES1.reshape "+x+"/"+y+" "+width+"x"+height+", swapInterval "+swapInterval);
GL2ES1 gl = drawable.getGL().getGL2ES1();
@@ -217,7 +224,7 @@ public class GearsES1 implements GLEventListener {
public void dispose(GLAutoDrawable drawable) {
System.err.println(Thread.currentThread()+" GearsES1.dispose ... ");
final Object upstreamWidget = drawable.getUpstreamWidget();
- if (upstreamWidget instanceof Window) {
+ if (upstreamWidget instanceof Window) {
final Window window = (Window) upstreamWidget;
window.removeMouseListener(gearsMouse);
window.removeKeyListener(gearsKeys);
@@ -232,7 +239,7 @@ public class GearsES1 implements GLEventListener {
System.err.println(Thread.currentThread()+" GearsES1.dispose FIN");
}
- public void display(GLAutoDrawable drawable) {
+ public void display(GLAutoDrawable drawable) {
// Turn the gears' teeth
angle += 2.0f;
@@ -251,10 +258,10 @@ public class GearsES1 implements GLEventListener {
} else {
gl.glClearColor(0.2f, 0.2f, 0.2f, 0.0f);
}
-
+
// Special handling for the case where the GLJPanel is translucent
// and wants to be composited with other Java 2D content
- if (GLProfile.isAWTAvailable() &&
+ if (GLProfile.isAWTAvailable() &&
(drawable instanceof javax.media.opengl.awt.GLJPanel) &&
!((javax.media.opengl.awt.GLJPanel) drawable).isOpaque() &&
((javax.media.opengl.awt.GLJPanel) drawable).shouldPreserveColorBufferIfTranslucent()) {
@@ -264,25 +271,25 @@ public class GearsES1 implements GLEventListener {
}
gl.glNormal3f(0.0f, 0.0f, 1.0f);
-
+
// Rotate the entire assembly of gears based on how the user
// dragged the mouse around
gl.glPushMatrix();
gl.glRotatef(view_rotx, 1.0f, 0.0f, 0.0f);
gl.glRotatef(view_roty, 0.0f, 1.0f, 0.0f);
gl.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f);
-
- gear1.draw(gl, -3.0f, -2.0f, angle);
- gear2.draw(gl, 3.1f, -2.0f, -2.0f * angle - 9.0f);
+
+ gear1.draw(gl, -3.0f, -2.0f, angle);
+ gear2.draw(gl, 3.1f, -2.0f, -2.0f * angle - 9.0f);
gear3.draw(gl, -3.1f, 4.2f, -2.0f * angle - 25.0f);
-
+
// Remember that every push needs a pop; this one is paired with
// rotating the entire gear assembly
gl.glPopMatrix();
}
-
- class GearsKeyAdapter extends KeyAdapter {
+
+ class GearsKeyAdapter extends KeyAdapter {
public void keyPressed(KeyEvent e) {
int kc = e.getKeyCode();
if(KeyEvent.VK_LEFT == kc) {
@@ -296,16 +303,16 @@ public class GearsES1 implements GLEventListener {
}
}
}
-
+
class GearsMouseAdapter extends MouseAdapter {
public void mousePressed(MouseEvent e) {
prevMouseX = e.getX();
prevMouseY = e.getY();
}
-
+
public void mouseReleased(MouseEvent e) {
}
-
+
public void mouseDragged(MouseEvent e) {
int x = e.getX();
int y = e.getY();
@@ -324,7 +331,7 @@ public class GearsES1 implements GLEventListener {
}
float thetaY = 360.0f * ( (float)(x-prevMouseX)/(float)width);
float thetaX = 360.0f * ( (float)(prevMouseY-y)/(float)height);
-
+
prevMouseX = x;
prevMouseY = y;
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java
index 9817ea57f..60242d604 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java
@@ -45,6 +45,7 @@ import javax.media.opengl.GL;
import javax.media.opengl.GL2ES2;
import javax.media.opengl.GLAnimatorControl;
import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLContext;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLProfile;
import javax.media.opengl.GLUniformData;
@@ -64,7 +65,9 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL
private final float view_rotz = 0.0f;
private float panX = 0.0f, panY = 0.0f, panZ=0.0f;
- private GearsObjectES2 gear1=null, gear2=null, gear3=null;
+ private volatile GearsObjectES2 gear1=null, gear2=null, gear3=null;
+ private GearsES2 sharedGears = null;
+ private volatile boolean usesSharedGears = false;
private FloatBuffer gear1Color=GearsObject.red, gear2Color=GearsObject.green, gear3Color=GearsObject.blue;
private float angle = 0.0f;
private int swapInterval = 0;
@@ -80,6 +83,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL
private float[] clearColor = null;
private boolean clearBuffers = true;
private boolean verbose = true;
+ private volatile boolean isInit = false;
private PinchToZoomGesture pinchToZoomGesture = null;
@@ -132,12 +136,16 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL
this.gear3Color = gear3Color;
}
- public void setGears(GearsObjectES2 g1, GearsObjectES2 g2, GearsObjectES2 g3) {
+ public void setSharedGearsObjects(GearsObjectES2 g1, GearsObjectES2 g2, GearsObjectES2 g3) {
gear1 = g1;
gear2 = g2;
gear3 = g3;
}
+ public void setSharedGears(GearsES2 shared) {
+ sharedGears = shared;
+ }
+
/**
* @return gear1
*/
@@ -153,12 +161,33 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL
*/
public GearsObjectES2 getGear3() { return gear3; }
+ public boolean usesSharedGears() { return usesSharedGears; }
+
+ private static final int TIME_OUT = 2000; // 2s
+ private static final int POLL_DIVIDER = 20; // TO/20
+ private static final int TIME_SLICE = TIME_OUT / POLL_DIVIDER ;
+
+ /**
+ * @return True if this GLEventListener became initialized within TIME_OUT 2s
+ */
+ public boolean waitForInit(boolean initialized) throws InterruptedException {
+ int wait;
+ for (wait=0; wait<POLL_DIVIDER && initialized != isInit ; wait++) {
+ Thread.sleep(TIME_SLICE);
+ }
+ return wait<POLL_DIVIDER;
+ }
@Override
public void init(GLAutoDrawable drawable) {
+ if(null != sharedGears && sharedGears.getGear1() == null ) {
+ System.err.println(Thread.currentThread()+" GearsES2.init: pending shared Gears .. re-init later XXXXX");
+ drawable.setGLEventListenerInitState(this, false);
+ return;
+ }
System.err.println(Thread.currentThread()+" GearsES2.init: tileRendererInUse "+tileRendererInUse);
- final GL2ES2 gl = drawable.getGL().getGL2ES2();
+ final GL2ES2 gl = drawable.getGL().getGL2ES2();
if(verbose) {
System.err.println("GearsES2 init on "+Thread.currentThread());
System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities());
@@ -201,39 +230,56 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL
st.ownUniform(colorU);
st.uniform(gl, colorU);
- if(null == gear1) {
- gear1 = new GearsObjectES2(st, gear1Color, 1.0f, 4.0f, 1.0f, 20, 0.7f, pmvMatrix, pmvMatrixUniform, colorU);
- if(verbose) {
- System.err.println("gear1 created: "+gear1);
- }
+ if( null != sharedGears ) {
+ gear1 = new GearsObjectES2(sharedGears.getGear1(), st, pmvMatrix, pmvMatrixUniform, colorU);
+ gear2 = new GearsObjectES2(sharedGears.getGear2(), st, pmvMatrix, pmvMatrixUniform, colorU);
+ gear3 = new GearsObjectES2(sharedGears.getGear3(), st, pmvMatrix, pmvMatrixUniform, colorU);
+ usesSharedGears = true;
+ if(verbose) {
+ System.err.println("gear1 created w/ share: "+sharedGears.getGear1()+" -> "+gear1);
+ System.err.println("gear2 created w/ share: "+sharedGears.getGear2()+" -> "+gear2);
+ System.err.println("gear3 created w/ share: "+sharedGears.getGear3()+" -> "+gear3);
+ }
} else {
- gear1 = new GearsObjectES2(gear1, st, pmvMatrix, pmvMatrixUniform, colorU);
- if(verbose) {
- System.err.println("gear1 reused: "+gear1);
+ if(null == gear1) {
+ gear1 = new GearsObjectES2(st, gear1Color, 1.0f, 4.0f, 1.0f, 20, 0.7f, pmvMatrix, pmvMatrixUniform, colorU);
+ if(verbose) {
+ System.err.println("gear1 created: "+gear1);
+ }
+ } else {
+ final GearsObjectES2 _gear1 = gear1;
+ gear1 = new GearsObjectES2(_gear1, st, pmvMatrix, pmvMatrixUniform, colorU);
+ usesSharedGears = true;
+ if(verbose) {
+ System.err.println("gear1 created w/ share: "+_gear1+" -> "+gear1);
+ }
}
- }
- if(null == gear2) {
- gear2 = new GearsObjectES2(st, gear2Color, 0.5f, 2.0f, 2.0f, 10, 0.7f, pmvMatrix, pmvMatrixUniform, colorU);
- if(verbose) {
- System.err.println("gear2 created: "+gear2);
- }
- } else {
- gear2 = new GearsObjectES2(gear2, st, pmvMatrix, pmvMatrixUniform, colorU);
- if(verbose) {
- System.err.println("gear2 reused: "+gear2);
+ if(null == gear2) {
+ gear2 = new GearsObjectES2(st, gear2Color, 0.5f, 2.0f, 2.0f, 10, 0.7f, pmvMatrix, pmvMatrixUniform, colorU);
+ if(verbose) {
+ System.err.println("gear2 created: "+gear2);
+ }
+ } else {
+ final GearsObjectES2 _gear2 = gear2;
+ gear2 = new GearsObjectES2(_gear2, st, pmvMatrix, pmvMatrixUniform, colorU);
+ usesSharedGears = true;
+ if(verbose) {
+ System.err.println("gear2 created w/ share: "+_gear2+" -> "+gear2);
+ }
}
- }
- if(null == gear3) {
- gear3 = new GearsObjectES2(st, gear3Color, 1.3f, 2.0f, 0.5f, 10, 0.7f, pmvMatrix, pmvMatrixUniform, colorU);
- if(verbose) {
- System.err.println("gear3 created: "+gear3);
- }
- } else {
- gear3 = new GearsObjectES2(gear3, st, pmvMatrix, pmvMatrixUniform, colorU);
- if(verbose) {
- System.err.println("gear3 reused: "+gear3);
+ if(null == gear3) {
+ gear3 = new GearsObjectES2(st, gear3Color, 1.3f, 2.0f, 0.5f, 10, 0.7f, pmvMatrix, pmvMatrixUniform, colorU);
+ if(verbose) {
+ }
+ } else {
+ final GearsObjectES2 _gear3 = gear3;
+ gear3 = new GearsObjectES2(_gear3, st, pmvMatrix, pmvMatrixUniform, colorU);
+ usesSharedGears = true;
+ if(verbose) {
+ System.err.println("gear3 created w/ share: "+_gear3+" -> "+gear3);
+ }
}
}
@@ -254,6 +300,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL
st.useProgram(gl, false);
System.err.println(Thread.currentThread()+" GearsES2.init FIN");
+ isInit = true;
}
private final GestureHandler.GestureListener pinchToZoomListener = new GestureHandler.GestureListener() {
@@ -267,6 +314,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL
@Override
public void reshape(GLAutoDrawable glad, int x, int y, int width, int height) {
+ if( !isInit ) { return; }
final GL2ES2 gl = glad.getGL().getGL2ES2();
if(-1 != swapInterval) {
gl.setSwapInterval(swapInterval);
@@ -278,6 +326,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL
public void reshapeTile(TileRendererBase tr,
int tileX, int tileY, int tileWidth, int tileHeight,
int imageWidth, int imageHeight) {
+ if( !isInit ) { return; }
final GL2ES2 gl = tr.getAttachedDrawable().getGL().getGL2ES2();
gl.setSwapInterval(0);
reshapeImpl(gl, tileX, tileY, tileWidth, tileHeight, imageWidth, imageHeight);
@@ -339,6 +388,8 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL
@Override
public void dispose(GLAutoDrawable drawable) {
+ if( !isInit ) { return; }
+ isInit = false;
System.err.println(Thread.currentThread()+" GearsES2.dispose: tileRendererInUse "+tileRendererInUse);
final Object upstreamWidget = drawable.getUpstreamWidget();
if (upstreamWidget instanceof Window) {
@@ -370,6 +421,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL
@Override
public void display(GLAutoDrawable drawable) {
+ if( !isInit ) { return; }
GLAnimatorControl anim = drawable.getAnimator();
if( verbose && ( null == anim || !anim.isAnimating() ) ) {
System.err.println(Thread.currentThread()+" GearsES2.display "+drawable.getWidth()+"x"+drawable.getHeight()+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(drawable.getHandle()));
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestBug365TextureGenerateMipMaps.java b/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestBug365TextureGenerateMipMaps.java
index 4d9b750c4..b9e64e1da 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestBug365TextureGenerateMipMaps.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestBug365TextureGenerateMipMaps.java
@@ -31,7 +31,7 @@ import com.jogamp.opengl.util.texture.TextureIO;
* <br></br>
* Bug Reference: https://jogamp.org/bugzilla/show_bug.cgi?id=365
* <br></br>
- * The bug pertains to mipmap generation from a Texture and exists in {@link ScaleInternal}
+ * The bug pertains to mipmap generation from a Texture and exists in {@link ScaleInternal}
* where a {@link java.nio.BufferUnderflowException} is thrown.
* <br></br>
* <ul>This suite of test cases test:
@@ -43,14 +43,14 @@ import com.jogamp.opengl.util.texture.TextureIO;
* <li>{@link ScaleInternal#scale_internal_int(int, int, int, ByteBuffer, int, int, java.nio.IntBuffer, int, int, int, boolean)}</li>
* <li>{@link ScaleInternal#scale_internal_float(int, int, int, ByteBuffer, int, int, java.nio.FloatBuffer, int, int, int, boolean)}</li>
* </ul>
- *
+ *
* @author Michael Esemplare, et.al.
*
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestBug365TextureGenerateMipMaps extends UITestCase {
static GLOffscreenAutoDrawable drawable;
-
+
@BeforeClass
public static void setup() throws Throwable {
// disableNPOT
@@ -61,23 +61,21 @@ public class TestBug365TextureGenerateMipMaps extends UITestCase {
throw t;
}
}
-
+
@AfterClass
public static void teardown() {
tearDownOffscreenAutoDrawable();
}
-
+
private static void setUpOffscreenAutoDrawable() throws Throwable {
GLProfile glp = GLProfile.getDefault();
GLCapabilities caps = new GLCapabilities(glp);
-
+
GLDrawableFactory factory = GLDrawableFactory.getFactory(glp);
-
- // Make a drawable to get an offscreen context
- drawable = factory.createOffscreenAutoDrawable(null, caps, null, 2, 2, null);
-
- drawable.setRealized(true);
+ // Make a drawable to get an offscreen context
+ drawable = factory.createOffscreenAutoDrawable(null, caps, null, 2, 2);
+ drawable.display(); // trigger context creation
GLContext glContext = drawable.getContext();
try {
Assert.assertTrue("Could not make context current", GLContext.CONTEXT_NOT_CURRENT < glContext.makeCurrent());
@@ -86,7 +84,7 @@ public class TestBug365TextureGenerateMipMaps extends UITestCase {
throw t;
}
}
-
+
private static void tearDownOffscreenAutoDrawable() {
if(drawable != null) {
drawable.getContext().release();
@@ -94,30 +92,30 @@ public class TestBug365TextureGenerateMipMaps extends UITestCase {
drawable = null;
}
}
-
+
private static void testTextureMipMapGeneration(int width, int height, int pixelFormat, int pixelType) {
int internalFormat = pixelFormat;
int border = 0;
boolean mipmap = true;
boolean dataIsCompressed = false;
boolean mustFlipVertically = false;
-
+
int memReq = Mipmap.image_size( width, height, pixelFormat, pixelType );
ByteBuffer buffer = Buffers.newDirectByteBuffer( memReq );
-
- TextureData data = new TextureData(drawable.getGLProfile(),
- internalFormat,
- width,
- height,
- border,
- pixelFormat,
- pixelType,
- mipmap,
- dataIsCompressed,
- mustFlipVertically,
- buffer,
+
+ TextureData data = new TextureData(drawable.getGLProfile(),
+ internalFormat,
+ width,
+ height,
+ border,
+ pixelFormat,
+ pixelType,
+ mipmap,
+ dataIsCompressed,
+ mustFlipVertically,
+ buffer,
null);
-
+
Texture texture = TextureIO.newTexture(drawable.getGL(), data);
// Cleanup
texture.destroy(drawable.getGL());
@@ -125,144 +123,144 @@ public class TestBug365TextureGenerateMipMaps extends UITestCase {
buffer.clear();
buffer = null;
}
-
+
@Test
public void test00_MipMap_ScaleInternal_RGB_UBYTE () {
int width = 1;
int height = 7;
int pixelFormat = GL2.GL_RGB;
int pixelType = GL2.GL_UNSIGNED_BYTE;
-
+
testTextureMipMapGeneration(width, height, pixelFormat, pixelType);
}
-
+
@Test
public void test01_MipMap_ScaleInternal_RGBA_UBYTE () {
int width = 1;
int height = 7;
int pixelFormat = GL2.GL_RGBA;
int pixelType = GL2.GL_UNSIGNED_BYTE;
-
+
testTextureMipMapGeneration(width, height, pixelFormat, pixelType);
}
-
+
@Test
public void test02_MipMap_ScaleInternal_RGB_BYTE () {
int width = 1;
int height = 7;
int pixelFormat = GL2.GL_RGB;
int pixelType = GL2.GL_BYTE;
-
+
testTextureMipMapGeneration(width, height, pixelFormat, pixelType);
}
-
+
@Test
public void test03_MipMap_ScaleInternal_RGBA_BYTE () {
int width = 1;
int height = 7;
int pixelFormat = GL2.GL_RGBA;
int pixelType = GL2.GL_BYTE;
-
+
testTextureMipMapGeneration(width, height, pixelFormat, pixelType);
}
-
+
@Test
public void test04_MipMap_ScaleInternal_RGB_USHORT () {
int width = 1;
int height = 7;
int pixelFormat = GL2.GL_RGB;
int pixelType = GL2.GL_UNSIGNED_SHORT;
-
+
testTextureMipMapGeneration(width, height, pixelFormat, pixelType);
}
-
+
@Test
public void test05_MipMap_ScaleInternal_RGBA_USHORT () {
int width = 1;
int height = 7;
int pixelFormat = GL2.GL_RGBA;
int pixelType = GL2.GL_UNSIGNED_SHORT;
-
+
testTextureMipMapGeneration(width, height, pixelFormat, pixelType);
}
-
+
@Test
public void test06_MipMap_ScaleInternal_RGB_SHORT () {
int width = 1;
int height = 7;
int pixelFormat = GL2.GL_RGB;
int pixelType = GL2.GL_SHORT;
-
+
testTextureMipMapGeneration(width, height, pixelFormat, pixelType);
}
-
+
@Test
public void test07_MipMap_ScaleInternal_RGBA_SHORT () {
int width = 1;
int height = 7;
int pixelFormat = GL2.GL_RGBA;
int pixelType = GL2.GL_SHORT;
-
+
testTextureMipMapGeneration(width, height, pixelFormat, pixelType);
}
-
+
@Test
public void test08_MipMap_ScaleInternal_RGB_UINT () {
int width = 1;
int height = 7;
int pixelFormat = GL2.GL_RGB;
int pixelType = GL2.GL_UNSIGNED_INT;
-
+
testTextureMipMapGeneration(width, height, pixelFormat, pixelType);
}
-
+
@Test
public void test09_MipMap_ScaleInternal_RGBA_UINT () {
int width = 1;
int height = 7;
int pixelFormat = GL2.GL_RGBA;
int pixelType = GL2.GL_UNSIGNED_INT;
-
+
testTextureMipMapGeneration(width, height, pixelFormat, pixelType);
}
-
+
@Test
public void test10_MipMap_ScaleInternal_RGB_INT () {
int width = 1;
int height = 7;
int pixelFormat = GL2.GL_RGB;
int pixelType = GL2.GL_INT;
-
+
testTextureMipMapGeneration(width, height, pixelFormat, pixelType);
}
-
+
@Test
public void test11_MipMap_ScaleInternal_RGBA_INT () {
int width = 1;
int height = 7;
int pixelFormat = GL2.GL_RGBA;
int pixelType = GL2.GL_INT;
-
+
testTextureMipMapGeneration(width, height, pixelFormat, pixelType);
}
-
+
@Test
public void test12_MipMap_ScaleInternal_RGB_FLOAT () {
int width = 1;
int height = 7;
int pixelFormat = GL2.GL_RGB;
int pixelType = GL2.GL_FLOAT;
-
+
testTextureMipMapGeneration(width, height, pixelFormat, pixelType);
}
-
+
@Test
public void test13_MipMap_ScaleInternal_RGBA_FLOAT () {
int width = 1;
int height = 7;
int pixelFormat = GL2.GL_RGBA;
int pixelType = GL2.GL_FLOAT;
-
+
testTextureMipMapGeneration(width, height, pixelFormat, pixelType);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering2GL2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering2GL2NEWT.java
index d539b5e55..16c1b33f4 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering2GL2NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering2GL2NEWT.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,7 +20,7 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
@@ -60,14 +60,14 @@ import org.junit.runners.MethodSorters;
* </p>
* <p>
* {@link RandomTileRenderer} buffer allocation is performed
- * within the pre {@link GLEventListener}
+ * within the pre {@link GLEventListener}
* set via {@link TileRendererBase#setGLEventListener(GLEventListener, GLEventListener)}
- * on the main thread.
+ * on the main thread.
* </p>
* <p>
* At tile rendering finish, the viewport and
* and the original {@link GLEventListener}'s PMV matrix as well.
- * The latter is done by calling it's {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape} method.
+ * The latter is done by calling it's {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape} method.
* </p>
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@@ -83,7 +83,7 @@ public class TestRandomTiledRendering2GL2NEWT extends UITestCase {
doTest(8);
}
- void doTest(int msaaCount) throws IOException, InterruptedException, InvocationTargetException {
+ void doTest(int msaaCount) throws IOException, InterruptedException, InvocationTargetException {
final GLCapabilities caps = new GLCapabilities(null);
caps.setDoubleBuffered(true);
if( msaaCount > 0 ) {
@@ -93,7 +93,7 @@ public class TestRandomTiledRendering2GL2NEWT extends UITestCase {
final int maxTileSize = 64;
final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile());
- final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, caps, null, maxTileSize, maxTileSize, null);
+ final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, caps, null, maxTileSize, maxTileSize);
final Gears gears = new Gears();
glad.addGLEventListener( gears );
@@ -156,7 +156,7 @@ public class TestRandomTiledRendering2GL2NEWT extends UITestCase {
drawable.getGL().glViewport(0, 0, drawable.getWidth(), drawable.getHeight());
gears.reshape(drawable, 0, 0, drawable.getWidth(), drawable.getHeight());
return false;
- }
+ }
});
glad.destroy();
@@ -168,9 +168,9 @@ public class TestRandomTiledRendering2GL2NEWT extends UITestCase {
caps.getGLProfile(),
0 /* internalFormat */,
imageWidth, imageHeight,
- 0,
+ 0,
imageBuffer.pixelAttributes,
- false, false,
+ false, false,
flipVertically[0],
imageBuffer.buffer,
null /* Flusher */);
@@ -189,5 +189,5 @@ public class TestRandomTiledRendering2GL2NEWT extends UITestCase {
}
}
org.junit.runner.JUnitCore.main(TestRandomTiledRendering2GL2NEWT.class.getName());
- }
+ }
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2NEWT.java
index 74909dc8c..2220c1fb3 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2NEWT.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,7 +20,7 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
@@ -60,14 +60,14 @@ import org.junit.runners.MethodSorters;
* </p>
* <p>
* {@link TileRenderer} buffer allocation is performed
- * within the pre {@link GLEventListener}
+ * within the pre {@link GLEventListener}
* set via {@link TileRendererBase#setGLEventListener(GLEventListener, GLEventListener)}
- * on the main thread.
+ * on the main thread.
* </p>
* <p>
* At tile rendering finish, the viewport and
* and the original {@link GLEventListener}'s PMV matrix as well.
- * The latter is done by calling it's {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape} method.
+ * The latter is done by calling it's {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape} method.
* </p>
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@@ -88,8 +88,8 @@ public class TestTiledRendering2NEWT extends UITestCase {
return null;
}
return glp;
- }
-
+ }
+
@Test
public void test001_off_gl2___aa0() throws IOException {
GLProfile glp = getGLProfile(GLProfile.GL2);
@@ -155,8 +155,8 @@ public class TestTiledRendering2NEWT extends UITestCase {
doTest(true, new GearsES2(), glp, 8);
}
- void doTest(boolean onscreen, final GLEventListener demo, GLProfile glp, final int msaaCount) throws IOException {
- GLCapabilities caps = new GLCapabilities(glp);
+ void doTest(boolean onscreen, final GLEventListener demo, GLProfile glp, final int msaaCount) throws IOException {
+ GLCapabilities caps = new GLCapabilities(glp);
caps.setDoubleBuffered(onscreen);
if( msaaCount > 0 ) {
caps.setSampleBuffers(true);
@@ -172,7 +172,7 @@ public class TestTiledRendering2NEWT extends UITestCase {
glad = glWin;
} else {
final GLDrawableFactory factory = GLDrawableFactory.getFactory(glp);
- glad = factory.createOffscreenAutoDrawable(null, caps, null, maxTileSize, maxTileSize, null);
+ glad = factory.createOffscreenAutoDrawable(null, caps, null, maxTileSize, maxTileSize);
}
glad.addGLEventListener( demo );
@@ -220,7 +220,7 @@ public class TestTiledRendering2NEWT extends UITestCase {
}
renderer.detachAutoDrawable();
-
+
// Restore viewport and Gear's PMV matrix
// .. even though we close the demo, this is for documentation!
glad.invoke(true, new GLRunnable() {
@@ -229,7 +229,7 @@ public class TestTiledRendering2NEWT extends UITestCase {
drawable.getGL().glViewport(0, 0, drawable.getWidth(), drawable.getHeight());
demo.reshape(drawable, 0, 0, drawable.getWidth(), drawable.getHeight());
return false;
- }
+ }
});
final GLPixelBuffer imageBuffer = renderer.getImageBuffer();
@@ -237,15 +237,15 @@ public class TestTiledRendering2NEWT extends UITestCase {
caps.getGLProfile(),
0 /* internalFormat */,
imageWidth, imageHeight,
- 0,
+ 0,
imageBuffer.pixelAttributes,
- false, false,
+ false, false,
flipVertically[0],
imageBuffer.buffer,
null /* Flusher */);
TextureIO.write(textureData, file);
-
+
glad.destroy();
}
@@ -259,5 +259,5 @@ public class TestTiledRendering2NEWT extends UITestCase {
}
}
org.junit.runner.JUnitCore.main(TestTiledRendering2NEWT.class.getName());
- }
+ }
}
diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java
index e85052d08..b1e9f477e 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,12 +20,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.opengl.test.junit.util;
import jogamp.newt.WindowImplAccess;
@@ -40,6 +40,7 @@ import java.awt.Robot;
import javax.media.nativewindow.NativeWindow;
import javax.media.nativewindow.NativeWindowFactory;
import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLContext;
import javax.media.opengl.GLDrawable;
import org.junit.Assert;
@@ -50,17 +51,17 @@ import com.jogamp.newt.event.WindowEvent;
public class AWTRobotUtil {
static final boolean DEBUG = false;
-
+
public static final int RETRY_NUMBER = 5;
public static final int ROBOT_DELAY = 100; // ms
public static final int TIME_OUT = 2000; // 2s
public static final int POLL_DIVIDER = 20; // TO/20
public static final int TIME_SLICE = TIME_OUT / POLL_DIVIDER ;
- public static Integer AWT_CLICK_TO = null;
-
+ public static Integer AWT_CLICK_TO = null;
+
static Object awtEDTAliveSync = new Object();
- static volatile boolean awtEDTAliveFlag = false;
-
+ static volatile boolean awtEDTAliveFlag = false;
+
static class OurUncaughtExceptionHandler implements UncaughtExceptionHandler {
@Override
public void uncaughtException(Thread t, Throwable e) {
@@ -68,16 +69,16 @@ public class AWTRobotUtil {
e.printStackTrace();
}
}
-
+
static {
Thread.setDefaultUncaughtExceptionHandler( new OurUncaughtExceptionHandler() );
// System.err.println("AWT EDT alive: "+isAWTEDTAlive());
}
-
+
/** Probes whether AWT's EDT is alive or not. */
public static boolean isAWTEDTAlive() {
if( EventQueue.isDispatchThread() ) {
- return true;
+ return true;
}
synchronized ( awtEDTAliveSync ) {
awtEDTAliveFlag = false;
@@ -85,7 +86,7 @@ public class AWTRobotUtil {
@Override
public void run() {
awtEDTAliveFlag = true;
- }
+ }
});
for (int wait=0; wait<POLL_DIVIDER && !awtEDTAliveFlag; wait++) {
try {
@@ -103,13 +104,13 @@ public class AWTRobotUtil {
throw new Error("AWT EDT not alive");
}
}
-
+
/** Issuing {@link #validateAWTEDTIsAlive()} before calling {@link Robot#waitForIdle()}. */
public static void waitForIdle(Robot robot) {
validateAWTEDTIsAlive();
robot.waitForIdle();
}
-
+
public static void clearAWTFocus(Robot robot) throws InterruptedException, InvocationTargetException, AWTException {
if(null == robot) {
robot = new Robot();
@@ -123,8 +124,8 @@ public class AWTRobotUtil {
robot.delay(ROBOT_DELAY);
System.err.println("******** clearAWTFocus.X");
}
-
- public static int[] getCenterLocation(Object obj, boolean onTitleBarIfWindow)
+
+ public static int[] getCenterLocation(Object obj, boolean onTitleBarIfWindow)
throws InterruptedException, InvocationTargetException {
if(obj instanceof com.jogamp.newt.Window) {
return getCenterLocationNEWT((com.jogamp.newt.Window)obj, onTitleBarIfWindow);
@@ -132,37 +133,37 @@ public class AWTRobotUtil {
return getCenterLocationAWT((java.awt.Component)obj, onTitleBarIfWindow);
} else {
throw new RuntimeException("Neither AWT nor NEWT: "+obj);
- }
+ }
}
- private static int[] getCenterLocationNEWT(com.jogamp.newt.Window win, boolean onTitleBarIfWindow)
+ private static int[] getCenterLocationNEWT(com.jogamp.newt.Window win, boolean onTitleBarIfWindow)
throws InterruptedException, InvocationTargetException {
- javax.media.nativewindow.util.Point p0 = win.getLocationOnScreen(null);
+ javax.media.nativewindow.util.Point p0 = win.getLocationOnScreen(null);
if( onTitleBarIfWindow ) {
javax.media.nativewindow.util.InsetsImmutable insets = win.getInsets();
- p0.translate(win.getWidth()/2, insets.getTopHeight()/2);
+ p0.translate(win.getWidth()/2, insets.getTopHeight()/2);
} else {
p0.translate(win.getWidth()/2, win.getHeight()/2);
}
- return new int[] { p0.getX(), p0.getY() };
- }
- private static int[] getCenterLocationAWT(java.awt.Component comp, boolean onTitleBarIfWindow)
+ return new int[] { p0.getX(), p0.getY() };
+ }
+ private static int[] getCenterLocationAWT(java.awt.Component comp, boolean onTitleBarIfWindow)
throws InterruptedException, InvocationTargetException {
int x0, y0;
- java.awt.Point p0 = comp.getLocationOnScreen();
+ java.awt.Point p0 = comp.getLocationOnScreen();
java.awt.Rectangle r0 = comp.getBounds();
if( onTitleBarIfWindow && comp instanceof java.awt.Window) {
java.awt.Window window = (java.awt.Window) comp;
java.awt.Insets insets = window.getInsets();
- y0 = (int) ( p0.getY() + insets.top / 2.0 + .5 ) ;
+ y0 = (int) ( p0.getY() + insets.top / 2.0 + .5 ) ;
} else {
y0 = (int) ( p0.getY() + r0.getHeight() / 2.0 + .5 ) ;
}
x0 = (int) ( p0.getX() + r0.getWidth() / 2.0 + .5 ) ;
- return new int[] { x0, y0 };
+ return new int[] { x0, y0 };
}
- public static int[] getClientLocation(Object obj, int x, int y)
+ public static int[] getClientLocation(Object obj, int x, int y)
throws InterruptedException, InvocationTargetException {
if(obj instanceof com.jogamp.newt.Window) {
return getClientLocationNEWT((com.jogamp.newt.Window)obj, x, y);
@@ -170,19 +171,19 @@ public class AWTRobotUtil {
return getClientLocationAWT((java.awt.Component)obj, x, y);
} else {
throw new RuntimeException("Neither AWT nor NEWT: "+obj);
- }
+ }
}
- private static int[] getClientLocationNEWT(com.jogamp.newt.Window win, int x, int y)
+ private static int[] getClientLocationNEWT(com.jogamp.newt.Window win, int x, int y)
throws InterruptedException, InvocationTargetException {
- javax.media.nativewindow.util.Point p0 = win.getLocationOnScreen(null);
- return new int[] { p0.getX(), p0.getY() };
+ javax.media.nativewindow.util.Point p0 = win.getLocationOnScreen(null);
+ return new int[] { p0.getX(), p0.getY() };
}
- private static int[] getClientLocationAWT(java.awt.Component comp, int x, int y)
+ private static int[] getClientLocationAWT(java.awt.Component comp, int x, int y)
throws InterruptedException, InvocationTargetException {
- java.awt.Point p0 = comp.getLocationOnScreen();
- return new int[] { (int)p0.getX(), (int)p0.getY() };
+ java.awt.Point p0 = comp.getLocationOnScreen();
+ return new int[] { (int)p0.getX(), (int)p0.getY() };
}
-
+
/**
* toFront, call setVisible(true) and toFront(),
* after positioning the mouse in the middle of the window via robot.
@@ -196,7 +197,7 @@ public class AWTRobotUtil {
// just for event tracing ..
AWTWindowFocusAdapter winFA = new AWTWindowFocusAdapter("window");
window.addWindowFocusListener(winFA);
-
+
if(null == robot) {
robot = new Robot();
robot.setAutoWaitForIdle(true);
@@ -221,7 +222,7 @@ public class AWTRobotUtil {
wait++;
} while (wait<POLL_DIVIDER && !window.hasFocus());
final boolean success = wait<POLL_DIVIDER;
-
+
window.removeWindowFocusListener(winFA);
if(!success) {
System.err.println("*** AWTRobotUtil.toFrontAndRequestFocus() UI failure");
@@ -236,7 +237,7 @@ public class AWTRobotUtil {
* centerMouse
* @param onTitleBarIfWindow TODO
*/
- public static void centerMouse(Robot robot, Object obj, boolean onTitleBarIfWindow)
+ public static void centerMouse(Robot robot, Object obj, boolean onTitleBarIfWindow)
throws AWTException, InterruptedException, InvocationTargetException {
if(null == robot) {
@@ -251,20 +252,20 @@ public class AWTRobotUtil {
robot.delay(ROBOT_DELAY);
}
- public static void setMouseToClientLocation(Robot robot, Object obj, int x, int y)
+ public static void setMouseToClientLocation(Robot robot, Object obj, int x, int y)
throws AWTException, InterruptedException, InvocationTargetException {
-
+
if(null == robot) {
robot = new Robot();
robot.setAutoWaitForIdle(true);
}
-
+
int[] p0 = getClientLocation(obj, x, y);
robot.mouseMove( p0[0], p0[1] );
robot.delay(ROBOT_DELAY);
}
-
+
public static int getClickTimeout(Object obj) {
if(obj instanceof com.jogamp.newt.Window) {
return com.jogamp.newt.event.MouseEvent.getClickTimeout();
@@ -272,41 +273,41 @@ public class AWTRobotUtil {
if(null == AWT_CLICK_TO) {
AWT_CLICK_TO =
(Integer) java.awt.Toolkit.getDefaultToolkit().getDesktopProperty("awt.multiClickInterval");
- if(null == AWT_CLICK_TO) {
+ if(null == AWT_CLICK_TO) {
AWT_CLICK_TO = new Integer(500);
}
}
return AWT_CLICK_TO.intValue();
} else {
throw new RuntimeException("Neither AWT nor NEWT: "+obj);
- }
+ }
}
-
+
/**
* requestFocus, if robot is valid, use mouse operation,
* otherwise programmatic, ie call requestFocus
*/
- public static void requestFocus(Robot robot, Object obj)
+ public static void requestFocus(Robot robot, Object obj)
throws AWTException, InterruptedException, InvocationTargetException {
requestFocus(robot, obj, true);
}
-
+
/**
* requestFocus, if robot is valid, use mouse operation,
* otherwise programmatic, ie call requestFocus
*/
- public static void requestFocus(Robot robot, Object obj, boolean onTitleBarIfWindow)
+ public static void requestFocus(Robot robot, Object obj, boolean onTitleBarIfWindow)
throws AWTException, InterruptedException, InvocationTargetException {
if(null != robot) {
- final int mouseButton = java.awt.event.InputEvent.BUTTON1_MASK;
+ final int mouseButton = java.awt.event.InputEvent.BUTTON1_MASK;
centerMouse(robot, obj, onTitleBarIfWindow);
-
+
waitForIdle(robot);
robot.mousePress(mouseButton);
robot.mouseRelease(mouseButton);
final int d = getClickTimeout(obj) + 1;
- robot.delay( d );
- System.err.println("requestFocus: click, d: "+d+" ms");
+ robot.delay( d );
+ System.err.println("requestFocus: click, d: "+d+" ms");
} else {
if(obj instanceof com.jogamp.newt.Window) {
requestFocusNEWT((com.jogamp.newt.Window) obj, onTitleBarIfWindow);
@@ -317,12 +318,12 @@ public class AWTRobotUtil {
}
}
}
- private static void requestFocusNEWT(com.jogamp.newt.Window win, boolean onTitleBarIfWindow)
+ private static void requestFocusNEWT(com.jogamp.newt.Window win, boolean onTitleBarIfWindow)
throws AWTException, InterruptedException, InvocationTargetException {
win.requestFocus();
System.err.println("requestFocus: NEWT Component");
}
- private static void requestFocusAWT(final java.awt.Component comp, boolean onTitleBarIfWindow)
+ private static void requestFocusAWT(final java.awt.Component comp, boolean onTitleBarIfWindow)
throws AWTException, InterruptedException, InvocationTargetException {
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
@@ -330,11 +331,11 @@ public class AWTRobotUtil {
System.err.println("requestFocus: AWT Component");
}});
}
-
- public static void requestFocus(Robot robot, Object obj, int x, int y)
+
+ public static void requestFocus(Robot robot, Object obj, int x, int y)
throws AWTException, InterruptedException, InvocationTargetException {
validateAWTEDTIsAlive();
-
+
final boolean idling = robot.isAutoWaitForIdle();
final int mouseButton = java.awt.event.InputEvent.BUTTON1_MASK;
robot.mouseMove( x, y );
@@ -348,7 +349,7 @@ public class AWTRobotUtil {
final int d = getClickTimeout(obj) + 1;
robot.delay( d );
}
-
+
public static boolean hasFocus(Object obj) {
if(obj instanceof com.jogamp.newt.Window) {
return ((com.jogamp.newt.Window) obj).hasFocus();
@@ -388,7 +389,7 @@ public class AWTRobotUtil {
*
* @return True if the Window became the global focused Window within TIME_OUT
*/
- public static boolean waitForFocus(FocusEventCountAdapter gain,
+ public static boolean waitForFocus(FocusEventCountAdapter gain,
FocusEventCountAdapter lost) throws InterruptedException {
int wait;
for (wait=0; wait<POLL_DIVIDER; wait++) {
@@ -399,12 +400,12 @@ public class AWTRobotUtil {
}
return false;
}
-
+
/**
*
* @return True if the Window became the global focused Window within TIME_OUT
*/
- public static boolean waitForFocus(Object obj, FocusEventCountAdapter gain,
+ public static boolean waitForFocus(Object obj, FocusEventCountAdapter gain,
FocusEventCountAdapter lost) throws InterruptedException {
if(!waitForFocus(obj)) {
return false;
@@ -412,13 +413,13 @@ public class AWTRobotUtil {
return waitForFocus(gain, lost);
}
- public static void assertRequestFocusAndWait(Robot robot, Object requestFocus, Object waitForFocus,
+ public static void assertRequestFocusAndWait(Robot robot, Object requestFocus, Object waitForFocus,
FocusEventCountAdapter gain, FocusEventCountAdapter lost)
throws AWTException, InterruptedException, InvocationTargetException {
int i = 0;
boolean hasFocus = false;
-
+
for(i=0; i < RETRY_NUMBER && !hasFocus; i++) {
requestFocus(robot, requestFocus);
hasFocus = waitForFocus(waitForFocus, gain, lost);
@@ -426,7 +427,7 @@ public class AWTRobotUtil {
if(!hasFocus) {
System.err.print("*** AWTRobotUtil.assertRequestFocusAndWait() ");
if( ( null == gain || gain.focusGained() ) && ( null == lost || !lost.focusLost() ) ) {
- // be error tolerant here, some impl. may lack focus-lost events (OS X)
+ // be error tolerant here, some impl. may lack focus-lost events (OS X)
System.err.println("minor UI failure");
hasFocus = true;
} else {
@@ -444,7 +445,7 @@ public class AWTRobotUtil {
}
System.err.println("*** gain: "+gain);
System.err.println("*** lost: "+lost);
- Thread.dumpStack();
+ Thread.dumpStack();
}
Assert.assertTrue("Did not gain focus", hasFocus);
}
@@ -457,15 +458,15 @@ public class AWTRobotUtil {
robot.keyRelease(keyCode);
robot.delay(msDelay);
}
-
+
public static int keyType(int i, Robot robot, int keyCode,
- Object obj, KeyEventCountAdapter counter) throws InterruptedException, AWTException, InvocationTargetException
- {
+ Object obj, KeyEventCountAdapter counter) throws InterruptedException, AWTException, InvocationTargetException
+ {
int tc = 0;
int j;
final long t0 = System.currentTimeMillis();
final int c0 = null!=counter ? counter.getCount() : 0;
-
+
for(j=0; 1 > tc && j<RETRY_NUMBER; j++) {
if(!hasFocus(obj)) {
// focus lost for some reason, regain it programmatic
@@ -491,37 +492,37 @@ public class AWTRobotUtil {
return (int) ( System.currentTimeMillis() - t0 ) ;
}
- /** No validation is performed .. */
+ /** No validation is performed .. */
public static int keyPress(int i, Robot robot, boolean press, int keyCode, int msDelay) {
- final long t0 = System.currentTimeMillis();
+ final long t0 = System.currentTimeMillis();
if(press) {
awtRobotKeyPress(robot, keyCode, msDelay);
} else {
awtRobotKeyRelease(robot, keyCode, msDelay);
}
-
+
return (int) ( System.currentTimeMillis() - t0 ) ;
}
-
- /** No validation is performed .. */
+
+ /** No validation is performed .. */
public static int newtKeyPress(int i, Robot robot, boolean press, short newtKeyCode, int msDelay) {
final int keyCode = AWTNewtEventFactory.newtKeyCode2AWTKeyCode(newtKeyCode);
- final long t0 = System.currentTimeMillis();
+ final long t0 = System.currentTimeMillis();
if(press) {
awtRobotKeyPress(robot, keyCode, msDelay);
} else {
awtRobotKeyRelease(robot, keyCode, msDelay);
}
-
+
return (int) ( System.currentTimeMillis() - t0 ) ;
}
-
+
/**
* @param keyCode TODO
* @param counter shall return the number of keys typed (press + release)
*/
- public static void assertKeyType(Robot robot, int keyCode, int typeCount,
- Object obj, KeyEventCountAdapter counter)
+ public static void assertKeyType(Robot robot, int keyCode, int typeCount,
+ Object obj, KeyEventCountAdapter counter)
throws AWTException, InterruptedException, InvocationTargetException {
if(null == robot) {
@@ -532,16 +533,16 @@ public class AWTRobotUtil {
centerMouse(robot, obj, false);
Assert.assertEquals("Key already pressed", false, counter.isPressed());
-
+
if(DEBUG) {
System.err.println("**************************************");
System.err.println("KC0: "+counter);
}
-
+
final int c0 = counter.getCount();
for(int i=0; i<typeCount; i++) {
- keyType(i, robot, keyCode, obj, counter);
+ keyType(i, robot, keyCode, obj, counter);
}
if(DEBUG) { System.err.println("KC3.0: "+counter); }
@@ -552,8 +553,8 @@ public class AWTRobotUtil {
* @param keyCode TODO
* @param counter shall return the number of keys typed (press + release)
*/
- public static void assertKeyPress(Robot robot, int keyCode, int typeCount,
- Object obj, KeyEventCountAdapter counter)
+ public static void assertKeyPress(Robot robot, int keyCode, int typeCount,
+ Object obj, KeyEventCountAdapter counter)
throws AWTException, InterruptedException, InvocationTargetException {
if(null == robot) {
@@ -564,36 +565,36 @@ public class AWTRobotUtil {
centerMouse(robot, obj, false);
Assert.assertEquals("Key already pressed", false, counter.isPressed());
-
+
if(DEBUG) {
System.err.println("**************************************");
System.err.println("KC0: "+counter);
}
-
+
final int c0 = counter.getCount();
for(int i=0; i<typeCount; i++) {
- keyType(i, robot, keyCode, obj, counter);
+ keyType(i, robot, keyCode, obj, counter);
}
if(DEBUG) { System.err.println("KC3.0: "+counter); }
Assert.assertEquals("Wrong key count", typeCount, counter.getCount()-c0);
}
-
+
static int mouseClick(int i, Robot robot, int mouseButton,
- Object obj, InputEventCountAdapter counter) throws InterruptedException, AWTException, InvocationTargetException
+ Object obj, InputEventCountAdapter counter) throws InterruptedException, AWTException, InvocationTargetException
{
int j;
int tc = 0;
final long t0 = System.currentTimeMillis();
-
+
for(j=0; 1 > tc && j<RETRY_NUMBER; j++) {
if(!hasFocus(obj)) {
// focus lost for some reason, regain it programmatic
if(DEBUG) { System.err.println(i+":"+j+" MC1.0: "+counter+" - regain focus"); }
requestFocus(null, obj);
}
- final int c0 = null != counter ? counter.getCount() : 0;
+ final int c0 = null != counter ? counter.getCount() : 0;
if(DEBUG) { System.err.println(i+":"+j+" MC1.1: "+counter); }
waitForIdle(robot);
robot.mousePress(mouseButton);
@@ -609,13 +610,13 @@ public class AWTRobotUtil {
Assert.assertEquals("Mouse ("+i+":"+j+") not clicked one time", 1, tc);
return (int) ( System.currentTimeMillis() - t0 ) ;
}
-
+
/**
* @param mouseButton ie InputEvent.BUTTON1_MASK
* @param clickCount ie 1, or 2
*/
public static void assertMouseClick(Robot robot, int mouseButton, int clickCount,
- Object obj, InputEventCountAdapter counter)
+ Object obj, InputEventCountAdapter counter)
throws AWTException, InterruptedException, InvocationTargetException {
if(null == robot) {
@@ -628,14 +629,14 @@ public class AWTRobotUtil {
centerMouse(robot, obj, false);
Assert.assertEquals("Mouse already pressed", false, counter.isPressed());
-
+
if(DEBUG) {
System.err.println("**************************************");
System.err.println("MC0: "+counter);
}
-
+
final int c0 = counter.getCount();
-
+
for(int i=0; i<clickCount; i++) {
final int waited = mouseClick(i, robot, mouseButton, obj, counter);
if(DEBUG) { System.err.println(i+": MC2.X: "+counter+", consumed: "+waited); }
@@ -670,7 +671,7 @@ public class AWTRobotUtil {
/**
*
- * @return True if the GLDrawable recives the expected size within TIME_OUT
+ * @return True if the GLDrawable receives the expected size within TIME_OUT
*/
public static boolean waitForSize(GLDrawable drawable, int width, int height) throws InterruptedException {
int wait;
@@ -681,7 +682,6 @@ public class AWTRobotUtil {
}
/**
- *
* @return True if the Component becomes realized (not displayable, native invalid) within TIME_OUT
*/
public static boolean waitForRealized(Object obj, boolean realized) throws InterruptedException {
@@ -719,9 +719,29 @@ public class AWTRobotUtil {
for (wait=0; wait<POLL_DIVIDER && realized != glad.isRealized(); wait++) {
Thread.sleep(TIME_SLICE);
}
- }
+ }
+ } else if(obj instanceof GLAutoDrawable) {
+ GLAutoDrawable glad = (GLAutoDrawable) obj;
+ for (wait=0; wait<POLL_DIVIDER && realized != glad.isRealized(); wait++) {
+ Thread.sleep(TIME_SLICE);
+ }
} else {
- throw new RuntimeException("Neither AWT nor NEWT: "+obj);
+ throw new RuntimeException("Neither AWT nor NEWT nor GLAutoDrawable: "+obj);
+ }
+ return wait<POLL_DIVIDER;
+ }
+
+ /**
+ *
+ * @return True if the GLContext becomes created or not within TIME_OUT
+ */
+ public static boolean waitForCreated(GLContext context, boolean created) throws InterruptedException {
+ if( null == context ) {
+ return !created;
+ }
+ int wait;
+ for (wait=0; wait<POLL_DIVIDER && created != context.isCreated() ; wait++) {
+ Thread.sleep(TIME_SLICE);
}
return wait<POLL_DIVIDER;
}
@@ -732,9 +752,9 @@ public class AWTRobotUtil {
*
* @param obj either an AWT Window (Frame, JFrame) or NEWT Window
* @param willClose indicating that the window will close, hence this method waits for the window to be closed
- * @param wcl the WindowClosingListener to determine whether the AWT or NEWT widget has been closed. It should be attached
- * to the widget ASAP before any other listener, e.g. via {@link #addClosingListener(Object)}.
- * The WindowClosingListener will be reset before attempting to close the widget.
+ * @param wcl the WindowClosingListener to determine whether the AWT or NEWT widget has been closed. It should be attached
+ * to the widget ASAP before any other listener, e.g. via {@link #addClosingListener(Object)}.
+ * The WindowClosingListener will be reset before attempting to close the widget.
* @return True if the Window is closing and closed (if willClose is true), each within TIME_OUT
* @throws InterruptedException
*/
diff --git a/src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java b/src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java
index f83cb515e..e5f13640d 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,12 +20,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.opengl.test.junit.util;
@@ -36,6 +36,10 @@ import java.io.InputStreamReader;
import java.io.OutputStream;
import java.lang.reflect.*;
import java.nio.FloatBuffer;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.media.opengl.GLContext;
import com.jogamp.common.os.Platform;
@@ -48,7 +52,7 @@ public class MiscUtils {
}
return def;
}
-
+
public static int atoi(String str, int def) {
try {
return Integer.parseInt(str);
@@ -57,7 +61,7 @@ public class MiscUtils {
}
return def;
}
-
+
public static long atol(String str, long def) {
try {
return Long.parseLong(str);
@@ -75,23 +79,23 @@ public class MiscUtils {
}
return def;
}
-
+
public static String toHexString(byte hex) {
- return "0x" + Integer.toHexString( (int)hex & 0x000000FF );
+ return "0x" + Integer.toHexString( hex & 0x000000FF );
}
-
+
public static String toHexString(short hex) {
- return "0x" + Integer.toHexString( (int)hex & 0x0000FFFF );
+ return "0x" + Integer.toHexString( hex & 0x0000FFFF );
}
-
+
public static String toHexString(int hex) {
return "0x" + Integer.toHexString( hex );
}
-
+
public static String toHexString(long hex) {
return "0x" + Long.toHexString( hex );
}
-
+
public static void assertFloatBufferEquals(String errmsg, FloatBuffer expected, FloatBuffer actual, float delta) {
if(null == expected && null == actual) {
return;
@@ -104,26 +108,26 @@ public class MiscUtils {
throw new AssertionError(msg+"; Actual is null, but expected not: "+expected);
}
if(expected.remaining() != actual.remaining()) {
- throw new AssertionError(msg+"; Expected has "+expected.remaining()+" remaining, but actual has "+actual.remaining());
+ throw new AssertionError(msg+"; Expected has "+expected.remaining()+" remaining, but actual has "+actual.remaining());
}
final int a0 = expected.position();
final int b0 = actual.position();
for(int i=0; i<expected.remaining(); i++) {
final float ai = expected.get(a0 + i);
final float bi = actual.get(b0 + i);
- final float daibi = Math.abs(ai - bi);
+ final float daibi = Math.abs(ai - bi);
if( daibi > delta ) {
throw new AssertionError(msg+"; Expected @ ["+a0+"+"+i+"] has "+ai+", but actual @ ["+b0+"+"+i+"] has "+bi+", it's delta "+daibi+" > "+delta);
}
}
}
-
+
public static void assertFloatBufferNotEqual(String errmsg, FloatBuffer expected, FloatBuffer actual, float delta) {
if(null == expected || null == actual) {
return;
}
if(expected.remaining() != actual.remaining()) {
- return;
+ return;
}
String msg = null != errmsg ? errmsg + " " : "";
final int a0 = expected.position();
@@ -131,14 +135,14 @@ public class MiscUtils {
for(int i=0; i<expected.remaining(); i++) {
final float ai = expected.get(a0 + i);
final float bi = actual.get(b0 + i);
- final float daibi = Math.abs(ai - bi);
+ final float daibi = Math.abs(ai - bi);
if( daibi > delta ) {
return;
}
}
throw new AssertionError(msg+"; Expected and actual are equal.");
}
-
+
public static boolean setFieldIfExists(Object instance, String fieldName, Object value) {
try {
Field f = instance.getClass().getField(fieldName);
@@ -155,14 +159,14 @@ public class MiscUtils {
}
return false;
}
-
+
public static class StreamDump extends Thread {
final InputStream is;
final StringBuilder outString;
final OutputStream outStream;
final String prefix;
final Object sync;
- volatile boolean eos = false;
+ volatile boolean eos = false;
public StreamDump(OutputStream out, String prefix, InputStream is, Object sync) {
this.is = is;
@@ -178,7 +182,7 @@ public class MiscUtils {
this.prefix = null;
this.sync = sync;
}
-
+
public final boolean eos() { return eos; }
@Override
@@ -208,7 +212,28 @@ public class MiscUtils {
}
}
}
- }
+ }
+
+ public static void dumpSharedGLContext(GLContext self) {
+ int i = 0, j = 0;
+ System.err.println("Myself: hash 0x"+Integer.toHexString(self.hashCode())+", \t(isShared "+self.isShared()+", created "+self.isCreated()+")");
+ {
+ final List<GLContext> set = self.getCreatedShares();
+ for (final Iterator<GLContext> iter = set.iterator(); iter.hasNext(); ) {
+ final GLContext c = iter.next();
+ System.err.println("Ctx #"+(i++)+": hash 0x"+Integer.toHexString(c.hashCode())+", \t(created "+c.isCreated()+")");
+ }
+ }
+ {
+ final List<GLContext> set = self.getDestroyedShares();
+ for (final Iterator<GLContext> iter = set.iterator(); iter.hasNext(); ) {
+ final GLContext c = iter.next();
+ System.err.println("Ctx #"+(j++)+": hash 0x"+Integer.toHexString(c.hashCode())+", \t(created "+c.isCreated()+")");
+ }
+ }
+ System.err.println("\t Total created "+i+" + destroyed "+j+" = "+(i+j));
+ System.err.println();
+ }
}