From 7f7a23dd0ddf106e6f0c69fc2a05ff92ac56200e Mon Sep 17 00:00:00 2001
From: Sven Gothel
- * 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}.
*
* Extensive FBO reconfiguration (size and sample buffer count) and validation are performed.
- *
- * 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}. *
** This test simulates shared off-thread GL context / texture usage, @@ -81,7 +81,7 @@ import org.junit.runners.MethodSorters; *
* This test simulates shared on-thread GL context / texture usage, @@ -79,7 +79,7 @@ import org.junit.runners.MethodSorters; *
* Finally a {@link GLAutoDrawableDelegate} is created with the just created {@link GLDrawable} and {@link GLContext}. - * It is being used to run the {@link GLEventListener}. - *
+ * It is being used to run the {@link GLEventListener}. + * */ @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()- * The created {@link GLOffscreenAutoDrawable} is being used to run the {@link GLEventListener}. - *
+ * The created {@link GLOffscreenAutoDrawable} is being used to run the {@link GLEventListener}. + * */ @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}. *- * The created {@link GLOffscreenAutoDrawable} is being used to run the {@link GLEventListener}. - *
+ * The created {@link GLOffscreenAutoDrawable} is being used to run the {@link GLEventListener}. + * */ @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()+ * The original VBO is created by attaching a GearsES1 instance to + * the master GLAutoDrawable and initializing it. + *
+ *+ * Above method allows random creation of all GLWindow instances. + *
+ *+ * One animator is being used, hence the GLWindow, GLDrawable and GLContext + * creation of all 3 GLWindows is sequential. + *
+ */ @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()+ * Above method allows random creation of the 1st GLCanvas, which triggers + * creation of the dependent other GLCanvas sharing it's GLContext. + *
+ */ +@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+ * The original VBO is created by attaching a GearsES2 instance to + * the master GLAutoDrawable and initializing it. + *
+ *+ * Above method allows random creation of all GLWindow instances. + *
+ *+ * One tests uses only one animator, where the GLWindow, GLDrawable and GLContext + * creation of all 3 GLWindows is sequential. + *
+ *+ * Another tests uses 3 animator, one for each GLWindow, + * where the GLWindow, GLDrawable and GLContext creation + * of all 3 GLWindows is random. + * This fact benefits from the master GLContext/GLAutoDrawable, + * since it is guaranteed it exist and is realized at the time of the shared + * GLWindow creation. + *
+ */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestSharedContextVBOES2NEWT1 extends UITestCase { + static GLProfile glp; + static GLCapabilities caps; + static int width, height; + GLAutoDrawable sharedDrawable; + GearsES2 sharedGears; + + @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); + } + } + + 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 { + 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() { + Assert.assertNotNull(sharedDrawable); + sharedDrawable.destroy(); + sharedDrawable = null; + } + + 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()); + } + + glWindow.setSize(width, height); + + GearsES2 gears = new GearsES2(vsync ? 1 : 0); + if(useShared) { + gears.setSharedGearsObjects(sharedGears.getGear1(), sharedGears.getGear2(), sharedGears.getGear3()); + } + glWindow.addGLEventListener(gears); + + animator.add(glWindow); + animator.start(); + glWindow.setVisible(true); + Assert.assertTrue(AWTRobotUtil.waitForRealized(glWindow, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(glWindow, true)); + 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.assertTrue("Gears not initialized", sharedGears.waitForInit(true)); + Assert.assertEquals("Gears is not shared as expected", useShared, gears.usesSharedGears()); + + return glWindow; + } + + @Test + 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(), + f1.getY()+0, true, false); + GLWindow f3 = runTestGL(animator, f1.getX()+0, + f1.getY()+height+insets.getTotalHeight(), true, false); + 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.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 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(), + f1.getY()+0, true, false); + GLWindow f3 = runTestGL(animator, f1.getX()+0, + f1.getY()+height+insets.getTotalHeight(), true, false); + 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.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 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(), + f1.getY()+0, true, false); + GLWindow f3 = runTestGL(animator3, f1.getX()+0, + f1.getY()+height+insets.getTotalHeight(), true, false); + + try { + Thread.sleep(duration); + } catch(Exception e) { + e.printStackTrace(); + } + animator1.stop(); + animator2.stop(); + animator3.stop(); + + f1.destroy(); + f2.destroy(); + 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 = 1000; // ms + + public static void main(String args[]) { + for(int i=0; i+ * Above method allows random creation of the 1st GLWindow, which triggers + * creation of the dependent other GLWindow sharing it's GLContext. + *
+ */ +@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+ * Above method allows random creation of the 1st GLWindow, which triggers + * creation of the dependent other GLWindow sharing it's GLContext. + *
+ */ +@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
@@ -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
* Bug Reference: https://jogamp.org/bugzilla/show_bug.cgi?id=365
*
- * 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.
*
* This suite of test cases test:
@@ -43,14 +43,14 @@ import com.jogamp.opengl.util.texture.TextureIO;
*
- *
+ *
* @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;
*
* {@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. *
** 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. *
*/ @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; * ** {@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. *
** 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. *
*/ @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