aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/com/jogamp/opengl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-09-15 16:54:52 +0200
committerSven Gothel <[email protected]>2012-09-15 16:54:52 +0200
commit4dd44b985fe0541be3a3bcd9045d201ed3ca2cc5 (patch)
treee14c927a1da9f089297aa291dcd69f2f39b4f15e /src/test/com/jogamp/opengl
parent9036376b7806a5fc61590bf49404eb71830de92f (diff)
Seamless Integration of an FBObject based GLFBODrawable as GLOffscreenAutoDrawable.FBO and as an OffscreenLayerSurface's drawable (OSX) - Fix Bugs 569 and 599
Summary: ========= The new FBObject based GLFBODrawable implementation allows the seamless utilization of FBO offscreen rendering in single buffer, double buffer and MSAA mode. The GLFBODrawable uses a parent drawable based on a dummy surface to allow a GLOffscreenAutoDrawable.FBO creation or a mutable surface supporting an existing offscreen layer surface (OSX CALayer). Offscreen GLDrawable's and GLOffscreenAutoDrawable's can be selected via the GLCapabilities. If simply !onscreen is selected in the caps instance w/o enabling FBO, PBuffer or Bitmap, the factory will automatically choose regarding availability: FBO > PBuffer > Bitmap Double buffering is supported in MSAA more (intrinsic) and explicit in non MSAA. It is preferred when delivering resources (texture id's or framebuffer names) to a shared GLContext. This is demonstrated in (emulates our OSX CALayer implementation): TestFBOOffThreadSharedContextMix2DemosES2NEWT, TestFBOOnThreadSharedContext1DemoES2NEWT and with the OSX JAWT OffscreenLayerSurface itself. FBO is the preferred choice. +++ Offscreen drawables can be resized while maintaining a bound GLContext (e.g. w/ GLAutoDrawable). Previously both, drawable and context, needed to be destroyed and recreated at offscreen resize. Common implementation in GLDrawableHelper is used in the implementations (NEWT's GLWindow, AWT GLCanvas, SWT GLCanvas). +++ Tested: ======= Manually run all unit tests on: - Linux x86_64 NVidia/AMD/Mesa3d(ES) - OSX x86_64 NVidia - Windows x86_64 NVidia - Android arm Mali-400/Tegra-2 No regressions. Disclaimer: =========== This feature is committed almost in one patch. Both previous commits were introducing / fixing the capabilities behavior: 90d45928186f2be99999461cfe45f76a783cc961 9036376b7806a5fc61590bf49404eb71830de92f I have to appologize for the huge size and impact (files and platforms) of this commit however, I could not find a better way to inject this feature in one sane piece. NativeWindow Details: ===================== Complete decoupling of platform impl. detail of surfaces implementing ProxySurface. Used to generalize dummy surfaces and EGL surfaces on top of a native platform surface. - ProxySurface.UpstreamSurfaceHook -> UpstreamSurfaceHook - abstract class ProxySurface -> interface ProxySurface + ProxySurfaceImpl - Misc. implementations JOGL Details: ===================== FBOObject: API Change / Simplification & Usability - Removed reference counter to remove complexity, allow user to choose. - Add 'dispose' flag for detachColorbuffer(..), allowing to keep attachment alive - Fix equals operation of Attachment - Check pre-exising GL errors - Interface Colobuffer gets lifecycle methods - Add static factory methods to create Attachments w/o FBObject instance - Reset: - Clip min size to 1 - Keep alive samplingSink, i.e. don't issue resetMSAATexture2DSink(..). It gets called at syncFramebuffer()/use(..) later on before actual usage. This allows the consumer to utilize the GL_FRONT buffer until (e.g.) swap. - misc bugfixes GLOffscreenAutoDrawable: API Change - Reloc and interfacing - class com.jogamp.opengl.OffscreenAutoDrawable -> javax.media.opengl.* interfaces GLOffscreenAutoDrawable extends GLAutoDrawable GLOffscreenAutoDrawable.FBO extends GLOffscreenAutoDrawable, GLFBODrawable - Added general implementation and FBO specialization - Replacing GLPBuffer (deprecated) .. usable for any offscreen GLDrawable via factory GLAutoDrawable: - Add 'GLDrawable getDelegatedDrawable()' - Refine documentation of setContext(..), remove disclaimer and fixme tags GLDrawableFactory: - Refine API doc and it's selection mechanism for offscreen. - Add createOffscreenDrawable(..) - Add createOffscreenAutoDrawable(..) - Add canCreateFBO(..) - Mark createGLPbuffer(..) deprectated Mark GLPBuffer deprecated New: GLFBODrawable extends GLDrawable GLCanvas (AWT and SWT): Add offscreen resize support w/o GLContext recreation GLAutoDrawableBase .. GLWindow: - Add offscreen resize support w/o GLContext recreation - Remove double swapBuffer call - GLBase/GLContext: - Add: - boolean hasBasicFBOSupport() - boolean hasFullFBOSupport() - int getMaxRenderbufferSamples() - boolean isTextureFormatBGRA8888Available() GLContext: Fix version detection and hasGLSL() - Version detection in setGLFunctionAvailability(..) - Query GL_VERSION ASAP and parse it and compare w/ given major/minor - Use parsed version if valid and lower than given _or_ given is invalid. - Use validated version for caching (procaddr, ..), version number, etc. - Fix hasGLSL() Since 'isGL2ES2()' is true if 'isGL2()' and the latter simply alows GL 1.*, we confine the result to a GL >= 2.0 on desktops. FIXME: May consider GL 1.5 w/ extensions. - return isGL2ES2(); + return isGLES2() || + isGL3() || + isGL2() && ctxMajorVersion>1 ; GLDrawableImpl: - Add 'associateContext(GLContext, boolean)' allowing impl. to have a (weak) reference list of bound context. This is was pulled up from the OSX specific drawable impl. - swapBuffersImpl() -> swapBuffersImpl(boolean doubleBuffered) and call it regardless of single buffering. This is required to propagate this event to impl. properly, i.e. FBODrawable requires a swap notification. - Clarify 'contextMadeCurrent(..)' protocol GLDrawableHelper: - Add resize and recreate offscreen drawable util method - Simplify required init/reshape calls for GLEventListener - GLGraphicsConfigurationUtil: - fixWinAttribBitsAndHwAccel: Reflect sharede context hw-accel bits - OSX has no offscreen bitmap, use pbuffer - use proper offscreen auto selection if offscreen and no modes are set EGL Context/Drawable/DrawableFactory: Abstract native platform code out of base classes - Use EGLWrappedSurface w/ UpstreamSurfaceHook to handle upstream (X11, WGL, ..) lifecycle - in case the EGL resource is hooked up on it. Invisible dummy surfaces: All platforms - size is now reduced to 64x64 and decoupled of actual generic mutable size - fix device lifecycle, no more leaks +++ OSX ==== Enable support for GLFBODrawableImpl in offscreen CALayer mode - NSOpenGLImpl: hooks to calayer native code - calayer code: - allows pbuffer and texures (FBO) - decouple size and draw calls avoiding flickering - enable auto resize of calayer tree MacOSXCGLContext: - NSOpenGLImpl: - Fix false pbuffer 'usage', validate the pointer - If !pbuffer, copy other window mode bits of caps - MacOSXCGLGraphicsConfiguration: - Only assume pbuffer if !onscreen - Remove reference of native pixelformat pointer Native code: - use 'respondsToSelector:' query before calling 'new' methods avoiding an error message where unsuported (prev. OSX versions) - if monitor refresh-rate is queried 0, set to default 60hz - add missing NSAutoreleasePool decoration +++ Android / NEWT: =============== Issue setVisible(..) w/o wait, i.e. queue on EDT, @Android surfaceChanged() callback. Otherwise we could deadlock: setVisible(..) -> EDT -> setVisibleImpl(..) -> 'GL-display'. the latter may may cause havoc while Android-EDT is blocked [until it's return].
Diffstat (limited to 'src/test/com/jogamp/opengl')
-rw-r--r--src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher0.java2
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivityLauncher.java22
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableDeadlockAWT.java128
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableFactoryNEWT.java375
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBODrawableNEWT.java272
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMix2DemosES2NEWT.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java298
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOnThreadSharedContext1DemoES2NEWT.java273
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateNEWT.java152
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateOnOffscrnCapsNEWT.java (renamed from src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLCapabilities01NEWT.java)238
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryOffscrnCapsNEWT.java317
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT.java328
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT.java351
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT.java300
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitchNEWT.java22
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDrawable01NEWT.java171
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLExtensionQueryOffscreen.java19
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java46
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer01GLCanvasAWT.java (renamed from src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingOffscreenLayer01GLCanvasAWT.java)55
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer02NewtCanvasAWT.java (renamed from src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingOffscreenLayer02NewtCanvasAWT.java)86
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPBufferDeadlockAWT.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java20
-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/TestSharedContextListNEWT2.java14
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextNewtAWTBug523.java17
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES1NEWT.java20
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT.java20
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java14
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461FBOSupersamplingSwingAWT.java159
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461PBufferSupersamplingSwingAWT.java (renamed from src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461OffscreenSupersamplingSwingAWT.java)6
-rwxr-xr-xsrc/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java2
-rwxr-xr-xsrc/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1NEWT.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES2NEWT.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java6
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquareES1.java19
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/FBOMix2DemosES2.java5
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java17
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/Mix2TexturesES2.java216
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java21
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java27
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java13
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGLJPanelAWTBug450.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBufferBase.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTGLn.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTJOGLGLCanvas01GLn.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite01AWT.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite01NEWT.java16
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02AWT.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02NEWT.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileAWT.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileNEWT.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java21
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java16
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/TestWindows01NEWT.java1
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java39
-rw-r--r--src/test/com/jogamp/opengl/test/junit/util/NEWTGLContext.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/util/UITestCase.java109
59 files changed, 3353 insertions, 956 deletions
diff --git a/src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher0.java b/src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher0.java
index 4f24fc9b8..c4b74c56f 100644
--- a/src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher0.java
+++ b/src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher0.java
@@ -50,6 +50,8 @@ public class MovieCubeActivityLauncher0 extends LauncherUtil.BaseActivityLaunche
// props.setProperty("jogamp.debug.NativeLibrary", "true");
// props.setProperty("jogamp.debug.NativeLibrary.Lookup", "true");
// props.setProperty("jogamp.debug.IOUtil", "true");
+ // props.setProperty("jogamp.debug.Lock", "true");
+ // props.setProperty("jogamp.debug.Lock.TraceLock", "true");
// props.setProperty("nativewindow.debug", "all");
props.setProperty("nativewindow.debug.GraphicsConfiguration", "true");
// props.setProperty("jogl.debug", "all");
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivityLauncher.java b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivityLauncher.java
index c75c229a8..576305835 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivityLauncher.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivityLauncher.java
@@ -14,23 +14,23 @@ public class NEWTGraphUI1pActivityLauncher extends LauncherUtil.BaseActivityLaun
final OrderedProperties props = getProperties();
// props.setProperty("jogamp.debug.JNILibLoader", "true");
// props.setProperty("jogamp.debug.NativeLibrary", "true");
- // properties.setProperty("jogamp.debug.NativeLibrary.Lookup", "true");
- // properties.setProperty("jogamp.debug.IOUtil", "true");
- // properties.setProperty("nativewindow.debug", "all");
+ // props.setProperty("jogamp.debug.NativeLibrary.Lookup", "true");
+ // props.setProperty("jogamp.debug.IOUtil", "true");
+ // props.setProperty("nativewindow.debug", "all");
props.setProperty("nativewindow.debug.GraphicsConfiguration", "true");
- // properties.setProperty("jogl.debug", "all");
- // properties.setProperty("jogl.debug.GLProfile", "true");
+ // props.setProperty("jogl.debug", "all");
+ // props.setProperty("jogl.debug.GLProfile", "true");
props.setProperty("jogl.debug.GLDrawable", "true");
props.setProperty("jogl.debug.GLContext", "true");
props.setProperty("jogl.debug.GLSLCode", "true");
props.setProperty("jogl.debug.CapabilitiesChooser", "true");
- // properties.setProperty("jogl.debug.GLSLState", "true");
- // properties.setProperty("jogl.debug.DebugGL", "true");
- // properties.setProperty("jogl.debug.TraceGL", "true");
- // properties.setProperty("newt.debug", "all");
+ // props.setProperty("jogl.debug.GLSLState", "true");
+ // props.setProperty("jogl.debug.DebugGL", "true");
+ // props.setProperty("jogl.debug.TraceGL", "true");
+ // props.setProperty("newt.debug", "all");
props.setProperty("newt.debug.Window", "true");
- // properties.setProperty("newt.debug.Window.MouseEvent", "true");
- // properties.setProperty("newt.debug.Window.KeyEvent", "true");
+ // props.setProperty("newt.debug.Window.MouseEvent", "true");
+ // props.setProperty("newt.debug.Window.KeyEvent", "true");
}
@Override
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
new file mode 100644
index 000000000..eab1a37e3
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableDeadlockAWT.java
@@ -0,0 +1,128 @@
+/**
+ * Copyright 2011 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.opengl.test.junit.jogl.acore;
+
+import java.awt.EventQueue;
+import java.lang.reflect.InvocationTargetException;
+
+import javax.media.opengl.DefaultGLCapabilitiesChooser;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLDrawableFactory;
+import javax.media.opengl.GLOffscreenAutoDrawable;
+import javax.media.opengl.GLProfile;
+
+import jogamp.nativewindow.jawt.JAWTUtil;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.jogamp.common.util.RunnableTask;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+
+public class TestFBOAutoDrawableDeadlockAWT extends UITestCase {
+ static GLProfile glp;
+ static int width, height;
+
+ @BeforeClass
+ public static void initClass() {
+ glp = GLProfile.getGL2ES2();
+ Assert.assertNotNull( glp );
+ width = 512;
+ height = 512;
+ }
+
+ protected void runTestGL( GLCapabilities caps ) throws InterruptedException, InvocationTargetException {
+ final GLOffscreenAutoDrawable fbod = GLDrawableFactory.getFactory(caps.getGLProfile()).createOffscreenAutoDrawable(
+ null,
+ caps, new DefaultGLCapabilitiesChooser(),
+ 512, 512,
+ null
+ );
+
+ final boolean[] done = {false};
+ final Runnable pbufferCreationAction = new Runnable() {
+ public void run() {
+ System.err.println("AA.1");
+ fbod.display();
+ done[ 0 ] = true;
+ 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);
+ 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();
+ 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();
+ }
+
+ @Test(timeout = 2000) // 2s timeout
+ public void testDeadlock() throws InterruptedException, InvocationTargetException {
+ GLCapabilities caps = new GLCapabilities( glp );
+ runTestGL( caps );
+ }
+
+ static long duration = 500; // 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();
+ }
+ }
+ }
+ 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
new file mode 100644
index 000000000..2dc547f39
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableFactoryNEWT.java
@@ -0,0 +1,375 @@
+/**
+ * Copyright 2012 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.io.IOException;
+
+import javax.media.opengl.GL;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLDrawableFactory;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLOffscreenAutoDrawable;
+import javax.media.opengl.GLProfile;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.jogamp.opengl.FBObject;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.FBOMix2DemosES2;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.MultisampleDemoES2;
+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}.
+ * <p>
+ * 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>
+ */
+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 {
+ 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 {
+ 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 {
+ 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 {
+ final GLProfile glp = GLProfile.getGL2ES2();
+ final FBOMix2DemosES2 demo = new FBOMix2DemosES2(0);
+ demo.setDoRotation(false);
+ final GLCapabilities caps = new GLCapabilities(glp);
+ caps.setSampleBuffers(true);
+ caps.setNumSamples(4);
+ testGLFBODrawableImpl(caps, demo);
+ }
+
+ @Test
+ public void testEGLES2_Demo0Normal() throws InterruptedException {
+ if( GLProfile.isAvailable(GLProfile.GLES2) ) {
+ final GLProfile glp = GLProfile.get(GLProfile.GLES2);
+ final GLCapabilities caps = new GLCapabilities(glp);
+ testGLFBODrawableImpl(caps, new GearsES2(0));
+ } else {
+ System.err.println("EGL ES2 n/a");
+ }
+ }
+
+ @Test
+ public void testEGLES2_Demo0MSAA4() throws InterruptedException {
+ if( GLProfile.isAvailable(GLProfile.GLES2) ) {
+ final GLProfile glp = GLProfile.get(GLProfile.GLES2);
+ final GLCapabilities caps = new GLCapabilities(glp);
+ caps.setSampleBuffers(true);
+ caps.setNumSamples(4);
+ testGLFBODrawableImpl(caps, new GearsES2(0));
+ } else {
+ System.err.println("EGL ES2 n/a");
+ }
+ }
+
+ void testGLFBODrawableImpl(GLCapabilities caps, GLEventListener demo) throws InterruptedException {
+ 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);
+ 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());
+
+ //
+ // 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);
+ }
+
+ 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));
+ Assert.assertNotSame(colorB, colorA);
+ Assert.assertTrue("Depth attachments are equal: "+depthB+" == "+depthA, !depthB.equals(depthA));
+ Assert.assertNotSame(depthB, depthA);
+ } else {
+ // single buffer
+ Assert.assertEquals(colorA, colorB);
+ Assert.assertSame(colorA, colorB);
+ 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);
+ }
+
+ if( chosenCaps.getNumSamples() > 0 ) {
+ // 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));
+ Assert.assertSame(fboFront, _fboFront);
+ Assert.assertTrue("FBO are not equal: "+fboBack+" != "+_fboBack, fboBack.equals(_fboBack));
+ Assert.assertSame(fboBack, _fboBack);
+ } else if( chosenCaps.getDoubleBuffered() ) {
+ // real double buffer
+ FBObject _fboFront = glad.getFBObject(GL.GL_FRONT);
+ FBObject _fboBack = glad.getFBObject(GL.GL_BACK);
+ Assert.assertTrue("FBO are not equal: "+fboBack+" != "+_fboFront, fboBack.equals(_fboFront));
+ Assert.assertSame(fboBack, _fboFront);
+ Assert.assertTrue("FBO are not equal: "+fboFront+" != "+_fboBack, fboFront.equals(_fboBack));
+ Assert.assertSame(fboFront, _fboBack);
+ } else {
+ // single buffer
+ 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));
+ Assert.assertSame(fboFront, _fboFront);
+ Assert.assertTrue("FBO are not equal: "+fboBack+" != "+_fboFront, fboBack.equals(_fboFront));
+ Assert.assertSame(fboBack, _fboFront);
+ Assert.assertTrue("FBO are not equal: "+fboBack+" != "+_fboBack, fboBack.equals(_fboBack));
+ Assert.assertSame(fboBack, _fboBack);
+ 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(),
+ AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep));
+ snapshotGLEventListener.setMakeSnapshot();
+ glad.display(); // - SWAP_ODD
+ glad.display(); // - SWAP_EVEN
+ {
+ // Check whether the attachment reference are still valid!
+ final FBObject _fboFront = glad.getFBObject(GL.GL_FRONT);
+ final FBObject _fboBack = glad.getFBObject(GL.GL_BACK);
+ System.out.println("Resize1.oldFront: "+fboFront);
+ System.out.println("Resize1.nowFront: "+_fboFront);
+ System.out.println("Resize1.oldBack : "+fboBack);
+ System.out.println("Resize1.nowBack : "+_fboBack);
+ Assert.assertEquals(fboFront, _fboFront);
+ 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(),
+ AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep));
+ snapshotGLEventListener.setMakeSnapshot();
+ glad.display(); // - SWAP_EVEN
+ glad.display(); // - SWAP_ODD
+ {
+ // Check whether the attachment reference are still valid!
+ final FBObject _fboFront = glad.getFBObject(GL.GL_FRONT);
+ final FBObject _fboBack = glad.getFBObject(GL.GL_BACK);
+ System.out.println("Resize2.oldFront: "+fboFront);
+ System.out.println("Resize2.nowFront: "+_fboFront);
+ System.out.println("Resize2.oldBack : "+fboBack);
+ System.out.println("Resize2.nowBack : "+_fboBack);
+ if(chosenCaps.getDoubleBuffered() && 0==chosenCaps.getNumSamples()) {
+ // real double buffer
+ Assert.assertEquals(fboBack, _fboFront);
+ Assert.assertEquals(fboFront, _fboBack);
+ } else {
+ // single or MSAA
+ Assert.assertEquals(fboFront, _fboFront);
+ 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.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(),
+ 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/TestFBODrawableNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBODrawableNEWT.java
deleted file mode 100644
index 7977347a7..000000000
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBODrawableNEWT.java
+++ /dev/null
@@ -1,272 +0,0 @@
-/**
- * Copyright 2012 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.io.IOException;
-
-import javax.media.opengl.GL;
-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.GLEventListener;
-import javax.media.opengl.GLProfile;
-
-import jogamp.opengl.GLFBODrawableImpl;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import com.jogamp.opengl.FBObject;
-import com.jogamp.opengl.OffscreenAutoDrawable;
-import com.jogamp.opengl.test.junit.jogl.demos.es2.FBOMix2DemosES2;
-import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
-import com.jogamp.opengl.test.junit.jogl.demos.es2.MultisampleDemoES2;
-import com.jogamp.opengl.test.junit.util.UITestCase;
-import com.jogamp.opengl.util.GLReadBufferUtil;
-import com.jogamp.opengl.util.texture.TextureIO;
-
-public class TestFBODrawableNEWT extends UITestCase {
-
- static final int widthStep = 800/4;
- static final int heightStep = 600/4;
- volatile int szStep = 2;
-
- @Test
- public void testGL2ES2_Demo1Normal() throws InterruptedException {
- final GLProfile glp = GLProfile.getGL2ES2();
- final GLCapabilities caps = new GLCapabilities(glp);
- testGLFBODrawableImpl(caps, new GearsES2(0));
- }
-
- @Test
- public void testGL2ES2_Demo1MSAA4() throws InterruptedException {
- final GLProfile glp = GLProfile.getGL2ES2();
- final GLCapabilities caps = new GLCapabilities(glp);
- caps.setSampleBuffers(true);
- caps.setNumSamples(4);
- testGLFBODrawableImpl(caps, new GearsES2(0));
- }
-
- @Test
- public void testGL2ES2_Demo2Normal() throws InterruptedException {
- final GLProfile glp = GLProfile.getGL2ES2();
- final GLCapabilities caps = new GLCapabilities(glp);
- testGLFBODrawableImpl(caps, new MultisampleDemoES2(false));
- }
-
- @Test
- 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_FBODemoNormal() throws InterruptedException {
- final GLProfile glp = GLProfile.getGL2ES2();
- final FBOMix2DemosES2 demo = new FBOMix2DemosES2(0);
- demo.setDoRotation(false);
- final GLCapabilities caps = new GLCapabilities(glp);
- testGLFBODrawableImpl(caps, demo);
- }
-
- @Test
- public void testGL2ES2_FBODemoMSAA4() throws InterruptedException {
- final GLProfile glp = GLProfile.getGL2ES2();
- final FBOMix2DemosES2 demo = new FBOMix2DemosES2(0);
- demo.setDoRotation(false);
- final GLCapabilities caps = new GLCapabilities(glp);
- caps.setSampleBuffers(true);
- caps.setNumSamples(4);
- testGLFBODrawableImpl(caps, demo);
- }
-
- @Test
- public void testEGLES2_Demo0Normal() throws InterruptedException {
- if( GLProfile.isAvailable(GLProfile.GLES2) ) {
- final GLProfile glp = GLProfile.get(GLProfile.GLES2);
- final GLCapabilities caps = new GLCapabilities(glp);
- testGLFBODrawableImpl(caps, new GearsES2(0));
- } else {
- System.err.println("EGL ES2 n/a");
- }
- }
-
- @Test
- public void testEGLES2_Demo0MSAA4() throws InterruptedException {
- if( GLProfile.isAvailable(GLProfile.GLES2) ) {
- final GLProfile glp = GLProfile.get(GLProfile.GLES2);
- final GLCapabilities caps = new GLCapabilities(glp);
- caps.setSampleBuffers(true);
- caps.setNumSamples(4);
- testGLFBODrawableImpl(caps, new GearsES2(0));
- } else {
- System.err.println("EGL ES2 n/a");
- }
- }
-
- boolean skipShot = false;
-
- void testGLFBODrawableImpl(GLCapabilities caps, GLEventListener demo) throws InterruptedException {
- final GLReadBufferUtil screenshot = new GLReadBufferUtil(false, false);
- caps.setFBO(true);
- final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile());
- final GLDrawable fboDrawable = factory.createOffscreenDrawable(null, caps, null, widthStep*szStep, heightStep*szStep);
- Assert.assertNotNull(fboDrawable);
- Assert.assertTrue("Not an FBO Drawable", fboDrawable instanceof GLFBODrawableImpl);
-
- fboDrawable.setRealized(true);
- Assert.assertTrue(fboDrawable.isRealized());
-
- final FBObject fbo = ((GLFBODrawableImpl)fboDrawable).getFBObject();
-
- System.out.println("Realized: "+fboDrawable);
- System.out.println("Realized: "+fboDrawable.getChosenGLCapabilities());
- System.out.println("Realized: "+fbo);
-
- final GLContext context = fboDrawable.createContext(null);
- Assert.assertNotNull(context);
-
- int res = context.makeCurrent();
- Assert.assertTrue(GLContext.CONTEXT_CURRENT_NEW==res || GLContext.CONTEXT_CURRENT==res);
- context.release();
-
- System.out.println("Post Create-Ctx: "+fbo);
- final FBObject.Colorbuffer colorA = fbo.getColorbuffer(0);
- Assert.assertNotNull(colorA);
- final FBObject.RenderAttachment depthA = fbo.getDepthAttachment();
- Assert.assertNotNull(depthA);
-
- final OffscreenAutoDrawable glad = new OffscreenAutoDrawable(fboDrawable, context, true);
-
- glad.addGLEventListener(demo);
- glad.addGLEventListener(new GLEventListener() {
- volatile int displayCount=0;
- volatile int reshapeCount=0;
- public void init(GLAutoDrawable drawable) {}
- public void dispose(GLAutoDrawable drawable) {}
- public void display(GLAutoDrawable drawable) {
- final GL gl = drawable.getGL();
- // System.err.println(Thread.currentThread().getName()+": ** display: "+displayCount+": step "+szStep+" "+drawable.getWidth()+"x"+drawable.getHeight());
- // System.err.println(Thread.currentThread().getName()+": ** FBO-THIS: "+fbo);
- // System.err.println(Thread.currentThread().getName()+": ** FBO-SINK: "+fbo.getSamplingSinkFBO());
- // System.err.println(Thread.currentThread().getName()+": ** drawable-read: "+gl.getDefaultReadFramebuffer());
- if(skipShot) {
- skipShot=false;
- } else {
- snapshot(getSimpleTestName("."), displayCount, "msaa"+fbo.getNumSamples(), gl, screenshot, TextureIO.PNG, null);
- }
- Assert.assertEquals(drawable.getWidth(), widthStep*szStep);
- Assert.assertEquals(drawable.getHeight(), heightStep*szStep);
- displayCount++;
- }
- public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
- System.err.println(Thread.currentThread().getName()+": ** reshape: "+reshapeCount+": step "+szStep+" "+width+"x"+height+" - "+drawable.getWidth()+"x"+drawable.getHeight());
- Assert.assertEquals(drawable.getWidth(), widthStep*szStep);
- Assert.assertEquals(drawable.getHeight(), heightStep*szStep);
- reshapeCount++;
- }
- });
-
- // 0 - szStep = 2
- glad.display();
-
- // 1, 2 (resize + display)
- szStep = 1;
- skipShot=true;
- glad.setSize(widthStep*szStep, heightStep*szStep);
- glad.display();
- Assert.assertEquals(glad.getWidth(), widthStep*szStep);
- Assert.assertEquals(glad.getHeight(), heightStep*szStep);
- {
- // Check whether the attachment reference are still valid!
- FBObject.Colorbuffer _colorA = fbo.getColorbuffer(0);
- Assert.assertNotNull(_colorA);
- Assert.assertTrue(colorA == _colorA);
- Assert.assertTrue(colorA.equals(_colorA));
- FBObject.RenderAttachment _depthA = fbo.getDepthAttachment();
- Assert.assertNotNull(_depthA);
- Assert.assertTrue(depthA == _depthA);
- Assert.assertTrue(depthA.equals(_depthA));
-
- _colorA = fbo.getColorbuffer(colorA);
- Assert.assertNotNull(_colorA);
- Assert.assertTrue(colorA == _colorA);
- Assert.assertTrue(colorA.equals(_colorA));
- }
-
- // 3, 4 (resize + display)
- szStep = 4;
- skipShot=true;
- glad.setSize(widthStep*szStep, heightStep*szStep);
- glad.display();
- Assert.assertEquals(glad.getWidth(), widthStep*szStep);
- Assert.assertEquals(glad.getHeight(), heightStep*szStep);
- {
- // Check whether the attachment reference are still valid!
- FBObject.Colorbuffer _colorA = fbo.getColorbuffer(0);
- Assert.assertNotNull(_colorA);
- Assert.assertTrue(colorA == _colorA);
- final FBObject.RenderAttachment _depthA = fbo.getDepthAttachment();
- Assert.assertNotNull(_depthA);
- Assert.assertTrue(depthA == _depthA);
-
- _colorA = fbo.getColorbuffer(colorA);
- Assert.assertNotNull(_colorA);
- Assert.assertTrue(colorA == _colorA);
- }
-
- // 5
- glad.display();
- Assert.assertEquals(glad.getWidth(), widthStep*szStep);
- Assert.assertEquals(glad.getHeight(), heightStep*szStep);
-
- // 6, 7 (resize + display)
- szStep = 3;
- skipShot=true;
- glad.setSize(widthStep*szStep, heightStep*szStep);
- glad.display();
- Assert.assertEquals(glad.getWidth(), widthStep*szStep);
- Assert.assertEquals(glad.getHeight(), heightStep*szStep);
-
- glad.destroy();
- System.out.println("Fin: "+fboDrawable);
-
- // final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(fboDrawable, context);
- }
-
- public static void main(String args[]) throws IOException {
- org.junit.runner.JUnitCore.main(TestFBODrawableNEWT.class.getName());
- }
-
-}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java
index f7c83a03b..077baad43 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java
@@ -229,7 +229,7 @@ public class TestFBOMRTNEWT01 extends UITestCase {
final NativeSurface ns = gl.getContext().getGLReadDrawable().getNativeSurface();
if(last_snap_size[0] != ns.getWidth() && last_snap_size[1] != ns.getHeight()) {
gl.glFinish(); // sync .. no swap buffers yet!
- snapshot(getSimpleTestName("."), step_i, null, gl, screenshot, TextureIO.PNG, null); // overwrite ok
+ snapshot(step_i, null, gl, screenshot, TextureIO.PNG, null); // overwrite ok
last_snap_size[0] = ns.getWidth();
last_snap_size[1] = ns.getHeight();
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMix2DemosES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMix2DemosES2NEWT.java
index b384c9327..b3c542c63 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMix2DemosES2NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMix2DemosES2NEWT.java
@@ -106,7 +106,7 @@ public class TestFBOMix2DemosES2NEWT extends UITestCase {
if(dw<800) {
System.err.println("XXX: "+dw+"x"+dh+", c "+c);
if(0 == c%3) {
- snapshot(getSimpleTestName("."), i++, "msaa"+demo.getMSAA(), drawable.getGL(), screenshot, TextureIO.PNG, null);
+ snapshot(i++, "msaa"+demo.getMSAA(), drawable.getGL(), screenshot, TextureIO.PNG, null);
}
if( 3 == c ) {
new Thread() {
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
new file mode 100644
index 000000000..3ecf89bfc
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java
@@ -0,0 +1,298 @@
+/**
+ * Copyright 2012 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.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+import com.jogamp.newt.event.WindowEvent;
+import com.jogamp.newt.event.WindowAdapter;
+import com.jogamp.newt.opengl.GLWindow;
+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.util.QuitAdapter;
+
+import com.jogamp.opengl.util.Animator;
+import com.jogamp.opengl.util.FPSAnimator;
+import com.jogamp.opengl.util.GLReadBufferUtil;
+import com.jogamp.opengl.util.texture.TextureIO;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.Mix2TexturesES2;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2;
+
+import javax.media.nativewindow.NativeSurface;
+import javax.media.nativewindow.SurfaceUpdatedListener;
+import javax.media.opengl.GL;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLDrawableFactory;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLOffscreenAutoDrawable;
+import javax.media.opengl.GLProfile;
+
+import org.junit.Assert;
+import org.junit.AfterClass;
+import org.junit.Test;
+
+/**
+ * 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}.
+ * </p>
+ * <p>
+ * This test simulates shared off-thread GL context / texture usage,
+ * where the producer use FBOs and delivers shared textures.
+ * The receiver blends the shared textures onscreen.
+ * In detail the test consist of:
+ * <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>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>
+ * </ul></li>
+ * <li>1 onscreen {@link GLWindow}
+ * <ul>
+ * <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>
+ */
+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() {
+ }
+
+ 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);
+ } else {
+ glWindow.setSize(256, 256);
+ }
+ // eager initialization of context
+ glWindow.setVisible(true);
+ 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
+ final GLOffscreenAutoDrawable.FBO fbod1 = (GLOffscreenAutoDrawable.FBO)
+ factory.createOffscreenAutoDrawable(null, fbodCaps, null, glWindow.getWidth(), glWindow.getHeight(), glWindow.getContext());
+ fbod1.setUpstreamWidget(glWindow); // connect the real GLWindow (mouse/key) to offscreen!
+ fbod1.setTextureUnit(fbod1_texUnit);
+ {
+ GearsES2 demo0 = new GearsES2(-1);
+ fbod1.addGLEventListener(demo0);
+ demo0.setIgnoreFocus(true);
+ }
+ fbod1.getNativeSurface().addSurfaceUpdatedListener(new SurfaceUpdatedListener() {
+ @Override
+ public void surfaceUpdated(Object updater, NativeSurface ns, long when) {
+ mixerDemo.setTexID0(fbod1.getTextureBuffer(GL.GL_FRONT).getName());
+ } });
+ 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());
+ fbod2.setTextureUnit(fbod2_texUnit);
+ fbod2.addGLEventListener(new RedSquareES2(-1));
+ fbod2.getNativeSurface().addSurfaceUpdatedListener(new SurfaceUpdatedListener() {
+ @Override
+ public void surfaceUpdated(Object updater, NativeSurface ns, long when) {
+ mixerDemo.setTexID1(fbod2.getTextureBuffer(GL.GL_FRONT).getName());
+ } });
+ fbod2.display(); // init
+ System.err.println("FBOD2 "+fbod2);
+ Assert.assertTrue(fbod2.isInitialized());
+
+ // 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;
+ public void init(GLAutoDrawable drawable) {}
+ 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);
+ }
+ if(9 == c) {
+ c=0;
+ new Thread() {
+ @Override
+ public void run() {
+ glWindow.setSize(dw+256, dh+256);
+ } }.start();
+ }
+ }
+ }
+ 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));
+ //glWindow.addWindowListener(new TraceWindowAdapter(quitAdapter));
+ glWindow.addKeyListener(quitAdapter);
+ glWindow.addWindowListener(quitAdapter);
+
+ glWindow.addWindowListener(new WindowAdapter() {
+ public void windowResized(WindowEvent e) {
+ System.err.println("window resized: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight());
+ }
+ 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);
+ }
+
+ 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));
+ }
+
+ @Test
+ public void test01() throws InterruptedException {
+ GLCapabilities caps = new GLCapabilities(forceES2 ? GLProfile.get(GLProfile.GLES2) : GLProfile.getGL2ES2());
+ caps.setAlphaBits(1);
+ runTestGL(caps);
+ }
+
+ 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++;
+ duration = MiscUtils.atol(args[i], duration);
+ } else if(args[i].equals("-vsync")) {
+ i++;
+ swapInterval = MiscUtils.atoi(args[i], swapInterval);
+ } else if(args[i].equals("-es2")) {
+ forceES2 = true;
+ } else if(args[i].equals("-showFPS")) {
+ showFPS = true;
+ } else if(args[i].equals("-wait")) {
+ waitForKey = true;
+ } else if(args[i].equals("-nomain")) {
+ mainRun = false;
+ }
+ }
+
+ System.err.println("swapInterval "+swapInterval);
+ System.err.println("forceES2 "+forceES2);
+
+ if(waitForKey) {
+ BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
+ System.err.println("Press enter to continue");
+ try {
+ System.err.println(stdin.readLine());
+ } catch (IOException e) { }
+ }
+ org.junit.runner.JUnitCore.main(TestFBOOffThreadSharedContextMix2DemosES2NEWT.class.getName());
+ }
+}
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
new file mode 100644
index 000000000..7d9a9c662
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOnThreadSharedContext1DemoES2NEWT.java
@@ -0,0 +1,273 @@
+/**
+ * Copyright 2012 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.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+import com.jogamp.newt.event.WindowEvent;
+import com.jogamp.newt.event.WindowAdapter;
+import com.jogamp.newt.opengl.GLWindow;
+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.util.QuitAdapter;
+
+import com.jogamp.opengl.util.Animator;
+import com.jogamp.opengl.util.GLReadBufferUtil;
+import com.jogamp.opengl.util.texture.TextureIO;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.Mix2TexturesES2;
+
+import javax.media.nativewindow.NativeSurface;
+import javax.media.nativewindow.SurfaceUpdatedListener;
+import javax.media.opengl.GL;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLDrawableFactory;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLOffscreenAutoDrawable;
+import javax.media.opengl.GLProfile;
+
+import org.junit.Assert;
+import org.junit.AfterClass;
+import org.junit.Test;
+
+/**
+ * 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}.
+ * </p>
+ * <p>
+ * This test simulates shared on-thread GL context / texture usage,
+ * where the producer uses an FBO and delivers a shared texture.
+ * The receiver draws the shared texture onscreen.
+ * In detail the test consist of:
+ * <ul>
+ * <li>1 {@link GLOffscreenAutoDrawable.FBO} double buffered
+ * <ul>
+ * <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>
+ * </ul></li>
+ * <li>1 onscreen {@link GLWindow}
+ * <ul>
+ * <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>
+ */
+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() {
+ }
+
+ 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);
+ } else {
+ glWindow.setSize(256, 256);
+ }
+ // eager initialization of context
+ glWindow.setVisible(true);
+ 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
+ final GLOffscreenAutoDrawable.FBO fbod1 = (GLOffscreenAutoDrawable.FBO)
+ factory.createOffscreenAutoDrawable(null, fbodCaps, null, glWindow.getWidth(), glWindow.getHeight(), glWindow.getContext());
+ fbod1.setUpstreamWidget(glWindow); // connect the real GLWindow (mouse/key) to offscreen!
+ fbod1.setTextureUnit(fbod1_texUnit);
+ {
+ GearsES2 demo0 = new GearsES2(-1);
+ fbod1.addGLEventListener(demo0);
+ demo0.setIgnoreFocus(true);
+ }
+ fbod1.getNativeSurface().addSurfaceUpdatedListener(new SurfaceUpdatedListener() {
+ @Override
+ public void surfaceUpdated(Object updater, NativeSurface ns, long when) {
+ mixerDemo.setTexID0(fbod1.getTextureBuffer(GL.GL_FRONT).getName());
+ } });
+ 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) {
+ fbod1.setSize(glWindow.getWidth(), glWindow.getHeight());
+ }
+ });
+ glWindow.addGLEventListener(mixerDemo);
+ glWindow.addGLEventListener(new GLEventListener() {
+ int i=0, c=0;
+ public void init(GLAutoDrawable drawable) {}
+ 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);
+ }
+ if(9 == c) {
+ c=0;
+ new Thread() {
+ @Override
+ public void run() {
+ glWindow.setSize(dw+256, dh+256);
+ } }.start();
+ }
+ }
+ }
+ 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));
+ //glWindow.addWindowListener(new TraceWindowAdapter(quitAdapter));
+ glWindow.addKeyListener(quitAdapter);
+ glWindow.addWindowListener(quitAdapter);
+
+ glWindow.addWindowListener(new WindowAdapter() {
+ public void windowResized(WindowEvent e) {
+ System.err.println("window resized: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight());
+ }
+ 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);
+ }
+
+ animator1.stop();
+ Assert.assertFalse(animator1.isAnimating());
+ Assert.assertFalse(animator1.isStarted());
+
+ fbod1.destroy();
+
+ glWindow.destroy();
+ Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow, false));
+ }
+
+ @Test
+ public void test01() throws InterruptedException {
+ GLCapabilities caps = new GLCapabilities(forceES2 ? GLProfile.get(GLProfile.GLES2) : GLProfile.getGL2ES2());
+ caps.setAlphaBits(1);
+ runTestGL(caps);
+ }
+
+ 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++;
+ duration = MiscUtils.atol(args[i], duration);
+ } else if(args[i].equals("-vsync")) {
+ i++;
+ swapInterval = MiscUtils.atoi(args[i], swapInterval);
+ } else if(args[i].equals("-es2")) {
+ forceES2 = true;
+ } else if(args[i].equals("-showFPS")) {
+ showFPS = true;
+ } else if(args[i].equals("-wait")) {
+ waitForKey = true;
+ } else if(args[i].equals("-nomain")) {
+ mainRun = false;
+ }
+ }
+
+ System.err.println("swapInterval "+swapInterval);
+ System.err.println("forceES2 "+forceES2);
+
+ if(waitForKey) {
+ BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
+ System.err.println("Press enter to continue");
+ try {
+ System.err.println(stdin.readLine());
+ } catch (IOException e) { }
+ }
+ org.junit.runner.JUnitCore.main(TestFBOOnThreadSharedContext1DemoES2NEWT.class.getName());
+ }
+}
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
deleted file mode 100644
index 96d9b2e28..000000000
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateNEWT.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/**
- * Copyright 2012 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.io.IOException;
-
-import javax.media.opengl.GLAutoDrawable;
-import javax.media.opengl.GLAutoDrawableDelegate;
-import javax.media.opengl.GLCapabilities;
-import javax.media.opengl.GLContext;
-import javax.media.opengl.GLDrawable;
-import javax.media.opengl.GLDrawableFactory;
-import javax.media.opengl.GLException;
-import javax.media.opengl.GLProfile;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import com.jogamp.newt.NewtFactory;
-import com.jogamp.newt.Window;
-import com.jogamp.newt.event.WindowAdapter;
-import com.jogamp.newt.event.WindowEvent;
-import com.jogamp.newt.event.WindowListener;
-import com.jogamp.newt.event.WindowUpdateEvent;
-import com.jogamp.opengl.util.Animator;
-
-import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
-import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
-import com.jogamp.opengl.test.junit.util.QuitAdapter;
-import com.jogamp.opengl.test.junit.util.UITestCase;
-
-/**
- * Demonstrates a full featured custom GLAutoDrawable implementation
- * utilizing {@link GLAutoDrawableDelegate}.
- */
-public class TestGLAutoDrawableDelegateNEWT extends UITestCase {
-
- /** Note: Creates a full featured GLAutoDrawable w/ all window events connected. */
- private GLAutoDrawable createGLAutoDrawable(GLCapabilities caps, int x, int y, int width, int height, WindowListener wl) throws InterruptedException {
- final Window window = NewtFactory.createWindow(caps);
- Assert.assertNotNull(window);
- window.setPosition(x, y);
- window.setSize(width, height);
- window.setVisible(true);
- Assert.assertTrue(AWTRobotUtil.waitForVisible(window, true));
- Assert.assertTrue(AWTRobotUtil.waitForRealized(window, true));
-
- GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile());
- GLDrawable drawable = factory.createGLDrawable(window);
- Assert.assertNotNull(drawable);
-
- drawable.setRealized(true);
- Assert.assertTrue(drawable.isRealized());
-
- GLContext context = drawable.createContext(null);
- Assert.assertNotNull(context);
-
- int res = context.makeCurrent();
- Assert.assertTrue(GLContext.CONTEXT_CURRENT_NEW==res || GLContext.CONTEXT_CURRENT==res);
- context.release();
-
- final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(drawable, context, window, false) {
- @Override
- protected void destroyImplInLock() {
- super.destroyImplInLock(); // destroys drawable/context
- window.destroy(); // destroys the actual window
- }
- };
-
- // add basic window interaction
- window.addWindowListener(new WindowAdapter() {
- @Override
- public void windowRepaint(WindowUpdateEvent e) {
- glad.windowRepaintOp();
- }
- @Override
- public void windowResized(WindowEvent e) {
- glad.windowResizedOp();
- }
- @Override
- public void windowDestroyNotify(WindowEvent e) {
- glad.windowDestroyNotifyOp();
- }
- });
- window.addWindowListener(wl);
-
- return glad;
- }
-
- @Test
- public void test01() throws GLException, InterruptedException {
- final QuitAdapter quitAdapter = new QuitAdapter();
- GLAutoDrawable glad = createGLAutoDrawable(new GLCapabilities(GLProfile.getGL2ES2()), 0, 0, 640, 480, quitAdapter);
- glad.addGLEventListener(new GearsES2(1));
-
- final Animator animator = new Animator(glad);
- animator.setUpdateFPSFrames(60, null);
- animator.start();
-
- while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
- Thread.sleep(100);
- }
-
- animator.stop();
-
- glad.destroy();
- }
-
- static long duration = 2000; // ms
-
- public static void main(String args[]) throws IOException {
- for(int i=0; i<args.length; i++) {
- if(args[i].equals("-time")) {
- i++;
- try {
- duration = Integer.parseInt(args[i]);
- } catch (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(TestGLAutoDrawableDelegateNEWT.class.getName());
- }
-}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLCapabilities01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateOnOffscrnCapsNEWT.java
index cd1107e25..bcd777ef2 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLCapabilities01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateOnOffscrnCapsNEWT.java
@@ -46,42 +46,55 @@ import org.junit.Test;
import com.jogamp.newt.NewtFactory;
import com.jogamp.newt.Window;
+import com.jogamp.newt.event.WindowAdapter;
+import com.jogamp.newt.event.WindowEvent;
+import com.jogamp.newt.event.WindowUpdateEvent;
+import com.jogamp.opengl.GLAutoDrawableDelegate;
import com.jogamp.opengl.JoglVersion;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears;
import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
import com.jogamp.opengl.test.junit.util.UITestCase;
-public class TestGLCapabilities01NEWT extends UITestCase {
- static final int width = 100;
- static final int height = 100;
+/**
+ * Tests using a NEWT {@link Window} for on- and offscreen cases.
+ * <p>
+ * Each test 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>
+ */
+public class TestGLAutoDrawableDelegateOnOffscrnCapsNEWT extends UITestCase {
+ static final int widthStep = 800/4;
+ static final int heightStep = 600/4;
+ volatile int szStep = 2;
- boolean checkProfile(String profile) {
+ static GLCapabilities getCaps(String profile) {
if( !GLProfile.isAvailable(profile) ) {
System.err.println("Profile "+profile+" n/a");
- return false;
+ return null;
}
- return true;
+ 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());
- final GLCapabilitiesImmutable expGLCaps;
- if( GLGraphicsConfigurationUtil.isGLCapabilitiesOffscreenAutoSelection(reqGLCaps) ) {
- final GLDrawableFactory f = GLDrawableFactory.getFactory(reqGLCaps.getGLProfile());
- final boolean fboAvailable = true ; // f.canCreateFBO(null, reqGLCaps.getGLProfile());
- final boolean pbufferAvailable = f.canCreateGLPbuffer(null);
- expGLCaps = GLGraphicsConfigurationUtil.fixGLCapabilities(reqGLCaps, fboAvailable, pbufferAvailable);
- } else {
- expGLCaps = reqGLCaps;
- }
+ final boolean fboAvailable = factory.canCreateFBO(null, reqGLCaps.getGLProfile());
+ final boolean pbufferAvailable = factory.canCreateGLPbuffer(null);
+ final GLCapabilitiesImmutable expGLCaps = GLGraphicsConfigurationUtil.fixGLCapabilities(reqGLCaps, fboAvailable, pbufferAvailable);
System.out.println("Expected GL Caps: "+expGLCaps);
//
// Create native windowing resources .. X11/Win/OSX
//
final Window window = NewtFactory.createWindow(reqGLCaps);
Assert.assertNotNull(window);
- window.setSize(width, height);
+ window.setSize(widthStep*szStep, heightStep*szStep);
window.setVisible(true);
Assert.assertTrue(AWTRobotUtil.waitForVisible(window, true));
Assert.assertTrue(AWTRobotUtil.waitForRealized(window, true));
@@ -98,9 +111,7 @@ public class TestGLCapabilities01NEWT extends UITestCase {
//
// Create native OpenGL resources .. XGL/WGL/CGL ..
// equivalent to GLAutoDrawable methods: setVisible(true)
- //
- final GLDrawableFactory factory = GLDrawableFactory.getFactory(reqGLCaps.getGLProfile());
-
+ //
final GLDrawable drawable = factory.createGLDrawable(window);
Assert.assertNotNull(drawable);
System.out.println("Drawable Pre-GL(0): "+drawable.getClass().getName()+", "+drawable.getNativeSurface().getClass().getName());
@@ -124,10 +135,11 @@ public class TestGLCapabilities01NEWT 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 ..
if(chosenGLCaps.isOnscreen() || chosenGLCaps.isFBO()) {
// dbl buffer may be disabled w/ offscreen pbuffer and bitmap
Assert.assertEquals(expGLCaps.getDoubleBuffered(), chosenGLCaps.getDoubleBuffered());
- }
+ } */
GLContext context = drawable.createContext(null);
Assert.assertNotNull(context);
@@ -136,10 +148,68 @@ public class TestGLCapabilities01NEWT extends UITestCase {
context.release();
System.out.println("Chosen GL Caps(2): "+drawable.getChosenGLCapabilities());
+ System.out.println("Chosen GL CTX (2): "+context.getGLVersion());
System.out.println("Drawable Post-GL(2): "+drawable.getClass().getName()+", "+drawable.getNativeSurface().getClass().getName());
- drawable.setRealized(false);
- window.destroy();
+ final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(drawable, context, window, false, null) {
+ @Override
+ protected void destroyImplInLock() {
+ super.destroyImplInLock(); // destroys drawable/context
+ window.destroy(); // destroys the actual window, incl. the device
+ }
+ };
+
+ window.addWindowListener(new WindowAdapter() {
+ @Override
+ public void windowRepaint(WindowUpdateEvent e) {
+ glad.windowRepaintOp();
+ }
+
+ @Override
+ public void windowResized(WindowEvent e) {
+ glad.windowResizedOp(window.getWidth(), window.getHeight());
+ }
+
+ @Override
+ public void windowDestroyNotify(WindowEvent e) {
+ glad.windowDestroyNotifyOp();
+ }
+ });
+
+ 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(),
+ AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep));
+ snapshotGLEventListener.setMakeSnapshot();
+ glad.display();
+
+ // 2, 3 (resize + display)
+ szStep = 1;
+ window.setSize(widthStep*szStep, heightStep*szStep);
+ 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;
+ window.setSize(widthStep*szStep, heightStep*szStep);
+ 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: "+drawable);
+ System.out.println("Fin Window: "+window);
}
@Test
@@ -156,94 +226,142 @@ public class TestGLCapabilities01NEWT extends UITestCase {
@Test
public void testGL2OnScreenDblBuf() throws InterruptedException {
- if(!checkProfile(GLProfile.GL2)) {
- return;
- }
- final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GL2));
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
+ if(null == reqGLCaps) return;
+ doTest(reqGLCaps, new GearsES2(1));
+ }
+
+ @Test
+ public void testGL2OnScreenSglBuf() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setDoubleBuffered(false);
doTest(reqGLCaps, new GearsES2(1));
}
@Test
public void testGL2OffScreenAutoDblBuf() throws InterruptedException {
- if(!checkProfile(GLProfile.GL2)) {
- return;
- }
- final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GL2));
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
+ if(null == reqGLCaps) return;
reqGLCaps.setOnscreen(false);
doTest(reqGLCaps, new GearsES2(1));
}
@Test
public void testGL2OffScreenFBODblBuf() throws InterruptedException {
- if(!checkProfile(GLProfile.GL2)) {
- return;
- }
- final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GL2));
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ reqGLCaps.setFBO(true);
+ doTest(reqGLCaps, new GearsES2(1));
+ }
+
+ @Test
+ public void testGL2OffScreenFBOSglBuf() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
+ if(null == reqGLCaps) return;
reqGLCaps.setOnscreen(false);
reqGLCaps.setFBO(true);
+ reqGLCaps.setDoubleBuffered(false);
doTest(reqGLCaps, new GearsES2(1));
}
@Test
public void testGL2OffScreenPbufferDblBuf() throws InterruptedException {
- if(!checkProfile(GLProfile.GL2)) {
- return;
- }
- final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GL2));
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ reqGLCaps.setPBuffer(true);
+ doTest(reqGLCaps, new GearsES2(1));
+ }
+
+ @Test
+ public void testGL2OffScreenPbufferSglBuf() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
+ if(null == reqGLCaps) return;
reqGLCaps.setOnscreen(false);
reqGLCaps.setPBuffer(true);
+ reqGLCaps.setDoubleBuffered(false);
doTest(reqGLCaps, new GearsES2(1));
}
@Test
public void testGL2OffScreenBitmapDblBuf() throws InterruptedException {
- if(!checkProfile(GLProfile.GL2)) {
- return;
- }
- final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GL2));
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
+ if(null == reqGLCaps) return;
reqGLCaps.setOnscreen(false);
reqGLCaps.setBitmap(true);
- doTest(reqGLCaps, new GearsES2(1));
+ doTest(reqGLCaps, new Gears(1));
+ }
+
+ @Test
+ public void testGL2OffScreenBitmapSglBuf() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ reqGLCaps.setBitmap(true);
+ reqGLCaps.setDoubleBuffered(false);
+ doTest(reqGLCaps, new Gears(1));
}
@Test
public void testES2OnScreenDblBuf() throws InterruptedException {
- if(!checkProfile(GLProfile.GLES2)) {
- return;
- }
- final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GLES2));
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
+ if(null == reqGLCaps) return;
+ doTest(reqGLCaps, new GearsES2(1));
+ }
+
+ @Test
+ public void testES2OnScreenSglBuf() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setDoubleBuffered(false);
doTest(reqGLCaps, new GearsES2(1));
}
@Test
public void testES2OffScreenAutoDblBuf() throws InterruptedException {
- if(!checkProfile(GLProfile.GLES2)) {
- return;
- }
- final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GLES2));
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
+ if(null == reqGLCaps) return;
reqGLCaps.setOnscreen(false);
doTest(reqGLCaps, new GearsES2(1));
}
@Test
public void testES2OffScreenFBODblBuf() throws InterruptedException {
- if(!checkProfile(GLProfile.GLES2)) {
- return;
- }
- final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GLES2));
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ reqGLCaps.setFBO(true);
+ doTest(reqGLCaps, new GearsES2(1));
+ }
+
+ @Test
+ public void testES2OffScreenFBOSglBuf() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
+ if(null == reqGLCaps) return;
reqGLCaps.setOnscreen(false);
reqGLCaps.setFBO(true);
+ reqGLCaps.setDoubleBuffered(false);
doTest(reqGLCaps, new GearsES2(1));
}
@Test
public void testES2OffScreenPbufferDblBuf() throws InterruptedException {
- if(!checkProfile(GLProfile.GLES2)) {
- return;
- }
- final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GLES2));
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ reqGLCaps.setPBuffer(true);
+ doTest(reqGLCaps, new GearsES2(1));
+ }
+
+ @Test
+ public void testES2OffScreenPbufferSglBuf() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
+ if(null == reqGLCaps) return;
reqGLCaps.setOnscreen(false);
reqGLCaps.setPBuffer(true);
+ reqGLCaps.setDoubleBuffered(false);
doTest(reqGLCaps, new GearsES2(1));
}
@@ -260,7 +378,7 @@ public class TestGLCapabilities01NEWT extends UITestCase {
} */
public static void main(String args[]) throws IOException {
- org.junit.runner.JUnitCore.main(TestGLCapabilities01NEWT.class.getName());
+ org.junit.runner.JUnitCore.main(TestGLAutoDrawableDelegateOnOffscrnCapsNEWT.class.getName());
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryOffscrnCapsNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryOffscrnCapsNEWT.java
new file mode 100644
index 000000000..544d74aa5
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryOffscrnCapsNEWT.java
@@ -0,0 +1,317 @@
+/**
+ * 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.io.IOException;
+
+import javax.media.nativewindow.CapabilitiesImmutable;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLDrawableFactory;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLOffscreenAutoDrawable;
+import javax.media.opengl.GLProfile;
+
+import jogamp.opengl.GLGraphicsConfigurationUtil;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.jogamp.opengl.JoglVersion;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears;
+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}.
+ * <p>
+ * The created {@link GLOffscreenAutoDrawable} is being used to run the {@link GLEventListener}.
+ * </p>
+ */
+public class TestGLAutoDrawableFactoryOffscrnCapsNEWT extends UITestCase {
+ static final int widthStep = 800/4;
+ static final int heightStep = 600/4;
+ volatile int szStep = 2;
+
+ static GLCapabilities getCaps(String profile) {
+ if( !GLProfile.isAvailable(profile) ) {
+ System.err.println("Profile "+profile+" n/a");
+ return null;
+ }
+ 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());
+
+ final boolean fboAvailable = factory.canCreateFBO(null, reqGLCaps.getGLProfile());
+ final boolean pbufferAvailable = factory.canCreateGLPbuffer(null);
+ final GLCapabilitiesImmutable expGLCaps = GLGraphicsConfigurationUtil.fixGLCapabilities(reqGLCaps, fboAvailable, pbufferAvailable);
+ System.out.println("Expected GL Caps: "+expGLCaps);
+
+ //
+ // 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);
+
+ Assert.assertNotNull(glad);
+ 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);
+ Assert.assertNotNull(chosenCaps);
+ Assert.assertTrue(chosenCaps.getGreenBits()>5);
+ Assert.assertTrue(chosenCaps.getBlueBits()>5);
+ Assert.assertTrue(chosenCaps.getRedBits()>5);
+
+ glad.display(); // force native context creation
+
+ // Check caps of GLDrawable after realization
+ final GLCapabilitiesImmutable chosenGLCaps = glad.getChosenGLCapabilities();
+ System.out.println("Chosen GL Caps(1): "+chosenGLCaps);
+ System.out.println("Chosen GL CTX (1): "+glad.getContext().getGLVersion());
+
+ Assert.assertNotNull(chosenGLCaps);
+ Assert.assertTrue(chosenGLCaps.getGreenBits()>5);
+ Assert.assertTrue(chosenGLCaps.getBlueBits()>5);
+ Assert.assertTrue(chosenGLCaps.getRedBits()>5);
+ Assert.assertTrue(chosenGLCaps.getDepthBits()>4);
+ Assert.assertEquals(expGLCaps.isOnscreen(), chosenGLCaps.isOnscreen());
+ 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 ..
+ 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(),
+ 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(),
+ 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(),
+ AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep));
+ snapshotGLEventListener.setMakeSnapshot();
+ glad.display();
+
+ Thread.sleep(50);
+
+ glad.destroy();
+ System.out.println("Fin Drawable: "+glad);
+ }
+
+ @Test
+ public void testAvailableInfo() {
+ GLDrawableFactory f = GLDrawableFactory.getDesktopFactory();
+ if(null != f) {
+ System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString());
+ }
+ f = GLDrawableFactory.getEGLFactory();
+ 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);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ doTest(reqGLCaps, new GearsES2(1));
+ }
+
+ @Test
+ public void testGL2OffScreenFBODblBuf() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ reqGLCaps.setFBO(true);
+ doTest(reqGLCaps, new GearsES2(1));
+ }
+
+ @Test
+ public void testGL2OffScreenFBOSglBuf() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ reqGLCaps.setFBO(true);
+ reqGLCaps.setDoubleBuffered(false);
+ doTest(reqGLCaps, new GearsES2(1));
+ }
+
+ @Test
+ public void testGL2OffScreenFBOStencil() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ reqGLCaps.setFBO(true);
+ reqGLCaps.setStencilBits(1);
+ doTest(reqGLCaps, new GearsES2(1));
+ }
+
+ @Test
+ public void testGL2OffScreenFBOStencilMSAA() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ reqGLCaps.setFBO(true);
+ reqGLCaps.setStencilBits(1);
+ reqGLCaps.setSampleBuffers(true);
+ doTest(reqGLCaps, new GearsES2(1));
+ }
+
+ @Test
+ public void testGL2OffScreenPbufferDblBuf() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ reqGLCaps.setPBuffer(true);
+ doTest(reqGLCaps, new GearsES2(1));
+ }
+
+ @Test
+ public void testGL2OffScreenPbufferSglBuf() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ reqGLCaps.setPBuffer(true);
+ reqGLCaps.setDoubleBuffered(false);
+ doTest(reqGLCaps, new GearsES2(1));
+ }
+
+ @Test
+ public void testGL2OffScreenBitmapDblBuf() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ reqGLCaps.setBitmap(true);
+ doTest(reqGLCaps, new Gears(1));
+ }
+
+ @Test
+ public void testGL2OffScreenBitmapSglBuf() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ reqGLCaps.setBitmap(true);
+ reqGLCaps.setDoubleBuffered(false);
+ doTest(reqGLCaps, new Gears(1));
+ }
+
+ @Test
+ public void testES2OffScreenAutoDblBuf() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ doTest(reqGLCaps, new GearsES2(1));
+ }
+
+ @Test
+ public void testES2OffScreenFBODblBuf() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ reqGLCaps.setFBO(true);
+ doTest(reqGLCaps, new GearsES2(1));
+ }
+
+ @Test
+ public void testES2OffScreenFBOSglBuf() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ reqGLCaps.setFBO(true);
+ reqGLCaps.setDoubleBuffered(false);
+ doTest(reqGLCaps, new GearsES2(1));
+ }
+
+ @Test
+ public void testES2OffScreenPbufferDblBuf() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ reqGLCaps.setPBuffer(true);
+ doTest(reqGLCaps, new GearsES2(1));
+ }
+
+ @Test
+ public void testES2OffScreenPbufferSglBuf() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ reqGLCaps.setPBuffer(true);
+ reqGLCaps.setDoubleBuffered(false);
+ doTest(reqGLCaps, new GearsES2(1));
+ }
+
+ /** Not implemented !
+ @Test
+ public void testES2OffScreenBitmapDblBuf() throws InterruptedException {
+ if(!checkProfile(GLProfile.GLES2)) {
+ return;
+ }
+ final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GLES2));
+ reqGLCaps.setOnscreen(false);
+ reqGLCaps.setBitmap(true);
+ doTest(reqGLCaps, new GearsES2(1));
+ } */
+
+ public static void main(String args[]) throws IOException {
+ org.junit.runner.JUnitCore.main(TestGLAutoDrawableFactoryOffscrnCapsNEWT.class.getName());
+ }
+
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT.java
new file mode 100644
index 000000000..64a75716b
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT.java
@@ -0,0 +1,328 @@
+/**
+ * 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.Dimension;
+import java.awt.Frame;
+import java.io.IOException;
+
+import javax.media.nativewindow.CapabilitiesImmutable;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLDrawable;
+import javax.media.opengl.GLDrawableFactory;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLProfile;
+import javax.media.opengl.awt.GLCanvas;
+
+import jogamp.nativewindow.jawt.JAWTUtil;
+import jogamp.opengl.GLGraphicsConfigurationUtil;
+
+import org.junit.Assert;
+import org.junit.Assume;
+import org.junit.Test;
+
+import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.JoglVersion;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+
+/**
+ * Tests using a NEWT {@link GLWindow} {@link GLAutoDrawable auto drawable} for on- and offscreen cases.
+ * <p>
+ * The NEWT {@link GLAutoDrawable} is being used to run the {@link GLEventListener}.
+ * </p>
+ */
+public class TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT extends UITestCase {
+ static final int widthStep = 800/4;
+ static final int heightStep = 600/4;
+ volatile int szStep = 2;
+
+ static GLCapabilities getCaps(String profile) {
+ if( !GLProfile.isAvailable(profile) ) {
+ System.err.println("Profile "+profile+" n/a");
+ return null;
+ }
+ return new GLCapabilities(GLProfile.get(profile));
+ }
+
+ static void setGLCanvasSize(final Frame frame, final GLCanvas glc, final int width, final int height) {
+ try {
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ final Dimension new_sz = new Dimension(width, height);
+ glc.setMinimumSize(new_sz);
+ glc.setPreferredSize(new_sz);
+ glc.setSize(new_sz);
+ frame.pack();
+ frame.validate();
+ } } );
+ } catch( Throwable throwable ) {
+ throwable.printStackTrace();
+ Assume.assumeNoException( throwable );
+ }
+ }
+
+ static interface MyGLEventListener extends GLEventListener {
+ void setMakeSnapshot();
+ }
+
+ void doTest(GLCapabilitiesImmutable reqGLCaps, GLEventListener demo) throws InterruptedException {
+ if(reqGLCaps.isOnscreen() && JAWTUtil.isOffscreenLayerRequired()) {
+ System.err.println("onscreen layer n/a");
+ return;
+ }
+ if(!reqGLCaps.isOnscreen() && !JAWTUtil.isOffscreenLayerSupported()) {
+ System.err.println("offscreen layer n/a");
+ return;
+ }
+ System.out.println("Requested GL Caps: "+reqGLCaps);
+ final GLDrawableFactory factory = GLDrawableFactory.getFactory(reqGLCaps.getGLProfile());
+
+ final boolean fboAvailable = factory.canCreateFBO(null, reqGLCaps.getGLProfile());
+ final boolean pbufferAvailable = factory.canCreateGLPbuffer(null);
+ final GLCapabilitiesImmutable expGLCaps = GLGraphicsConfigurationUtil.fixGLCapabilities(reqGLCaps, fboAvailable, pbufferAvailable);
+ System.out.println("Expected GL Caps: "+expGLCaps);
+ //
+ // Create native windowing resources .. X11/Win/OSX
+ //
+ final GLCanvas glad = new GLCanvas(reqGLCaps); // will implicit trigger offscreen layer - if !onscreen && supported
+ Assert.assertNotNull(glad);
+ Dimension glc_sz = new Dimension(widthStep*szStep, heightStep*szStep);
+ glad.setMinimumSize(glc_sz);
+ glad.setPreferredSize(glc_sz);
+ glad.setSize(glc_sz);
+ final Frame frame = new Frame(getSimpleTestName("."));
+ Assert.assertNotNull(frame);
+ frame.add(glad);
+
+ try {
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.pack();
+ frame.setVisible(true);
+ }});
+ } catch( Throwable throwable ) {
+ throwable.printStackTrace();
+ Assume.assumeNoException( throwable );
+ }
+
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(glad, true));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(glad, true));
+ System.out.println("Window: "+glad.getClass().getName());
+
+ // Check caps of NativeWindow config w/o GL
+ final CapabilitiesImmutable chosenCaps = glad.getChosenGLCapabilities();
+ System.out.println("Window Caps Pre_GL: "+chosenCaps);
+ Assert.assertNotNull(chosenCaps);
+ Assert.assertTrue(chosenCaps.getGreenBits()>5);
+ Assert.assertTrue(chosenCaps.getBlueBits()>5);
+ Assert.assertTrue(chosenCaps.getRedBits()>5);
+
+ glad.display(); // force native context creation
+
+ //
+ // Create native OpenGL resources .. XGL/WGL/CGL ..
+ // equivalent to GLAutoDrawable methods: setVisible(true)
+ //
+ {
+ final GLDrawable actualDrawable = glad.getDelegatedDrawable();
+ Assert.assertNotNull(actualDrawable);
+ System.out.println("Drawable Pre-GL(0): "+actualDrawable.getClass().getName()+", "+actualDrawable.getNativeSurface().getClass().getName());
+ }
+
+ System.out.println("Window Caps PostGL : "+glad.getChosenGLCapabilities());
+ System.out.println("Drawable Post-GL(1): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName());
+
+ // Check caps of GLDrawable after realization
+ final GLCapabilitiesImmutable chosenGLCaps = glad.getChosenGLCapabilities();
+ System.out.println("Chosen GL Caps(1): "+chosenGLCaps);
+ Assert.assertNotNull(chosenGLCaps);
+ Assert.assertTrue(chosenGLCaps.getGreenBits()>5);
+ Assert.assertTrue(chosenGLCaps.getBlueBits()>5);
+ Assert.assertTrue(chosenGLCaps.getRedBits()>5);
+ Assert.assertTrue(chosenGLCaps.getDepthBits()>4);
+ Assert.assertEquals(expGLCaps.isOnscreen(), chosenGLCaps.isOnscreen());
+ 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 ..
+ if(chosenGLCaps.isOnscreen() || chosenGLCaps.isFBO()) {
+ // dbl buffer may be disabled w/ offscreen pbuffer and bitmap
+ Assert.assertEquals(expGLCaps.getDoubleBuffered(), chosenGLCaps.getDoubleBuffered());
+ } */
+
+ {
+ GLContext context = glad.getContext();
+ System.out.println("Chosen GL CTX (2): "+context.getGLVersion());
+ Assert.assertNotNull(context);
+ Assert.assertTrue(context.isCreated());
+ }
+
+ System.out.println("Chosen GL Caps(2): "+glad.getChosenGLCapabilities());
+ System.out.println("Drawable Post-GL(2): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName());
+
+ 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(),
+ AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep));
+ snapshotGLEventListener.setMakeSnapshot();
+ glad.display();
+
+ // 2, 3 (resize + display)
+ szStep = 1;
+ setGLCanvasSize(frame, glad, widthStep*szStep, heightStep*szStep);
+ Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
+ AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep));
+ glad.display();
+ snapshotGLEventListener.setMakeSnapshot();
+ glad.display();
+
+ // 4, 5 (resize + display)
+ szStep = 4;
+ setGLCanvasSize(frame, glad, widthStep*szStep, heightStep*szStep);
+ Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
+ AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep));
+ glad.display();
+ snapshotGLEventListener.setMakeSnapshot();
+ glad.display();
+
+ Thread.sleep(50);
+
+ try {
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.setVisible(false);
+ frame.remove(glad);
+ frame.dispose();
+ }});
+ } catch( Throwable throwable ) {
+ throwable.printStackTrace();
+ Assume.assumeNoException( throwable );
+ }
+ System.out.println("Fin: "+glad);
+ }
+
+ @Test
+ public void testAvailableInfo() {
+ GLDrawableFactory f = GLDrawableFactory.getDesktopFactory();
+ if(null != f) {
+ System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString());
+ }
+ f = GLDrawableFactory.getEGLFactory();
+ if(null != f) {
+ System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString());
+ }
+ }
+
+ @Test
+ public void testGL2OnScreen() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
+ if(null == reqGLCaps) return;
+ doTest(reqGLCaps, new GearsES2(1));
+ }
+
+ @Test
+ public void testGL2OffScreenAuto() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ doTest(reqGLCaps, new GearsES2(1));
+ }
+
+ @Test
+ public void testGL2OffScreenFBOMSAA() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ reqGLCaps.setFBO(true);
+ reqGLCaps.setSampleBuffers(true);
+ reqGLCaps.setNumSamples(4);
+ doTest(reqGLCaps, new GearsES2(1));
+ }
+
+ @Test
+ public void testGL2OffScreenPbuffer() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ reqGLCaps.setPBuffer(true);
+ doTest(reqGLCaps, new GearsES2(1));
+ }
+
+ @Test
+ public void testES2OnScreen() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
+ if(null == reqGLCaps) return;
+ doTest(reqGLCaps, new GearsES2(1));
+ }
+
+ @Test
+ public void testES2OffScreenAuto() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ doTest(reqGLCaps, new GearsES2(1));
+ }
+
+ @Test
+ public void testES2OffScreenFBOMSAA() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ reqGLCaps.setFBO(true);
+ reqGLCaps.setSampleBuffers(true);
+ reqGLCaps.setNumSamples(4);
+ doTest(reqGLCaps, new GearsES2(1));
+ }
+
+ @Test
+ public void testES2OffScreenPbuffer() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ reqGLCaps.setPBuffer(true);
+ doTest(reqGLCaps, new GearsES2(1));
+ }
+
+
+ public static void main(String args[]) throws IOException {
+ org.junit.runner.JUnitCore.main(TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT.class.getName());
+ }
+
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT.java
new file mode 100644
index 000000000..37ec44566
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT.java
@@ -0,0 +1,351 @@
+/**
+ * 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.io.IOException;
+
+import javax.media.nativewindow.CapabilitiesImmutable;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLDrawable;
+import javax.media.opengl.GLDrawableFactory;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLProfile;
+
+import jogamp.opengl.GLGraphicsConfigurationUtil;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.JoglVersion;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears;
+import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+
+/**
+ * Tests using a NEWT {@link GLWindow} {@link GLAutoDrawable auto drawable} for on- and offscreen cases.
+ * <p>
+ * The NEWT {@link GLAutoDrawable} is being used to run the {@link GLEventListener}.
+ * </p>
+ */
+public class TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT extends UITestCase {
+ static final int widthStep = 800/4;
+ static final int heightStep = 600/4;
+ volatile int szStep = 2;
+
+ static interface MyGLEventListener extends GLEventListener {
+ void setMakeSnapshot();
+ }
+
+ static GLCapabilities getCaps(String profile) {
+ if( !GLProfile.isAvailable(profile) ) {
+ System.err.println("Profile "+profile+" n/a");
+ return null;
+ }
+ 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());
+
+ final boolean fboAvailable = factory.canCreateFBO(null, reqGLCaps.getGLProfile());
+ final boolean pbufferAvailable = factory.canCreateGLPbuffer(null);
+ final GLCapabilitiesImmutable expGLCaps = GLGraphicsConfigurationUtil.fixGLCapabilities(reqGLCaps, fboAvailable, pbufferAvailable);
+ System.out.println("Expected GL Caps: "+expGLCaps);
+ //
+ // Create native windowing resources .. X11/Win/OSX
+ //
+ final GLWindow glad = GLWindow.create(reqGLCaps);
+ Assert.assertNotNull(glad);
+ glad.setSize(widthStep*szStep, heightStep*szStep);
+ glad.setVisible(true);
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(glad, true));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(glad, true));
+ System.out.println("Window: "+glad.getClass().getName());
+
+ // Check caps of NativeWindow config w/o GL
+ final CapabilitiesImmutable chosenCaps = glad.getGraphicsConfiguration().getChosenCapabilities();
+ System.out.println("Window Caps Pre_GL: "+chosenCaps);
+ Assert.assertNotNull(chosenCaps);
+ Assert.assertTrue(chosenCaps.getGreenBits()>5);
+ Assert.assertTrue(chosenCaps.getBlueBits()>5);
+ Assert.assertTrue(chosenCaps.getRedBits()>5);
+
+ //
+ // Create native OpenGL resources .. XGL/WGL/CGL ..
+ // equivalent to GLAutoDrawable methods: setVisible(true)
+ //
+ {
+ final GLDrawable actualDrawable = glad.getDelegatedDrawable();
+ Assert.assertNotNull(actualDrawable);
+ System.out.println("Drawable Pre-GL(0): "+actualDrawable.getClass().getName()+", "+actualDrawable.getNativeSurface().getClass().getName());
+ }
+
+ System.out.println("Window Caps PostGL : "+glad.getGraphicsConfiguration().getChosenCapabilities());
+ System.out.println("Drawable Post-GL(1): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName());
+
+ // Check caps of GLDrawable after realization
+ final GLCapabilitiesImmutable chosenGLCaps = glad.getChosenGLCapabilities();
+ System.out.println("Chosen GL Caps(1): "+chosenGLCaps);
+ Assert.assertNotNull(chosenGLCaps);
+ Assert.assertTrue(chosenGLCaps.getGreenBits()>5);
+ Assert.assertTrue(chosenGLCaps.getBlueBits()>5);
+ Assert.assertTrue(chosenGLCaps.getRedBits()>5);
+ Assert.assertTrue(chosenGLCaps.getDepthBits()>4);
+ Assert.assertEquals(expGLCaps.isOnscreen(), chosenGLCaps.isOnscreen());
+ 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 ..
+ if(chosenGLCaps.isOnscreen() || chosenGLCaps.isFBO()) {
+ // dbl buffer may be disabled w/ offscreen pbuffer and bitmap
+ Assert.assertEquals(expGLCaps.getDoubleBuffered(), chosenGLCaps.getDoubleBuffered());
+ } */
+
+ glad.display();
+ {
+ GLContext context = glad.getContext();
+ System.out.println("Chosen GL CTX (2): "+context.getGLVersion());
+ Assert.assertNotNull(context);
+ Assert.assertTrue(context.isCreated());
+ }
+
+ System.out.println("Chosen GL Caps(2): "+glad.getChosenGLCapabilities());
+ System.out.println("Drawable Post-GL(2): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName());
+
+ 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(),
+ 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(),
+ 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(),
+ AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep));
+ snapshotGLEventListener.setMakeSnapshot();
+ glad.display();
+
+ Thread.sleep(50);
+
+ glad.destroy();
+ System.out.println("Fin: "+glad);
+ }
+
+ @Test
+ public void testAvailableInfo() {
+ GLDrawableFactory f = GLDrawableFactory.getDesktopFactory();
+ if(null != f) {
+ System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString());
+ }
+ f = GLDrawableFactory.getEGLFactory();
+ if(null != f) {
+ System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString());
+ }
+ }
+
+ @Test
+ public void testGL2OnScreenDblBuf() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
+ if(null == reqGLCaps) return;
+ doTest(reqGLCaps, new GearsES2(1));
+ }
+
+ @Test
+ public void testGL2OnScreenSglBuf() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setDoubleBuffered(false);
+ doTest(reqGLCaps, new GearsES2(1));
+ }
+
+ @Test
+ public void testGL2OffScreenAutoDblBuf() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ doTest(reqGLCaps, new GearsES2(1));
+ }
+
+ @Test
+ public void testGL2OffScreenFBODblBuf() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ reqGLCaps.setFBO(true);
+ doTest(reqGLCaps, new GearsES2(1));
+ }
+
+ @Test
+ public void testGL2OffScreenFBOSglBuf() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ reqGLCaps.setFBO(true);
+ reqGLCaps.setDoubleBuffered(false);
+ doTest(reqGLCaps, new GearsES2(1));
+ }
+
+ @Test
+ public void testGL2OffScreenPbufferDblBuf() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ reqGLCaps.setPBuffer(true);
+ doTest(reqGLCaps, new GearsES2(1));
+ }
+
+ @Test
+ public void testGL2OffScreenPbufferSglBuf() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ reqGLCaps.setPBuffer(true);
+ reqGLCaps.setDoubleBuffered(false);
+ doTest(reqGLCaps, new GearsES2(1));
+ }
+
+ @Test
+ public void testGL2OffScreenBitmapDblBuf() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ reqGLCaps.setBitmap(true);
+ doTest(reqGLCaps, new Gears(1));
+ }
+
+ @Test
+ public void testGL2OffScreenBitmapSglBuf() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ reqGLCaps.setBitmap(true);
+ reqGLCaps.setDoubleBuffered(false);
+ doTest(reqGLCaps, new Gears(1));
+ }
+
+ @Test
+ public void testES2OnScreenDblBuf() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
+ if(null == reqGLCaps) return;
+ doTest(reqGLCaps, new GearsES2(1));
+ }
+
+ @Test
+ public void testES2OnScreenSglBuf() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setDoubleBuffered(false);
+ doTest(reqGLCaps, new GearsES2(1));
+ }
+
+ @Test
+ public void testES2OffScreenAutoDblBuf() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ doTest(reqGLCaps, new GearsES2(1));
+ }
+
+ @Test
+ public void testES2OffScreenFBODblBuf() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ reqGLCaps.setFBO(true);
+ doTest(reqGLCaps, new GearsES2(1));
+ }
+
+ @Test
+ public void testES2OffScreenFBOSglBuf() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ reqGLCaps.setFBO(true);
+ reqGLCaps.setDoubleBuffered(false);
+ doTest(reqGLCaps, new GearsES2(1));
+ }
+
+ @Test
+ public void testES2OffScreenPbufferDblBuf() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ reqGLCaps.setPBuffer(true);
+ doTest(reqGLCaps, new GearsES2(1));
+ }
+
+ @Test
+ public void testES2OffScreenPbufferSglBuf() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setOnscreen(false);
+ reqGLCaps.setPBuffer(true);
+ reqGLCaps.setDoubleBuffered(false);
+ doTest(reqGLCaps, new GearsES2(1));
+ }
+
+ /** Not implemented !
+ @Test
+ public void testES2OffScreenBitmapDblBuf() throws InterruptedException {
+ if(!checkProfile(GLProfile.GLES2)) {
+ return;
+ }
+ final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GLES2));
+ reqGLCaps.setOnscreen(false);
+ reqGLCaps.setBitmap(true);
+ doTest(reqGLCaps, new GearsES2(1));
+ } */
+
+ public static void main(String args[]) throws IOException {
+ org.junit.runner.JUnitCore.main(TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT.class.getName());
+ }
+
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT.java
new file mode 100644
index 000000000..47fc99844
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT.java
@@ -0,0 +1,300 @@
+/**
+ * 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.Component;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.io.IOException;
+
+import javax.media.nativewindow.CapabilitiesImmutable;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLDrawable;
+import javax.media.opengl.GLDrawableFactory;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLProfile;
+
+import jogamp.nativewindow.jawt.JAWTUtil;
+import jogamp.opengl.GLGraphicsConfigurationUtil;
+
+import org.junit.Assert;
+import org.junit.Assume;
+import org.junit.Test;
+
+import com.jogamp.newt.awt.NewtCanvasAWT;
+import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.JoglVersion;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+
+/**
+ * Tests using a NEWT {@link GLWindow} {@link GLAutoDrawable auto drawable} for on- and offscreen cases.
+ * <p>
+ * The NEWT {@link GLAutoDrawable} is being used to run the {@link GLEventListener}.
+ * </p>
+ */
+public class TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT extends UITestCase {
+ static final int widthStep = 800/4;
+ static final int heightStep = 600/4;
+ volatile int szStep = 2;
+
+ static GLCapabilities getCaps(String profile) {
+ if( !GLProfile.isAvailable(profile) ) {
+ System.err.println("Profile "+profile+" n/a");
+ return null;
+ }
+ return new GLCapabilities(GLProfile.get(profile));
+ }
+
+ static void setComponentSize(final Frame frame, final Component comp, final int width, final int height) {
+ try {
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ final Dimension new_sz = new Dimension(width, height);
+ comp.setMinimumSize(new_sz);
+ comp.setPreferredSize(new_sz);
+ comp.setSize(new_sz);
+ frame.pack();
+ frame.validate();
+ } } );
+ } catch( Throwable throwable ) {
+ throwable.printStackTrace();
+ Assume.assumeNoException( throwable );
+ }
+ }
+
+ static interface MyGLEventListener extends GLEventListener {
+ void setMakeSnapshot();
+ }
+
+ void doTest(boolean offscreenLayer, GLCapabilitiesImmutable reqGLCaps, GLEventListener demo) throws InterruptedException {
+ if(!offscreenLayer && JAWTUtil.isOffscreenLayerRequired()) {
+ System.err.println("onscreen layer n/a");
+ return;
+ }
+ if(offscreenLayer && !JAWTUtil.isOffscreenLayerSupported()) {
+ System.err.println("offscreen layer n/a");
+ return;
+ }
+ System.out.println("Requested GL Caps: "+reqGLCaps);
+ final GLDrawableFactory factory = GLDrawableFactory.getFactory(reqGLCaps.getGLProfile());
+
+ final boolean fboAvailable = factory.canCreateFBO(null, reqGLCaps.getGLProfile());
+ final boolean pbufferAvailable = factory.canCreateGLPbuffer(null);
+ final GLCapabilitiesImmutable expGLCaps = offscreenLayer ?
+ GLGraphicsConfigurationUtil.fixOffscreenGLCapabilities(reqGLCaps, fboAvailable, pbufferAvailable) :
+ GLGraphicsConfigurationUtil.fixGLCapabilities(reqGLCaps, fboAvailable, pbufferAvailable);
+ System.out.println("Expected GL Caps: "+expGLCaps);
+
+ final GLWindow glad = GLWindow.create(reqGLCaps);
+ Assert.assertNotNull(glad);
+
+
+ final NewtCanvasAWT nca = new NewtCanvasAWT(glad);
+ Assert.assertNotNull(nca);
+ Dimension size0 = new Dimension(widthStep*szStep, heightStep*szStep);
+ nca.setShallUseOffscreenLayer(offscreenLayer); // trigger offscreen layer - if supported
+ nca.setPreferredSize(size0);
+ nca.setMinimumSize(size0);
+ nca.setSize(size0);
+
+ final Frame frame = new Frame(getSimpleTestName("."));
+ Assert.assertNotNull(frame);
+ frame.add(nca);
+
+ try {
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.pack();
+ frame.setVisible(true);
+ }});
+ } catch( Throwable throwable ) {
+ throwable.printStackTrace();
+ Assume.assumeNoException( throwable );
+ }
+
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(glad, true));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(glad, true));
+ System.out.println("Window: "+glad.getClass().getName());
+
+ // Check caps of NativeWindow config w/o GL
+ final CapabilitiesImmutable chosenCaps = glad.getChosenGLCapabilities();
+ System.out.println("Window Caps Pre_GL: "+chosenCaps);
+ Assert.assertNotNull(chosenCaps);
+ Assert.assertTrue(chosenCaps.getGreenBits()>5);
+ Assert.assertTrue(chosenCaps.getBlueBits()>5);
+ Assert.assertTrue(chosenCaps.getRedBits()>5);
+
+ glad.display(); // force native context creation
+
+ //
+ // Create native OpenGL resources .. XGL/WGL/CGL ..
+ // equivalent to GLAutoDrawable methods: setVisible(true)
+ //
+ {
+ final GLDrawable actualDrawable = glad.getDelegatedDrawable();
+ Assert.assertNotNull(actualDrawable);
+ System.out.println("Drawable Pre-GL(0): "+actualDrawable.getClass().getName()+", "+actualDrawable.getNativeSurface().getClass().getName());
+ }
+
+ System.out.println("Window Caps PostGL : "+glad.getChosenGLCapabilities());
+ System.out.println("Drawable Post-GL(1): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName());
+
+ // Check caps of GLDrawable after realization
+ final GLCapabilitiesImmutable chosenGLCaps = glad.getChosenGLCapabilities();
+ System.out.println("Chosen GL Caps(1): "+chosenGLCaps);
+ Assert.assertNotNull(chosenGLCaps);
+ Assert.assertTrue(chosenGLCaps.getGreenBits()>5);
+ Assert.assertTrue(chosenGLCaps.getBlueBits()>5);
+ Assert.assertTrue(chosenGLCaps.getRedBits()>5);
+ Assert.assertTrue(chosenGLCaps.getDepthBits()>4);
+ Assert.assertEquals(expGLCaps.isOnscreen(), chosenGLCaps.isOnscreen());
+ 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 ..
+ if(chosenGLCaps.isOnscreen() || chosenGLCaps.isFBO()) {
+ // dbl buffer may be disabled w/ offscreen pbuffer and bitmap
+ Assert.assertEquals(expGLCaps.getDoubleBuffered(), chosenGLCaps.getDoubleBuffered());
+ } */
+
+ {
+ GLContext context = glad.getContext();
+ System.out.println("Chosen GL CTX (2): "+context.getGLVersion());
+ Assert.assertNotNull(context);
+ Assert.assertTrue(context.isCreated());
+ }
+
+ System.out.println("Chosen GL Caps(2): "+glad.getChosenGLCapabilities());
+ System.out.println("Drawable Post-GL(2): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName());
+
+ 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(),
+ AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep));
+ snapshotGLEventListener.setMakeSnapshot();
+ glad.display();
+
+ // 2, 3 (resize + display)
+ szStep = 1;
+ setComponentSize(frame, nca, widthStep*szStep, heightStep*szStep);
+ Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
+ AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep));
+ glad.display();
+ snapshotGLEventListener.setMakeSnapshot();
+ glad.display();
+
+ // 4, 5 (resize + display)
+ szStep = 4;
+ setComponentSize(frame, nca, widthStep*szStep, heightStep*szStep);
+ Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
+ AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep));
+ glad.display();
+ snapshotGLEventListener.setMakeSnapshot();
+ glad.display();
+
+ Thread.sleep(50);
+
+ try {
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.setVisible(false);
+ frame.remove(nca);
+ frame.dispose();
+ }});
+ } catch( Throwable throwable ) {
+ throwable.printStackTrace();
+ Assume.assumeNoException( throwable );
+ }
+ glad.destroy();
+ System.out.println("Fin: "+nca);
+ System.out.println("Fin: "+glad);
+ }
+
+ @Test
+ public void testAvailableInfo() {
+ GLDrawableFactory f = GLDrawableFactory.getDesktopFactory();
+ if(null != f) {
+ System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString());
+ }
+ f = GLDrawableFactory.getEGLFactory();
+ if(null != f) {
+ System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString());
+ }
+ }
+
+ @Test
+ public void testGL2OnScreenDblBuf() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
+ if(null == reqGLCaps) return;
+ doTest(false, reqGLCaps, new GearsES2(1));
+ }
+
+ @Test
+ public void testGL2OffScreenLayerAuto() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
+ if(null == reqGLCaps) return;
+ doTest(true, reqGLCaps, new GearsES2(1));
+ }
+
+ @Test
+ public void testGL2OffScreenFBOMSAA() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setFBO(true);
+ reqGLCaps.setOnscreen(true); // get native NEWT Window, not OffscreenWindow
+ reqGLCaps.setSampleBuffers(true);
+ reqGLCaps.setNumSamples(4);
+ doTest(true, reqGLCaps, new GearsES2(1));
+ }
+
+ @Test
+ public void testGL2OffScreenPbuffer() throws InterruptedException {
+ final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
+ if(null == reqGLCaps) return;
+ reqGLCaps.setPBuffer(true);
+ reqGLCaps.setOnscreen(true); // get native NEWT Window, not OffscreenWindow
+ doTest(true, reqGLCaps, new GearsES2(1));
+ }
+
+ public static void main(String args[]) throws IOException {
+ org.junit.runner.JUnitCore.main(TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT.class.getName());
+ }
+
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitchNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitchNEWT.java
index cece4c6d5..4c1130498 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitchNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitchNEWT.java
@@ -39,13 +39,14 @@ import com.jogamp.newt.event.WindowUpdateEvent;
import com.jogamp.newt.opengl.GLWindow;
import javax.media.opengl.GLAutoDrawable;
-import javax.media.opengl.GLAutoDrawableDelegate;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLContext;
import javax.media.opengl.GLDrawable;
import javax.media.opengl.GLDrawableFactory;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLProfile;
+
+import com.jogamp.opengl.GLAutoDrawableDelegate;
import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
@@ -81,14 +82,17 @@ public class TestGLContextDrawableSwitchNEWT extends UITestCase {
Assert.assertTrue(AWTRobotUtil.waitForVisible(window, true));
Assert.assertTrue(AWTRobotUtil.waitForRealized(window, true));
- GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile());
- GLDrawable drawable = factory.createGLDrawable(window);
+ final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile());
+ final GLDrawable drawable = factory.createGLDrawable(window);
Assert.assertNotNull(drawable);
drawable.setRealized(true);
Assert.assertTrue(drawable.isRealized());
- final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(drawable, null, window, false) {
+ final GLContext context = drawable.createContext(null);
+ Assert.assertNotNull(context);
+
+ final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(drawable, context, window, false, null) {
@Override
protected void destroyImplInLock() {
super.destroyImplInLock();
@@ -104,7 +108,7 @@ public class TestGLContextDrawableSwitchNEWT extends UITestCase {
}
@Override
public void windowResized(WindowEvent e) {
- glad.windowResizedOp();
+ glad.windowResizedOp(window.getWidth(), window.getHeight());
}
@Override
public void windowDestroyNotify(WindowEvent e) {
@@ -123,9 +127,13 @@ public class TestGLContextDrawableSwitchNEWT extends UITestCase {
GLAutoDrawable glad1 = createGLAutoDrawable(caps, 64, 64, width, height, quitAdapter); // no GLContext!
GLAutoDrawable glad2 = createGLAutoDrawable(caps, 2*64+width, 64, width+100, height+100, quitAdapter); // no GLContext!
- // create single context using glad1 and assign it to glad1
+ // create single context using glad1 and assign it to glad1,
+ // after destroying the prev. context!
{
- GLContext singleCtx = glad1.createContext(null);
+ final GLContext oldCtx = glad1.getContext();
+ Assert.assertNotNull(oldCtx);
+ oldCtx.destroy();
+ final GLContext singleCtx = glad1.createContext(null);
Assert.assertNotNull(singleCtx);
int res = singleCtx.makeCurrent();
Assert.assertTrue(GLContext.CONTEXT_CURRENT_NEW==res || GLContext.CONTEXT_CURRENT==res);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDrawable01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDrawable01NEWT.java
deleted file mode 100644
index a6e9cfb07..000000000
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDrawable01NEWT.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/**
- * 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.io.IOException;
-
-import javax.media.nativewindow.CapabilitiesImmutable;
-import javax.media.opengl.GL;
-import javax.media.opengl.GLCapabilities;
-import javax.media.opengl.GLCapabilitiesImmutable;
-import javax.media.opengl.GLContext;
-import javax.media.opengl.GLDrawable;
-import javax.media.opengl.GLDrawableFactory;
-import javax.media.opengl.GLProfile;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import com.jogamp.newt.NewtFactory;
-import com.jogamp.newt.Window;
-import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
-import com.jogamp.opengl.test.junit.util.UITestCase;
-
-public class TestGLDrawable01NEWT extends UITestCase {
- static final int width = 200, height = 200;
-
- void doTest(String profile, boolean onscreen, boolean fbo, boolean pbuffer) throws InterruptedException {
- if( !GLProfile.isAvailable(profile) ) {
- System.err.println("Profile "+profile+" n/a");
- return;
- }
-
- final GLProfile glp = GLProfile.get(profile);
- final GLCapabilities reqGLCaps = new GLCapabilities(glp);
-
- reqGLCaps.setOnscreen(onscreen);
- reqGLCaps.setPBuffer(!onscreen && pbuffer);
- reqGLCaps.setFBO(!onscreen && fbo);
- reqGLCaps.setDoubleBuffered(onscreen);
- // System.out.println("Requested: "+caps);
-
- //
- // Create native windowing resources .. X11/Win/OSX
- //
- Window window = NewtFactory.createWindow(reqGLCaps);
- Assert.assertNotNull(window);
- window.setSize(width, height);
- window.setVisible(true);
- AWTRobotUtil.waitForVisible(window, true);
- AWTRobotUtil.waitForRealized(window, true);
- // System.out.println("Created: "+window);
-
- // Check caps of NativeWindow config w/o GL
- final CapabilitiesImmutable chosenCaps = window.getGraphicsConfiguration().getChosenCapabilities();
- Assert.assertNotNull(chosenCaps);
- Assert.assertTrue(chosenCaps.getGreenBits()>5);
- Assert.assertTrue(chosenCaps.getBlueBits()>5);
- Assert.assertTrue(chosenCaps.getRedBits()>5);
-
- //
- // Create native OpenGL resources .. XGL/WGL/CGL ..
- // equivalent to GLAutoDrawable methods: setVisible(true)
- //
- final GLDrawableFactory factory = GLDrawableFactory.getFactory(glp);
-
- final GLDrawable drawable = factory.createGLDrawable(window);
- Assert.assertNotNull(drawable);
- // System.out.println("Pre: "+drawable);
- //
- drawable.setRealized(true);
- Assert.assertTrue(drawable.isRealized());
-
- // Check caps of GLDrawable after realization
- final GLCapabilitiesImmutable chosenGLCaps = drawable.getChosenGLCapabilities();
- Assert.assertNotNull(chosenGLCaps);
- Assert.assertTrue(chosenGLCaps.getGreenBits()>5);
- Assert.assertTrue(chosenGLCaps.getBlueBits()>5);
- Assert.assertTrue(chosenGLCaps.getRedBits()>5);
- Assert.assertTrue(chosenGLCaps.getDepthBits()>4);
- Assert.assertEquals(reqGLCaps.isOnscreen(), chosenGLCaps.isOnscreen());
- Assert.assertEquals(reqGLCaps.isOnscreen(), chosenGLCaps.getDoubleBuffered()); // offscreen shall be !dbl-buffer
- // System.out.println("Post: "+drawable);
-
- GLContext context = drawable.createContext(null);
- Assert.assertNotNull(context);
- // System.out.println(context);
-
- int res = context.makeCurrent();
- Assert.assertTrue(GLContext.CONTEXT_CURRENT_NEW==res || GLContext.CONTEXT_CURRENT==res);
-
- // draw something ..
- final GL gl = context.getGL();
- gl.glClearColor(1, 1, 1, 1);
- gl.glEnable(GL.GL_DEPTH_TEST);
- Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
- gl.glViewport(0, 0, width, height);
- gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
- Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
-
- drawable.swapBuffers();
- context.release();
-
- Thread.sleep(50);
-
- context.destroy();
- drawable.setRealized(false);
- window.destroy();
- // System.out.println("Final: "+window);
- }
-
- @Test
- public void testGL2OnScreen() throws InterruptedException {
- doTest(GLProfile.GL2, true, false, false);
- }
-
- @Test
- public void testES2OnScreen() throws InterruptedException {
- doTest(GLProfile.GLES2, true, false, false);
- }
-
- @Test
- public void testGL2PBuffer() throws InterruptedException {
- doTest(GLProfile.GL2, false, false, true);
- }
-
- @Test
- public void testES2PBuffer() throws InterruptedException {
- doTest(GLProfile.GLES2, false, false, true);
- }
-
- // @Test // TODO: FBO-Drawable via createGLDrawable and pre-exisiting NativeSurface
- public void testGL2FBO() throws InterruptedException {
- doTest(GLProfile.GL2, false, true, false);
- }
-
- // @Test // TODO: FBO-Drawable via createGLDrawable and pre-exisiting NativeSurface
- public void testES2FBO() throws InterruptedException {
- doTest(GLProfile.GLES2, false, true, false);
- }
-
- public static void main(String args[]) throws IOException {
- org.junit.runner.JUnitCore.main(TestGLDrawable01NEWT.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 e4245ef11..d4f3fece5 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
@@ -32,14 +32,11 @@ import java.util.Collections;
import java.util.SortedSet;
import java.util.TreeSet;
-import javax.media.nativewindow.AbstractGraphicsDevice;
-import javax.media.opengl.DefaultGLCapabilitiesChooser;
import javax.media.opengl.GL;
-import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
-import javax.media.opengl.GLCapabilitiesChooser;
import javax.media.opengl.GLContext;
import javax.media.opengl.GLDrawableFactory;
+import javax.media.opengl.GLOffscreenAutoDrawable;
import javax.media.opengl.GLProfile;
import jogamp.opengl.GLDrawableFactoryImpl;
@@ -77,13 +74,11 @@ public class TestGLExtensionQueryOffscreen {
@Test
public void testJogl2ExtensionCheck2() {
- GLCapabilities caps = new GLCapabilities(GLProfile.getDefault());
- GLDrawableFactory factory = GLDrawableFactory.getDesktopFactory();
- GLCapabilitiesChooser glCapsChooser = new DefaultGLCapabilitiesChooser();
- AbstractGraphicsDevice agd = factory.getDefaultDevice();
+ 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);
- GLAutoDrawable drawable = factory.createGLPbuffer(agd, caps, glCapsChooser, 256, 256, null);
- GLContext context = drawable.getContext();
+ final GLContext context = drawable.getContext();
context.makeCurrent();
String extensions;
try {
@@ -94,8 +89,8 @@ public class TestGLExtensionQueryOffscreen {
String[] tabExtensions = extensions.split(" ");
SortedSet<String> setExtensions = new TreeSet<String>();
Collections.addAll(setExtensions, tabExtensions);
- System.out.println("DefaulContext: "+context);
- System.out.println("DefaulContext: "+setExtensions);
+ System.out.println("DefaultContext: "+context);
+ System.out.println("DefaultContext: "+setExtensions);
}
}
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 33a9b7799..c1b7464e7 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
@@ -11,12 +11,14 @@ import javax.media.opengl.DefaultGLCapabilitiesChooser;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLCapabilitiesImmutable;
import javax.media.opengl.GLDrawableFactory;
+import javax.media.opengl.GLOffscreenAutoDrawable;
import javax.media.opengl.GLPbuffer;
import javax.media.opengl.GLProfile;
/**
* Tests the closing the device of GLWindow and GLPBuffer in JOGL
*/
+@SuppressWarnings("deprecation")
public class TestNEWTCloseX11DisplayBug565 {
@Test
@@ -59,7 +61,7 @@ public class TestNEWTCloseX11DisplayBug565 {
@Test
- public void testX11WindowMemoryLeakOffscreenWindow() throws Exception {
+ public void testX11WindowMemoryLeakGLPbuffer() throws Exception {
GLProfile.initSingleton(); // ensure shared resource runner is done
try {
for ( int j = 0; j < 10; j++ ) {
@@ -100,6 +102,48 @@ public class TestNEWTCloseX11DisplayBug565 {
}
}
+ @Test
+ public void testX11WindowMemoryLeakFBOAutoDrawable() throws Exception {
+ GLProfile.initSingleton(); // ensure shared resource runner is done
+ try {
+ for ( int j = 0; j < 10; j++ ) {
+ final int open0;
+ if(NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false)) {
+ open0 = X11Util.getOpenDisplayConnectionNumber();
+ } else {
+ open0 = 0;
+ }
+ final GLProfile glp = GLProfile.getDefault( );
+ GLCapabilitiesImmutable caps = new GLCapabilities( glp );
+
+
+ GLOffscreenAutoDrawable buffer = GLDrawableFactory.getFactory( glp ).createOffscreenAutoDrawable(
+ null,
+ caps,
+ new DefaultGLCapabilitiesChooser(),
+ 256,
+ 256,
+ null
+ );
+ buffer.display();
+ buffer.destroy();
+
+ if(NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false)) {
+ final int openD = X11Util.getOpenDisplayConnectionNumber() - open0;
+ if(openD > 0) {
+ X11Util.dumpOpenDisplayConnections();
+ X11Util.dumpPendingDisplayConnections();
+ Assert.assertEquals("New display connection didn't close", 0, openD);
+ }
+ }
+ }
+ }
+ catch ( Exception e ) {
+ e.printStackTrace();
+ 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/newt/parenting/TestParentingOffscreenLayer01GLCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer01GLCanvasAWT.java
index 4542fa47e..d181800c5 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingOffscreenLayer01GLCanvasAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer01GLCanvasAWT.java
@@ -26,7 +26,7 @@
* or implied, of JogAmp Community.
*/
-package com.jogamp.opengl.test.junit.newt.parenting;
+package com.jogamp.opengl.test.junit.jogl.acore;
import java.awt.BorderLayout;
import java.awt.Button;
@@ -56,11 +56,15 @@ import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.util.Animator;
-public class TestParentingOffscreenLayer01GLCanvasAWT extends UITestCase {
+public class TestOffscreenLayer01GLCanvasAWT extends UITestCase {
+ static boolean useMSAA = false;
+ static boolean addComp = true;
+ static int swapInterval = 1;
+ static boolean shallUseOffscreenPBufferLayer = false;
+ static boolean noAnimation = false;
static Dimension frameSize0;
static Dimension frameSize1;
static Dimension preferredGLSize;
- static Dimension minGLSize;
static long durationPerTest = 1000;
@BeforeClass
@@ -68,7 +72,6 @@ public class TestParentingOffscreenLayer01GLCanvasAWT extends UITestCase {
frameSize0 = new Dimension(500,300);
frameSize1 = new Dimension(800,600);
preferredGLSize = new Dimension(400,200);
- minGLSize = new Dimension(200,100);
}
private void setupFrameAndShow(final Frame f, java.awt.Component comp) throws InterruptedException, InvocationTargetException {
@@ -90,10 +93,12 @@ public class TestParentingOffscreenLayer01GLCanvasAWT extends UITestCase {
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
+ f.pack();
f.validate();
f.setVisible(true);
}});
}
+
private void end(GLAnimatorControl actrl, final Frame f, Window w) throws InterruptedException, InvocationTargetException {
actrl.stop();
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
@@ -114,11 +119,6 @@ public class TestParentingOffscreenLayer01GLCanvasAWT extends UITestCase {
}
@Test
- public void testOnscreenLayerGLCanvas_Onscreen() throws InterruptedException, InvocationTargetException {
- testOffscreenLayerGLCanvas_Impl(false);
- }
-
- @Test
public void testOffscreenLayerGLCanvas_OffscreenLayerWithOnscreenClass() throws InterruptedException, InvocationTargetException {
testOffscreenLayerGLCanvas_Impl(true);
}
@@ -134,13 +134,25 @@ public class TestParentingOffscreenLayer01GLCanvasAWT extends UITestCase {
}
final Frame frame1 = new Frame("AWT Parent Frame");
- GLCapabilities glCaps = new GLCapabilities(null);
- final GLCanvas glc = new GLCanvas(glCaps);
+ GLCapabilities caps = new GLCapabilities(null);
+ if(useMSAA) {
+ caps.setNumSamples(4);
+ caps.setSampleBuffers(true);
+ }
+ if(shallUseOffscreenPBufferLayer) {
+ caps.setPBuffer(true);
+ caps.setOnscreen(true); // simulate normal behavior ..
+ }
+ final GLCanvas glc = new GLCanvas(caps);
glc.setShallUseOffscreenLayer(offscreenLayer); // trigger offscreen layer - if supported
glc.setPreferredSize(preferredGLSize);
- glc.setMinimumSize(minGLSize);
+ glc.setMinimumSize(preferredGLSize);
+ glc.setSize(preferredGLSize);
- GLEventListener demo1 = new GearsES2(1);
+ GearsES2 demo1 = new GearsES2(swapInterval);
+ if(noAnimation) {
+ demo1.setDoRotation(false);
+ }
glc.addGLEventListener(demo1);
frame1.setSize(frameSize0);
@@ -151,12 +163,16 @@ public class TestParentingOffscreenLayer01GLCanvasAWT extends UITestCase {
glc.isOffscreenLayerSurfaceEnabled());
GLAnimatorControl animator1 = new Animator(glc);
- animator1.start();
+ if(!noAnimation) {
+ animator1.start();
+ }
+ animator1.setUpdateFPSFrames(60, System.err);
Thread.sleep(durationPerTest/2);
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
frame1.setSize(frameSize1);
+ frame1.pack();
frame1.validate();
}});
@@ -190,9 +206,18 @@ public class TestParentingOffscreenLayer01GLCanvasAWT extends UITestCase {
for(int i=0; i<args.length; i++) {
if(args[i].equals("-time")) {
durationPerTest = atoi(args[++i]);
+ } else if(args[i].equals("-vsync")) {
+ i++;
+ swapInterval = MiscUtils.atoi(args[i], swapInterval);
+ } else if(args[i].equals("-layeredPBuffer")) {
+ shallUseOffscreenPBufferLayer = true;
+ } else if(args[i].equals("-msaa")) {
+ useMSAA = true;
+ } else if(args[i].equals("-still")) {
+ noAnimation = true;
}
}
- String tstname = TestParentingOffscreenLayer01GLCanvasAWT.class.getName();
+ String tstname = TestOffscreenLayer01GLCanvasAWT.class.getName();
/*
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(new String[] {
tstname,
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingOffscreenLayer02NewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer02NewtCanvasAWT.java
index 6a1980b90..c2185d6c3 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingOffscreenLayer02NewtCanvasAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer02NewtCanvasAWT.java
@@ -26,7 +26,7 @@
* or implied, of JogAmp Community.
*/
-package com.jogamp.opengl.test.junit.newt.parenting;
+package com.jogamp.opengl.test.junit.jogl.acore;
import java.awt.BorderLayout;
import java.awt.Button;
@@ -50,16 +50,21 @@ import com.jogamp.newt.Window;
import com.jogamp.newt.awt.NewtCanvasAWT;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.newt.parenting.NewtAWTReparentingKeyAdapter;
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.util.Animator;
-public class TestParentingOffscreenLayer02NewtCanvasAWT extends UITestCase {
+public class TestOffscreenLayer02NewtCanvasAWT extends UITestCase {
+ static boolean useMSAA = false;
+ static boolean addComp = true;
+ static int swapInterval = 1;
+ static boolean shallUseOffscreenPBufferLayer = false;
+ static boolean noAnimation = false;
static Dimension frameSize0;
static Dimension frameSize1;
static Dimension preferredGLSize;
- static Dimension minGLSize;
static long durationPerTest = 1000;
@BeforeClass
@@ -67,7 +72,6 @@ public class TestParentingOffscreenLayer02NewtCanvasAWT extends UITestCase {
frameSize0 = new Dimension(500,300);
frameSize1 = new Dimension(800,600);
preferredGLSize = new Dimension(400,200);
- minGLSize = new Dimension(200,100);
}
private void setupFrameAndShow(final Frame f, java.awt.Component comp) throws InterruptedException, InvocationTargetException {
@@ -89,10 +93,12 @@ public class TestParentingOffscreenLayer02NewtCanvasAWT extends UITestCase {
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
+ f.pack();
f.validate();
f.setVisible(true);
}});
}
+
private void end(GLAnimatorControl actrl, final Frame f, Window w) throws InterruptedException, InvocationTargetException {
actrl.stop();
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
@@ -105,49 +111,42 @@ public class TestParentingOffscreenLayer02NewtCanvasAWT extends UITestCase {
}
@Test
- public void testOnscreenLayerNewtCanvas_Onscreen() throws InterruptedException, InvocationTargetException {
- if(!JAWTUtil.isOffscreenLayerRequired()) {
- testOffscreenLayerNewtCanvas_Impl(false, false);
- } else {
- System.err.println("onscreen layer n/a");
- }
- }
-
- // @Test
- public void testOffscreenLayerNewtCanvas_OffscreenLayerWithOffscreenClass() throws InterruptedException, InvocationTargetException {
- if(JAWTUtil.isOffscreenLayerSupported()) {
- testOffscreenLayerNewtCanvas_Impl(true, true);
- } else {
- System.err.println("offscreen layer n/a");
- }
+ public void testOffscreenLayerNewtCanvas_OffscreenLayerWithOnscreenClass() throws InterruptedException, InvocationTargetException {
+ testOffscreenLayerNewtCanvas_Impl(true);
}
- @Test
- public void testOffscreenLayerNewtCanvas_OffscreenLayerWithOnscreenClass() throws InterruptedException, InvocationTargetException {
- if(JAWTUtil.isOffscreenLayerSupported()) {
- testOffscreenLayerNewtCanvas_Impl(true, false);
- } else {
+ private void testOffscreenLayerNewtCanvas_Impl(boolean offscreenLayer) throws InterruptedException, InvocationTargetException {
+ if(!offscreenLayer && JAWTUtil.isOffscreenLayerRequired()) {
+ System.err.println("onscreen layer n/a");
+ return;
+ }
+ if(offscreenLayer && !JAWTUtil.isOffscreenLayerSupported()) {
System.err.println("offscreen layer n/a");
+ return;
}
- }
-
- private void testOffscreenLayerNewtCanvas_Impl(boolean offscreenLayer, boolean offscreenClass) throws InterruptedException, InvocationTargetException {
final Frame frame1 = new Frame("AWT Parent Frame");
- GLCapabilities glCaps = new GLCapabilities(null);
- if(offscreenClass) {
- glCaps.setOnscreen(false);
- glCaps.setPBuffer(true);
+ GLCapabilities caps = new GLCapabilities(null);
+ if(useMSAA) {
+ caps.setNumSamples(4);
+ caps.setSampleBuffers(true);
}
-
- GLWindow glWindow1 = GLWindow.create(glCaps);
+ if(shallUseOffscreenPBufferLayer) {
+ caps.setPBuffer(true);
+ caps.setOnscreen(true); // get native NEWT Window, not OffscreenWindow
+ }
+ GLWindow glWindow1 = GLWindow.create(caps);
final NewtCanvasAWT newtCanvasAWT1 = new NewtCanvasAWT(glWindow1);
newtCanvasAWT1.setShallUseOffscreenLayer(offscreenLayer); // trigger offscreen layer - if supported
newtCanvasAWT1.setPreferredSize(preferredGLSize);
- newtCanvasAWT1.setMinimumSize(minGLSize);
+ newtCanvasAWT1.setMinimumSize(preferredGLSize);
+ newtCanvasAWT1.setSize(preferredGLSize);
- GLEventListener demo1 = new GearsES2(1);
+ GearsES2 demo1 = new GearsES2(swapInterval);
+ if(noAnimation) {
+ demo1.setDoRotation(false);
+ }
setDemoFields(demo1, glWindow1, false);
glWindow1.addGLEventListener(demo1);
glWindow1.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT1, glWindow1));
@@ -161,12 +160,16 @@ public class TestParentingOffscreenLayer02NewtCanvasAWT extends UITestCase {
newtCanvasAWT1.isOffscreenLayerSurfaceEnabled());
GLAnimatorControl animator1 = new Animator(glWindow1);
- animator1.start();
+ if(!noAnimation) {
+ animator1.start();
+ }
+ animator1.setUpdateFPSFrames(60, System.err);
Thread.sleep(durationPerTest/2);
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
frame1.setSize(frameSize1);
+ frame1.pack();
frame1.validate();
}});
@@ -200,9 +203,18 @@ public class TestParentingOffscreenLayer02NewtCanvasAWT extends UITestCase {
for(int i=0; i<args.length; i++) {
if(args[i].equals("-time")) {
durationPerTest = atoi(args[++i]);
+ } else if(args[i].equals("-vsync")) {
+ i++;
+ swapInterval = MiscUtils.atoi(args[i], swapInterval);
+ } else if(args[i].equals("-layeredPBuffer")) {
+ shallUseOffscreenPBufferLayer = true;
+ } else if(args[i].equals("-msaa")) {
+ useMSAA = true;
+ } else if(args[i].equals("-still")) {
+ noAnimation = true;
}
}
- String tstname = TestParentingOffscreenLayer02NewtCanvasAWT.class.getName();
+ String tstname = TestOffscreenLayer02NewtCanvasAWT.class.getName();
/*
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(new String[] {
tstname,
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPBufferDeadlockAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPBufferDeadlockAWT.java
index 3a25d1206..90934f1b5 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPBufferDeadlockAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPBufferDeadlockAWT.java
@@ -45,6 +45,7 @@ import org.junit.Test;
import com.jogamp.common.util.RunnableTask;
import com.jogamp.opengl.test.junit.util.UITestCase;
+@SuppressWarnings("deprecation")
public class TestPBufferDeadlockAWT extends UITestCase {
static GLProfile glp;
static int width, height;
@@ -100,6 +101,7 @@ public class TestPBufferDeadlockAWT extends UITestCase {
}
});
Assert.assertTrue(done[0]);
+ pbuffer.destroy();
}
@Test(timeout = 2000) // 2s timeout
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 60502bab1..67b70e117 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
@@ -30,11 +30,10 @@ package com.jogamp.opengl.test.junit.jogl.acore;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLDrawableFactory;
-import javax.media.opengl.GLPbuffer;
+import javax.media.opengl.GLOffscreenAutoDrawable;
import javax.media.opengl.GLProfile;
import javax.media.opengl.awt.GLCanvas;
-import com.jogamp.common.os.Platform;
import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.test.junit.util.UITestCase;
@@ -53,17 +52,11 @@ public class TestSharedContextListAWT extends UITestCase {
static GLProfile glp;
static GLCapabilities caps;
static int width, height;
- GLPbuffer sharedDrawable;
+ GLOffscreenAutoDrawable sharedDrawable;
Gears sharedGears;
@BeforeClass
public static void initClass() {
- if(Platform.CPUFamily.X86 != Platform.CPU_ARCH.family) { // FIXME
- // FIXME: Turns out on some mobile GL drivers and platforms
- // using shared context is instable, Linux ARM (Omap4, Tegra2, Mesa3d, ..)
- setTestSupported(false);
- return;
- }
if(GLProfile.isAvailable(GLProfile.GL2)) {
glp = GLProfile.get(GLProfile.GL2);
Assert.assertNotNull(glp);
@@ -77,7 +70,7 @@ public class TestSharedContextListAWT extends UITestCase {
}
private void initShared() {
- sharedDrawable = GLDrawableFactory.getFactory(glp).createGLPbuffer(null, caps, null, width, height, null);
+ sharedDrawable = GLDrawableFactory.getFactory(glp).createOffscreenAutoDrawable(null, caps, null, width, height, null);
Assert.assertNotNull(sharedDrawable);
sharedGears = new Gears();
Assert.assertNotNull(sharedGears);
@@ -159,10 +152,6 @@ public class TestSharedContextListAWT extends UITestCase {
}
animator.stop();
- // here we go again: On AMD/X11 the create/destroy sequence must be the same
- // even though this is agains the chicken/egg logic
- releaseShared();
-
try {
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
@@ -182,8 +171,7 @@ public class TestSharedContextListAWT extends UITestCase {
Assume.assumeNoException( throwable );
}
- // see above ..
- //releaseShared();
+ releaseShared();
}
static long duration = 500; // ms
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 39367d1b0..78c8fd0ae 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
@@ -30,13 +30,12 @@ package com.jogamp.opengl.test.junit.jogl.acore;
import java.io.IOException;
-import com.jogamp.common.os.Platform;
import com.jogamp.newt.opengl.GLWindow;
import javax.media.nativewindow.util.InsetsImmutable;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLDrawableFactory;
-import javax.media.opengl.GLPbuffer;
+import javax.media.opengl.GLOffscreenAutoDrawable;
import javax.media.opengl.GLProfile;
import com.jogamp.opengl.util.Animator;
@@ -52,17 +51,11 @@ public class TestSharedContextListNEWT extends UITestCase {
static GLProfile glp;
static GLCapabilities caps;
static int width, height;
- GLPbuffer sharedDrawable;
+ GLOffscreenAutoDrawable sharedDrawable;
Gears sharedGears;
@BeforeClass
public static void initClass() {
- if(Platform.CPUFamily.X86 != Platform.CPU_ARCH.family) { // FIXME
- // FIXME: Turns out on some mobile GL drivers and platforms
- // using shared context is instable, Linux ARM (Omap4, Tegra2, Mesa3d, ..)
- setTestSupported(false);
- return;
- }
if(GLProfile.isAvailable(GLProfile.GL2)) {
glp = GLProfile.get(GLProfile.GL2);
Assert.assertNotNull(glp);
@@ -76,7 +69,7 @@ public class TestSharedContextListNEWT extends UITestCase {
}
private void initShared() {
- sharedDrawable = GLDrawableFactory.getFactory(glp).createGLPbuffer(null, caps, null, width, height, null);
+ sharedDrawable = GLDrawableFactory.getFactory(glp).createOffscreenAutoDrawable(null, caps, null, width, height, null);
Assert.assertNotNull(sharedDrawable);
sharedGears = new Gears();
Assert.assertNotNull(sharedGears);
@@ -134,16 +127,11 @@ public class TestSharedContextListNEWT extends UITestCase {
}
animator.stop();
- // here we go again: On AMD/X11 the create/destroy sequence must be the same
- // even though this is against the chicken/egg logic here ..
- releaseShared();
-
f1.destroy();
f2.destroy();
f3.destroy();
- // see above ..
- // releaseShared();
+ releaseShared();
}
static long duration = 500; // ms
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT2.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT2.java
index 7dca314bd..7893c51f1 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT2.java
@@ -30,7 +30,6 @@ package com.jogamp.opengl.test.junit.jogl.acore;
import java.io.IOException;
-import com.jogamp.common.os.Platform;
import com.jogamp.newt.opengl.GLWindow;
import javax.media.nativewindow.util.InsetsImmutable;
@@ -55,12 +54,6 @@ public class TestSharedContextListNEWT2 extends UITestCase {
@BeforeClass
public static void initClass() {
- if(Platform.CPUFamily.X86 != Platform.CPU_ARCH.family) { // FIXME
- // FIXME: Turns out on some mobile GL drivers and platforms
- // using shared context is instable, Linux ARM (Omap4, Tegra2, Mesa3d, ..)
- setTestSupported(false);
- return;
- }
if(GLProfile.isAvailable(GLProfile.GL2)) {
glp = GLProfile.get(GLProfile.GL2);
Assert.assertNotNull(glp);
@@ -135,16 +128,11 @@ public class TestSharedContextListNEWT2 extends UITestCase {
e.printStackTrace();
}
- // here we go again: On AMD/X11 the create/destroy sequence must be the same
- // even though this is against the chicken/egg logic here ..
- releaseShared();
-
f1.destroy();
f2.destroy();
f3.destroy();
- // see above ..
- // releaseShared();
+ releaseShared();
}
static long duration = 2000; // ms
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 bc2eddb9a..7894f3e86 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
@@ -45,7 +45,7 @@ import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLContext;
import javax.media.opengl.GLDrawableFactory;
import javax.media.opengl.GLEventListener;
-import javax.media.opengl.GLPbuffer;
+import javax.media.opengl.GLOffscreenAutoDrawable;
import javax.media.opengl.GLProfile;
import javax.media.opengl.awt.GLCanvas;
import javax.media.opengl.glu.GLU;
@@ -64,7 +64,6 @@ import org.junit.BeforeClass;
import org.junit.Test;
import com.jogamp.common.nio.Buffers;
-import com.jogamp.common.os.Platform;
import com.jogamp.newt.awt.NewtCanvasAWT;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
@@ -118,26 +117,20 @@ public class TestSharedContextNewtAWTBug523 extends UITestCase {
@BeforeClass
public static void initClass() {
- if(Platform.CPUFamily.X86 != Platform.CPU_ARCH.family) { // FIXME
- // FIXME: Turns out on some mobile GL drivers and platforms
- // using shared context is instable, Linux ARM (Omap4, Tegra2, Mesa3d, ..)
- setTestSupported(false);
- return;
- }
if(!GLProfile.isAvailable(GLProfile.GL2)) {
setTestSupported(false);
}
}
- static private GLPbuffer initShared(GLCapabilities caps) {
- GLPbuffer sharedDrawable = GLDrawableFactory.getFactory(caps.getGLProfile()).createGLPbuffer(null, caps, null, 64, 64, null);
+ static private GLOffscreenAutoDrawable initShared(GLCapabilities caps) {
+ final GLOffscreenAutoDrawable sharedDrawable = GLDrawableFactory.getFactory(caps.getGLProfile()).createOffscreenAutoDrawable(null, caps, null, 64, 64, null);
Assert.assertNotNull(sharedDrawable);
// init and render one frame, which will setup the Gears display lists
sharedDrawable.display();
return sharedDrawable;
}
- static private void releaseShared(GLPbuffer sharedDrawable) {
+ static private void releaseShared(GLOffscreenAutoDrawable sharedDrawable) {
if(null != sharedDrawable) {
sharedDrawable.destroy();
}
@@ -522,7 +515,7 @@ public class TestSharedContextNewtAWTBug523 extends UITestCase {
glCapabilities.setSampleBuffers(true);
glCapabilities.setNumSamples(4);
- final GLPbuffer sharedDrawable;
+ final GLOffscreenAutoDrawable sharedDrawable;
final GLContext sharedContext;
if(shareContext) {
sharedDrawable = initShared(glCapabilities);
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 707bd5a9b..6f108d862 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
@@ -28,13 +28,12 @@
package com.jogamp.opengl.test.junit.jogl.acore;
-import com.jogamp.common.os.Platform;
import com.jogamp.newt.opengl.GLWindow;
import javax.media.nativewindow.util.InsetsImmutable;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLDrawableFactory;
-import javax.media.opengl.GLPbuffer;
+import javax.media.opengl.GLOffscreenAutoDrawable;
import javax.media.opengl.GLProfile;
import com.jogamp.opengl.util.Animator;
@@ -50,17 +49,11 @@ public class TestSharedContextVBOES1NEWT extends UITestCase {
static GLProfile glp;
static GLCapabilities caps;
static int width, height;
- GLPbuffer sharedDrawable;
+ GLOffscreenAutoDrawable sharedDrawable;
GearsES1 sharedGears;
@BeforeClass
public static void initClass() {
- if(Platform.CPUFamily.X86 != Platform.CPU_ARCH.family) { // FIXME
- // FIXME: Turns out on some mobile GL drivers and platforms
- // using shared context is instable, Linux ARM (Omap4, Tegra2, Mesa3d, ..)
- setTestSupported(false);
- return;
- }
if(GLProfile.isAvailable(GLProfile.GL2ES1)) {
glp = GLProfile.get(GLProfile.GL2ES1);
Assert.assertNotNull(glp);
@@ -74,7 +67,7 @@ public class TestSharedContextVBOES1NEWT extends UITestCase {
}
private void initShared() {
- sharedDrawable = GLDrawableFactory.getFactory(glp).createGLPbuffer(null, caps, null, width, height, null);
+ sharedDrawable = GLDrawableFactory.getFactory(glp).createOffscreenAutoDrawable(null, caps, null, width, height, null);
Assert.assertNotNull(sharedDrawable);
sharedGears = new GearsES1();
Assert.assertNotNull(sharedGears);
@@ -132,16 +125,11 @@ public class TestSharedContextVBOES1NEWT extends UITestCase {
}
animator.stop();
- // here we go again: On AMD/X11 the create/destroy sequence must be the same
- // even though this is agains the chicken/egg logic here ..
- releaseShared();
-
f1.destroy();
f2.destroy();
f3.destroy();
- // see above ..
- // releaseShared();
+ releaseShared();
}
static long duration = 500; // ms
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT.java
index ce2bd77e1..da91350f1 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT.java
@@ -28,13 +28,12 @@
package com.jogamp.opengl.test.junit.jogl.acore;
-import com.jogamp.common.os.Platform;
import com.jogamp.newt.opengl.GLWindow;
import javax.media.nativewindow.util.InsetsImmutable;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLDrawableFactory;
-import javax.media.opengl.GLPbuffer;
+import javax.media.opengl.GLOffscreenAutoDrawable;
import javax.media.opengl.GLProfile;
import com.jogamp.opengl.util.Animator;
@@ -50,17 +49,11 @@ public class TestSharedContextVBOES2NEWT extends UITestCase {
static GLProfile glp;
static GLCapabilities caps;
static int width, height;
- GLPbuffer sharedDrawable;
+ GLOffscreenAutoDrawable sharedDrawable;
GearsES2 sharedGears;
@BeforeClass
public static void initClass() {
- if(Platform.CPUFamily.X86 != Platform.CPU_ARCH.family) { // FIXME
- // FIXME: Turns out on some mobile GL drivers and platforms
- // using shared context is instable, Linux ARM (Omap4, Tegra2, Mesa3d, ..)
- setTestSupported(false);
- return;
- }
if(GLProfile.isAvailable(GLProfile.GL2ES2)) {
glp = GLProfile.get(GLProfile.GL2ES2);
Assert.assertNotNull(glp);
@@ -74,7 +67,7 @@ public class TestSharedContextVBOES2NEWT extends UITestCase {
}
private void initShared() {
- sharedDrawable = GLDrawableFactory.getFactory(glp).createGLPbuffer(null, caps, null, width, height, null);
+ sharedDrawable = GLDrawableFactory.getFactory(glp).createOffscreenAutoDrawable(null, caps, null, width, height, null);
Assert.assertNotNull(sharedDrawable);
sharedGears = new GearsES2();
Assert.assertNotNull(sharedGears);
@@ -132,16 +125,11 @@ public class TestSharedContextVBOES2NEWT extends UITestCase {
}
animator.stop();
- // here we go again: On AMD/X11 the create/destroy sequence must be the same
- // even though this is agains the chicken/egg logic here ..
- releaseShared();
-
f1.destroy();
f2.destroy();
f3.destroy();
- // see above ..
- // releaseShared();
+ releaseShared();
}
static long duration = 500; // ms
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
index 8911e73ef..ee1a7311e 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java
@@ -30,7 +30,6 @@ package com.jogamp.opengl.test.junit.jogl.acore;
import java.io.IOException;
-import com.jogamp.common.os.Platform;
import com.jogamp.newt.opengl.GLWindow;
import javax.media.nativewindow.util.InsetsImmutable;
@@ -55,12 +54,6 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase {
@BeforeClass
public static void initClass() {
- if(Platform.CPUFamily.X86 != Platform.CPU_ARCH.family) { // FIXME
- // FIXME: Turns out on some mobile GL drivers and platforms
- // using shared context is instable, Linux ARM (Omap4, Tegra2, Mesa3d, ..)
- setTestSupported(false);
- return;
- }
if(GLProfile.isAvailable(GLProfile.GL2ES2)) {
glp = GLProfile.get(GLProfile.GL2ES2);
Assert.assertNotNull(glp);
@@ -136,16 +129,11 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase {
e.printStackTrace();
}
- // here we go again: On AMD/X11 the create/destroy sequence must be the same
- // even though this is against the chicken/egg logic here ..
- releaseShared();
-
f1.destroy();
f2.destroy();
f3.destroy();
- // see above ..
- // releaseShared();
+ releaseShared();
}
static long duration = 2000; // ms
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
new file mode 100644
index 000000000..42949afef
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461FBOSupersamplingSwingAWT.java
@@ -0,0 +1,159 @@
+/**
+ * Copyright 2011 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.opengl.test.junit.jogl.awt;
+
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+
+import java.awt.image.BufferedImage;
+import java.lang.reflect.InvocationTargetException;
+
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLDrawableFactory;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLOffscreenAutoDrawable;
+import javax.media.opengl.GLProfile;
+import javax.swing.ImageIcon;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.jogamp.opengl.test.junit.util.UITestCase;
+
+/**
+ * Tests for bug 461, a failure of GLDrawableFactory.createGLPbuffer() on Windows
+ * when the stencil buffer is turned on.
+ *
+ * @author Wade Walker (from code sample provided by Owen Dimond)
+ */
+@SuppressWarnings("deprecation")
+public class TestBug461FBOSupersamplingSwingAWT extends UITestCase implements GLEventListener {
+ JFrame jframe;
+ GLOffscreenAutoDrawable offScreenBuffer;
+
+ private void render(GLAutoDrawable drawable) {
+ GL2 gl = drawable.getGL().getGL2();
+ Assert.assertNotNull(gl);
+ gl.glClear(GL.GL_COLOR_BUFFER_BIT);
+
+ // draw a triangle filling the window
+ gl.glBegin(GL.GL_TRIANGLES);
+ gl.glColor3f(1, 0, 0);
+ gl.glVertex2d(-1, -1);
+ gl.glColor3f(0, 1, 0);
+ gl.glVertex2d(0, 1);
+ gl.glColor3f(0, 0, 1);
+ gl.glVertex2d(1, -1);
+ gl.glEnd();
+ }
+
+ /* @Override */
+ public void init(GLAutoDrawable drawable) {
+ }
+
+ /* @Override */
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ }
+
+ /* @Override */
+ public void display(GLAutoDrawable drawable) {
+ render(offScreenBuffer);
+ BufferedImage outputImage = com.jogamp.opengl.util.awt.Screenshot.readToBufferedImage(200, 200, false);
+ Assert.assertNotNull(outputImage);
+ ImageIcon imageIcon = new ImageIcon(outputImage);
+ JLabel imageLabel = new JLabel(imageIcon);
+ jframe.getContentPane().add(imageLabel);
+ }
+
+ /* @Override */
+ public void dispose(GLAutoDrawable drawable) {
+ try {
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ jframe.setVisible(false);
+ jframe.dispose();
+ }});
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testOffscreenSupersampling() throws InterruptedException, InvocationTargetException {
+ jframe = new JFrame("Offscreen Supersampling");
+ Assert.assertNotNull(jframe);
+ jframe.setSize( 300, 300);
+ jframe.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e) {
+ System.exit(0);
+ }
+ });
+
+ GLProfile glp = GLProfile.get(GLProfile.GL2);
+ Assert.assertNotNull(glp);
+
+ GLDrawableFactory fac = GLDrawableFactory.getFactory(glp);
+ Assert.assertNotNull(fac);
+
+ Assert.assertTrue( fac.canCreateGLPbuffer(GLProfile.getDefaultDevice()) );
+
+ GLCapabilities glCap = new GLCapabilities(glp);
+ Assert.assertNotNull(glCap);
+
+ // 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);
+ // Needed for drop shadows
+ glCap.setStencilBits(1);
+
+ //makes a new buffer
+ offScreenBuffer = fac.createOffscreenAutoDrawable(GLProfile.getDefaultDevice(), glCap, null, 200, 200, null);
+ Assert.assertNotNull(offScreenBuffer);
+ offScreenBuffer.addGLEventListener(this);
+ offScreenBuffer.display();
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ jframe.setVisible(true);
+ }});
+ offScreenBuffer.destroy();
+ }
+
+ public static void main(String args[]) {
+ org.junit.runner.JUnitCore.main(TestBug461FBOSupersamplingSwingAWT.class.getName());
+ }
+}
+
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461OffscreenSupersamplingSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461PBufferSupersamplingSwingAWT.java
index 6a315c67d..5b7052c37 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461OffscreenSupersamplingSwingAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461PBufferSupersamplingSwingAWT.java
@@ -57,7 +57,8 @@ import com.jogamp.opengl.test.junit.util.UITestCase;
*
* @author Wade Walker (from code sample provided by Owen Dimond)
*/
-public class TestBug461OffscreenSupersamplingSwingAWT extends UITestCase implements GLEventListener {
+@SuppressWarnings("deprecation")
+public class TestBug461PBufferSupersamplingSwingAWT extends UITestCase implements GLEventListener {
JFrame jframe;
GLPbuffer offScreenBuffer;
@@ -148,10 +149,11 @@ public class TestBug461OffscreenSupersamplingSwingAWT extends UITestCase impleme
public void run() {
jframe.setVisible(true);
}});
+ offScreenBuffer.destroy();
}
public static void main(String args[]) {
- org.junit.runner.JUnitCore.main(TestBug461OffscreenSupersamplingSwingAWT.class.getName());
+ org.junit.runner.JUnitCore.main(TestBug461PBufferSupersamplingSwingAWT.class.getName());
}
}
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 478bd4543..c5bdfb5f3 100755
--- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java
@@ -108,7 +108,7 @@ public class TestMultisampleES1AWT extends UITestCase {
public void init(GLAutoDrawable drawable) {}
public void dispose(GLAutoDrawable drawable) {}
public void display(GLAutoDrawable drawable) {
- snapshot(getSimpleTestName("."), displayCount++, null, drawable.getGL(), screenshot, TextureIO.PNG, null);
+ snapshot(displayCount++, null, drawable.getGL(), screenshot, TextureIO.PNG, null);
}
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { }
});
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1NEWT.java
index ed8e2bd85..5bbd6737c 100755
--- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1NEWT.java
@@ -133,7 +133,7 @@ public class TestMultisampleES1NEWT extends UITestCase {
public void init(GLAutoDrawable drawable) {}
public void dispose(GLAutoDrawable drawable) {}
public void display(GLAutoDrawable drawable) {
- snapshot(getSimpleTestName("."), displayCount++, null, drawable.getGL(), screenshot, TextureIO.PNG, null);
+ snapshot(displayCount++, null, drawable.getGL(), screenshot, TextureIO.PNG, null);
}
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { }
});
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES2NEWT.java
index 02fcae6ef..c2e3215ae 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES2NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES2NEWT.java
@@ -126,7 +126,7 @@ public class TestMultisampleES2NEWT extends UITestCase {
public void init(GLAutoDrawable drawable) {}
public void dispose(GLAutoDrawable drawable) {}
public void display(GLAutoDrawable drawable) {
- snapshot(getSimpleTestName("."), displayCount++, null, drawable.getGL(), screenshot, TextureIO.PNG, null);
+ snapshot(displayCount++, null, drawable.getGL(), screenshot, TextureIO.PNG, null);
}
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { }
});
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 e81d1b4af..40b351a75 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
@@ -24,6 +24,7 @@ package com.jogamp.opengl.test.junit.jogl.demos.es1;
import javax.media.nativewindow.NativeWindow;
import javax.media.opengl.GL;
import javax.media.opengl.GL2ES1;
+import javax.media.opengl.GL2ES2;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLProfile;
@@ -93,11 +94,16 @@ public class GearsES1 implements GLEventListener {
// GL2ES1 gl = FixedFuncUtil.wrapFixedFuncEmul(_gl /*, true*/);
GL2ES1 gl = _gl.getGL2ES1();
+ System.err.println("GearsES1 init on "+Thread.currentThread());
System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities());
System.err.println("INIT GL IS: " + gl.getClass().getName());
System.err.println("GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR));
System.err.println("GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER));
System.err.println("GL_VERSION: " + gl.glGetString(GL.GL_VERSION));
+ System.err.println("GL GLSL: "+gl.hasGLSL()+", has-compiler: "+gl.isFunctionAvailable("glCompileShader")+", version "+(gl.hasGLSL() ? gl.glGetString(GL2ES2.GL_SHADING_LANGUAGE_VERSION) : "none"));
+ System.err.println("GL FBO: basic "+ gl.hasBasicFBOSupport()+", full "+gl.hasFullFBOSupport());
+ System.err.println("GL Profile: "+gl.getGLProfile());
+ System.err.println("GL:" + gl + ", " + gl.getContext().getGLVersion());
gl.glLightfv(GL2ES1.GL_LIGHT0, GL2ES1.GL_POSITION, pos, 0);
gl.glEnable(GL.GL_CULL_FACE);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquareES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquareES1.java
index 8d1c708af..84234d464 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquareES1.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquareES1.java
@@ -71,15 +71,16 @@ public class RedSquareES1 implements GLEventListener {
} catch (Exception e) {e.printStackTrace();}
}
- System.err.println(Thread.currentThread()+"Chosen GLCapabilities: " + drawable.getChosenGLCapabilities());
- System.err.println(Thread.currentThread()+"INIT GL IS: " + gl.getClass().getName());
- System.err.println(Thread.currentThread()+"GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR));
- System.err.println(Thread.currentThread()+"GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER));
- System.err.println(Thread.currentThread()+"GL_VERSION: " + gl.glGetString(GL.GL_VERSION));
-
- System.err.println(Thread.currentThread()+" GL Profile: "+gl.getGLProfile());
- System.err.println(Thread.currentThread()+" GL:" + gl);
- System.err.println(Thread.currentThread()+" GL_VERSION=" + gl.glGetString(GL.GL_VERSION));
+ System.err.println("RedSquareES1 init on "+Thread.currentThread());
+ System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities());
+ System.err.println("INIT GL IS: " + gl.getClass().getName());
+ System.err.println("GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR));
+ System.err.println("GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER));
+ System.err.println("GL_VERSION: " + gl.glGetString(GL.GL_VERSION));
+ System.err.println("GL GLSL: "+gl.hasGLSL()+", has-compiler: "+gl.isFunctionAvailable("glCompileShader")+", version "+(gl.hasGLSL() ? gl.glGetString(GL2ES2.GL_SHADING_LANGUAGE_VERSION) : "none"));
+ System.err.println("GL FBO: basic "+ gl.hasBasicFBOSupport()+", full "+gl.hasFullFBOSupport());
+ System.err.println("GL Profile: "+gl.getGLProfile());
+ System.err.println("GL:" + gl + ", " + gl.getContext().getGLVersion());
// Allocate vertex arrays
colors = Buffers.newDirectFloatBuffer(16);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/FBOMix2DemosES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/FBOMix2DemosES2.java
index 3dfbb4893..992f0261c 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/FBOMix2DemosES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/FBOMix2DemosES2.java
@@ -63,9 +63,8 @@ public class FBOMix2DemosES2 implements GLEventListener {
public FBOMix2DemosES2(int swapInterval) {
demo0 = new GearsES2(-1);
- demo0.setIsFBOSlave(true);
+ demo0.setIgnoreFocus(true);
demo1 = new RedSquareES2(-1);
- demo1.setIsFBOSlave(true);
this.swapInterval = swapInterval;
st = new ShaderState();
@@ -245,6 +244,8 @@ public class FBOMix2DemosES2 implements GLEventListener {
}
interleavedVBO.enableBuffer(gl, true);
+ gl.glEnable(GL.GL_TEXTURE_2D);
+
gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4);
interleavedVBO.enableBuffer(gl, false);
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 38e8a15ce..d991e7635 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
@@ -64,8 +64,9 @@ public class GearsES2 implements GLEventListener {
private KeyListener gearsKeys = new GearsKeyAdapter();
private int prevMouseX, prevMouseY;
+ private boolean doRotate = true;
private boolean isInitialized = false;
- boolean isFBOSlave = false;
+ boolean ignoreFocus = false;
public GearsES2(int swapInterval) {
this.swapInterval = swapInterval;
@@ -75,7 +76,8 @@ public class GearsES2 implements GLEventListener {
this.swapInterval = 1;
}
- public void setIsFBOSlave(boolean v) { isFBOSlave = v; }
+ public void setIgnoreFocus(boolean v) { ignoreFocus = v; }
+ public void setDoRotation(boolean rotate) { this.doRotate = rotate; }
public void setPMVUseBackingArray(boolean pmvUseBackingArray) {
this.pmvUseBackingArray = pmvUseBackingArray;
@@ -112,11 +114,16 @@ public class GearsES2 implements GLEventListener {
System.err.println(Thread.currentThread()+" GearsES2.init ...");
GL2ES2 gl = drawable.getGL().getGL2ES2();
+ System.err.println("GearsES2 init on "+Thread.currentThread());
System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities());
System.err.println("INIT GL IS: " + gl.getClass().getName());
System.err.println("GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR));
System.err.println("GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER));
System.err.println("GL_VERSION: " + gl.glGetString(GL.GL_VERSION));
+ System.err.println("GL GLSL: "+gl.hasGLSL()+", has-compiler: "+gl.isFunctionAvailable("glCompileShader")+", version "+(gl.hasGLSL() ? gl.glGetString(GL2ES2.GL_SHADING_LANGUAGE_VERSION) : "none"));
+ System.err.println("GL FBO: basic "+ gl.hasBasicFBOSupport()+", full "+gl.hasFullFBOSupport());
+ System.err.println("GL Profile: "+gl.getGLProfile());
+ System.err.println("GL:" + gl + ", " + gl.getContext().getGLVersion());
gl.glEnable(GL.GL_DEPTH_TEST);
@@ -247,7 +254,9 @@ public class GearsES2 implements GLEventListener {
public void display(GLAutoDrawable drawable) {
// Turn the gears' teeth
- angle += 2.0f;
+ if(doRotate) {
+ angle += 2.0f;
+ }
// Get the GL corresponding to the drawable we are animating
GL2ES2 gl = drawable.getGL().getGL2ES2();
@@ -262,7 +271,7 @@ public class GearsES2 implements GLEventListener {
gl.glEnable(GL.GL_CULL_FACE);
- if( isFBOSlave || hasFocus ) {
+ if( ignoreFocus || hasFocus ) {
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
} else {
gl.glClearColor(0.2f, 0.2f, 0.2f, 0.0f);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/Mix2TexturesES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/Mix2TexturesES2.java
new file mode 100644
index 000000000..26e7e234a
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/Mix2TexturesES2.java
@@ -0,0 +1,216 @@
+/**
+ * Copyright (C) 2011 JogAmp Community. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * 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
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+package com.jogamp.opengl.test.junit.jogl.demos.es2;
+
+import java.nio.FloatBuffer;
+
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2ES2;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLUniformData;
+import javax.media.opengl.fixedfunc.GLMatrixFunc;
+
+import com.jogamp.opengl.util.GLArrayDataServer;
+import com.jogamp.opengl.util.PMVMatrix;
+import com.jogamp.opengl.util.glsl.ShaderCode;
+import com.jogamp.opengl.util.glsl.ShaderProgram;
+import com.jogamp.opengl.util.glsl.ShaderState;
+
+public class Mix2TexturesES2 implements GLEventListener {
+ private final int swapInterval;
+
+ private final ShaderState st;
+ private final PMVMatrix pmvMatrix;
+ private final GLUniformData texUnit0, texUnit1;
+
+ private volatile int texID0, texID1;
+ private ShaderProgram sp0;
+ private GLUniformData pmvMatrixUniform;
+ private GLArrayDataServer interleavedVBO;
+
+ public Mix2TexturesES2(int swapInterval, int texUnit0, int texUnit1) {
+ this.swapInterval = swapInterval;
+
+ st = new ShaderState();
+ // st.setVerbose(true);
+ pmvMatrix = new PMVMatrix();
+
+ if(0 == texUnit1) {
+ this.texUnit0 = new GLUniformData("mgl_ActiveTexture", texUnit0);
+ this.texUnit1 = null;
+ } else {
+ this.texUnit0 = new GLUniformData("mgl_Texture0", texUnit0);
+ this.texUnit1 = new GLUniformData("mgl_Texture1", texUnit1);
+ }
+ this.texID0 = 0;
+ this.texID1 = 0;
+ }
+
+ public void setTexID0(int texID) {
+ this.texID0 = texID;
+ }
+ public void setTexID1(int texID) {
+ this.texID1 = texID;
+ }
+
+ static final String[] es2_prelude = { "#version 100\n", "precision mediump float;\n" };
+ static final String gl2_prelude = "#version 110\n";
+
+ @Override
+ public void init(GLAutoDrawable drawable) {
+ final GL2ES2 gl = drawable.getGL().getGL2ES2();
+
+ final ShaderCode vp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, Mix2TexturesES2.class, "shader",
+ "shader/bin", "texture01_xxx", true);
+ final ShaderCode fp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, Mix2TexturesES2.class, "shader",
+ "shader/bin", null == texUnit1 ? "texture01_xxx" : "texture02_xxx", true);
+
+ // Prelude shader code w/ GLSL profile specifics [ 1. pre-proc, 2. other ]
+ int fp0Pos;
+ if(gl.isGLES2()) {
+ vp0.insertShaderSource(0, 0, es2_prelude[0]);
+ fp0Pos = fp0.insertShaderSource(0, 0, es2_prelude[0]);
+ } else {
+ vp0.insertShaderSource(0, 0, gl2_prelude);
+ fp0Pos = fp0.insertShaderSource(0, 0, gl2_prelude);
+ }
+ if(gl.isGLES2()) {
+ fp0Pos = fp0.insertShaderSource(0, fp0Pos, es2_prelude[1]);
+ }
+
+ sp0 = new ShaderProgram();
+ sp0.add(gl, vp0, System.err);
+ sp0.add(gl, fp0, System.err);
+ st.attachShaderProgram(gl, sp0, true);
+
+ pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf());
+ st.ownUniform(pmvMatrixUniform);
+ st.uniform(gl, pmvMatrixUniform);
+
+ interleavedVBO = GLArrayDataServer.createGLSLInterleaved(3+4+2, GL.GL_FLOAT, false, 3*4, GL.GL_STATIC_DRAW);
+ {
+ interleavedVBO.addGLSLSubArray("mgl_Vertex", 3, GL.GL_ARRAY_BUFFER);
+ interleavedVBO.addGLSLSubArray("mgl_Color", 4, GL.GL_ARRAY_BUFFER);
+ //interleavedVBO.addGLSLSubArray("mgl_Normal", 3, GL.GL_ARRAY_BUFFER);
+ interleavedVBO.addGLSLSubArray("mgl_MultiTexCoord", 2, GL.GL_ARRAY_BUFFER);
+
+ FloatBuffer ib = (FloatBuffer)interleavedVBO.getBuffer();
+
+ for(int i=0; i<4; i++) {
+ ib.put(s_quadVertices, i*3, 3);
+ ib.put(s_quadColors, i*4, 4);
+ //ib.put(s_cubeNormals, i*3, 3);
+ ib.put(s_quadTexCoords, i*2, 2);
+ }
+ }
+ interleavedVBO.seal(gl, true);
+ interleavedVBO.enableBuffer(gl, false);
+ st.ownAttribute(interleavedVBO, true);
+
+ st.ownUniform(texUnit0);
+ st.uniform(gl, texUnit0);
+ if(null != texUnit1) {
+ st.ownUniform(texUnit1);
+ st.uniform(gl, texUnit1);
+ }
+
+ st.useProgram(gl, false);
+ }
+
+ @Override
+ public void dispose(GLAutoDrawable drawable) {
+ final GL2ES2 gl = drawable.getGL().getGL2ES2();
+ st.destroy(gl);
+
+ sp0 = null;
+ pmvMatrixUniform = null;
+ interleavedVBO = null;
+ }
+
+ @Override
+ public void display(GLAutoDrawable drawable) {
+ final GL2ES2 gl = drawable.getGL().getGL2ES2();
+
+ st.useProgram(gl, true);
+ gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+ gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
+
+ interleavedVBO.enableBuffer(gl, true);
+
+ if(0<texID0) {
+ gl.glActiveTexture(GL.GL_TEXTURE0 + texUnit0.intValue());
+ gl.glBindTexture(GL.GL_TEXTURE_2D, texID0);
+ }
+
+ if(0<texID1 && null != texUnit1) {
+ gl.glActiveTexture(GL.GL_TEXTURE0 + texUnit1.intValue());
+ gl.glBindTexture(GL.GL_TEXTURE_2D, texID1);
+ }
+
+ gl.glEnable(GL.GL_TEXTURE_2D);
+
+ gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4);
+
+ interleavedVBO.enableBuffer(gl, false);
+
+ st.useProgram(gl, false);
+ }
+
+ @Override
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ final GL2ES2 gl = drawable.getGL().getGL2ES2();
+
+ if(-1 != swapInterval) {
+ gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there)
+ }
+
+ pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
+ pmvMatrix.glLoadIdentity();
+ pmvMatrix.glOrthof(-1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 10.0f);
+
+ pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
+ pmvMatrix.glLoadIdentity();
+
+ st.useProgram(gl, true);
+ st.uniform(gl, pmvMatrixUniform);
+ st.useProgram(gl, false);
+
+ }
+
+ private static final float[] s_quadVertices = {
+ -1f, -1f, 0f, // LB
+ 1f, -1f, 0f, // RB
+ -1f, 1f, 0f, // LT
+ 1f, 1f, 0f // RT
+ };
+ private static final float[] s_quadColors = {
+ 1f, 1f, 1f, 1f,
+ 1f, 1f, 1f, 1f,
+ 1f, 1f, 1f, 1f,
+ 1f, 1f, 1f, 1f };
+ private static final float[] s_quadTexCoords = {
+ 0f, 0f, // LB
+ 1f, 0f, // RB
+ 0f, 1f, // LT
+ 1f, 1f // RT
+ };
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java
index a956fe1e4..9629d2102 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java
@@ -51,7 +51,6 @@ public class RedSquareES2 implements GLEventListener {
float aspect = 1.0f;
boolean doRotate = true;
boolean isInitialized = false;
- boolean isFBOSlave = false;
public RedSquareES2(int swapInterval) {
this.swapInterval = swapInterval;
@@ -61,7 +60,6 @@ public class RedSquareES2 implements GLEventListener {
this.swapInterval = 1;
}
- public void setIsFBOSlave(boolean v) { isFBOSlave = v; }
public void setAspect(float aspect) { this.aspect = aspect; }
public void setDoRotation(boolean rotate) { this.doRotate = rotate; }
@@ -74,15 +72,16 @@ public class RedSquareES2 implements GLEventListener {
System.err.println(Thread.currentThread()+" RedSquareES2.init ...");
GL2ES2 gl = glad.getGL().getGL2ES2();
- System.err.println(Thread.currentThread()+"Chosen GLCapabilities: " + glad.getChosenGLCapabilities());
- System.err.println(Thread.currentThread()+"INIT GL IS: " + gl.getClass().getName());
- System.err.println(Thread.currentThread()+"GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR));
- System.err.println(Thread.currentThread()+"GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER));
- System.err.println(Thread.currentThread()+"GL_VERSION: " + gl.glGetString(GL.GL_VERSION));
-
- System.err.println(Thread.currentThread()+" GL Profile: "+gl.getGLProfile());
- System.err.println(Thread.currentThread()+" GL:" + gl);
- System.err.println(Thread.currentThread()+" GL_VERSION=" + gl.glGetString(GL.GL_VERSION));
+ System.err.println("RedSquareES2 init on "+Thread.currentThread());
+ System.err.println("Chosen GLCapabilities: " + glad.getChosenGLCapabilities());
+ System.err.println("INIT GL IS: " + gl.getClass().getName());
+ System.err.println("GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR));
+ System.err.println("GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER));
+ System.err.println("GL_VERSION: " + gl.glGetString(GL.GL_VERSION));
+ System.err.println("GL GLSL: "+gl.hasGLSL()+", has-compiler: "+gl.isFunctionAvailable("glCompileShader")+", version "+(gl.hasGLSL() ? gl.glGetString(GL2ES2.GL_SHADING_LANGUAGE_VERSION) : "none"));
+ System.err.println("GL FBO: basic "+ gl.hasBasicFBOSupport()+", full "+gl.hasFullFBOSupport());
+ System.err.println("GL Profile: "+gl.getGLProfile());
+ System.err.println("GL:" + gl + ", " + gl.getContext().getGLVersion());
st = new ShaderState();
st.setVerbose(true);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java
index b3fdaa0ca..732036eb0 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java
@@ -60,12 +60,12 @@ import org.junit.Test;
public class TestGearsES2AWT extends UITestCase {
static int width, height;
- static boolean firstUIActionOnProcess = false;
static boolean forceES2 = false;
static boolean shallUseOffscreenLayer = false;
+ static boolean shallUseOffscreenPBufferLayer = false;
+ static boolean useMSAA = false;
static boolean addComp = true;
static int swapInterval = 1;
- static boolean showFPS = false;
@BeforeClass
public static void initClass() {
@@ -83,7 +83,6 @@ public class TestGearsES2AWT extends UITestCase {
final GLCanvas glCanvas = new GLCanvas(caps);
Assert.assertNotNull(glCanvas);
- glCanvas.setShallUseOffscreenLayer(shallUseOffscreenLayer);
Dimension glc_sz = new Dimension(width, height);
glCanvas.setMinimumSize(glc_sz);
glCanvas.setPreferredSize(glc_sz);
@@ -112,8 +111,8 @@ public class TestGearsES2AWT extends UITestCase {
frame.pack();
frame.setVisible(true);
}});
- animator.setUpdateFPSFrames(60, System.err);
animator.start();
+ animator.setUpdateFPSFrames(60, System.err);
while(!quitAdapter.shouldQuit() /* && animator.isAnimating() */ && animator.getTotalFPSDuration()<duration) {
Thread.sleep(100);
@@ -136,7 +135,17 @@ public class TestGearsES2AWT extends UITestCase {
@Test
public void test01() throws InterruptedException, InvocationTargetException {
- GLCapabilities caps = new GLCapabilities(forceES2 ? GLProfile.get(GLProfile.GLES2) : GLProfile.getGL2ES2());
+ GLCapabilities caps = new GLCapabilities(forceES2 ? GLProfile.get(GLProfile.GLES2) : GLProfile.getGL2ES2());
+ if(useMSAA) {
+ caps.setNumSamples(4);
+ caps.setSampleBuffers(true);
+ }
+ if(shallUseOffscreenLayer) {
+ caps.setOnscreen(false);
+ }
+ if(shallUseOffscreenPBufferLayer) {
+ caps.setPBuffer(true);
+ }
runTestGL(caps);
}
@@ -158,10 +167,10 @@ public class TestGearsES2AWT extends UITestCase {
swapInterval = MiscUtils.atoi(args[i], swapInterval);
} else if(args[i].equals("-layered")) {
shallUseOffscreenLayer = true;
- } else if(args[i].equals("-showFPS")) {
- showFPS = true;
- } else if(args[i].equals("-firstUIAction")) {
- firstUIActionOnProcess = true;
+ } else if(args[i].equals("-layeredPBuffer")) {
+ shallUseOffscreenPBufferLayer = true;
+ } else if(args[i].equals("-msaa")) {
+ useMSAA = true;
} else if(args[i].equals("-wait")) {
waitForKey = true;
} else if(args[i].equals("-justGears")) {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java
index b3166b03b..9c1293e22 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java
@@ -1,7 +1,9 @@
package com.jogamp.opengl.test.junit.jogl.demos.gl2;
+import javax.media.opengl.GL;
import javax.media.opengl.GL2;
+import javax.media.opengl.GL2ES2;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLProfile;
@@ -71,11 +73,16 @@ public class Gears implements GLEventListener {
GL2 gl = drawable.getGL().getGL2();
+ System.err.println("Gears (GL2) init on "+Thread.currentThread());
System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities());
System.err.println("INIT GL IS: " + gl.getClass().getName());
- System.err.println("GL_VENDOR: " + gl.glGetString(GL2.GL_VENDOR));
- System.err.println("GL_RENDERER: " + gl.glGetString(GL2.GL_RENDERER));
- System.err.println("GL_VERSION: " + gl.glGetString(GL2.GL_VERSION));
+ System.err.println("GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR));
+ System.err.println("GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER));
+ System.err.println("GL_VERSION: " + gl.glGetString(GL.GL_VERSION));
+ System.err.println("GL GLSL: "+gl.hasGLSL()+", has-compiler: "+gl.isFunctionAvailable("glCompileShader")+", version "+(gl.hasGLSL() ? gl.glGetString(GL2ES2.GL_SHADING_LANGUAGE_VERSION) : "none"));
+ System.err.println("GL FBO: basic "+ gl.hasBasicFBOSupport()+", full "+gl.hasFullFBOSupport());
+ System.err.println("GL Profile: "+gl.getGLProfile());
+ System.err.println("GL:" + gl + ", " + gl.getContext().getGLVersion());
float pos[] = { 5.0f, 5.0f, 10.0f, 0.0f };
float red[] = { 0.8f, 0.1f, 0.0f, 0.7f };
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGLJPanelAWTBug450.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGLJPanelAWTBug450.java
index 4f97feb4f..bd9b7cae7 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGLJPanelAWTBug450.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGLJPanelAWTBug450.java
@@ -117,7 +117,7 @@ public class TestGLJPanelAWTBug450 extends UITestCase {
}
if(0 == f) {
System.err.println("BGR ("+r_x+"/"+r_y+"): "+byte0+", "+byte1+", "+byte2+" - OK "+(!failed));
- snapshot(getSimpleTestName("."), f, null, gl, screenshot, TextureIO.PNG, null);
+ snapshot(f, null, gl, screenshot, TextureIO.PNG, null);
}
f++;
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBufferBase.java b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBufferBase.java
index 4ef7b2719..f8e064a4e 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBufferBase.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBufferBase.java
@@ -70,7 +70,7 @@ public class ReadBufferBase implements GLEventListener {
_gl.getContext().setGLReadDrawable(externalRead);
if(_gl.isGL2GL3()) {
- _gl.getGL2GL3().glReadBuffer(GL2GL3.GL_FRONT);
+ _gl.getGL2GL3().glReadBuffer(GL.GL_FRONT);
}
System.out.println("---------------------------");
System.out.println(_gl.getContext());
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTGLn.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTGLn.java
index 6a27e6f27..fe40cec28 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTGLn.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTGLn.java
@@ -139,7 +139,7 @@ public class TestNewtCanvasSWTGLn extends UITestCase {
public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) { }
public void display(final GLAutoDrawable drawable) {
if(displayCount < 3) {
- snapshot(getSimpleTestName("."), displayCount++, null, drawable.getGL(), screenshot, TextureIO.PNG, null);
+ snapshot(displayCount++, null, drawable.getGL(), screenshot, TextureIO.PNG, null);
}
}
public void dispose(final GLAutoDrawable drawable) { }
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTJOGLGLCanvas01GLn.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTJOGLGLCanvas01GLn.java
index 4ca1dae0d..6d9e2219c 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTJOGLGLCanvas01GLn.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTJOGLGLCanvas01GLn.java
@@ -134,7 +134,7 @@ public class TestSWTJOGLGLCanvas01GLn extends UITestCase {
public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) { }
public void display(final GLAutoDrawable drawable) {
if(displayCount < 3) {
- snapshot(getSimpleTestName("."), displayCount++, null, drawable.getGL(), screenshot, TextureIO.PNG, null);
+ snapshot(displayCount++, null, drawable.getGL(), screenshot, TextureIO.PNG, null);
}
}
public void dispose(final GLAutoDrawable drawable) { }
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite01AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite01AWT.java
index 6cee319ba..e2252d635 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite01AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite01AWT.java
@@ -96,8 +96,8 @@ public class TestGLReadBufferUtilTextureIOWrite01AWT extends UITestCase {
public void init(GLAutoDrawable drawable) {}
public void dispose(GLAutoDrawable drawable) {}
public void display(GLAutoDrawable drawable) {
- snapshot(getSimpleTestName("."), f, null, drawable.getGL(), screenshotRGBA, TextureIO.PNG, null);
- snapshot(getSimpleTestName("."), f, null, drawable.getGL(), screenshotRGB, TextureIO.PNG, null);
+ snapshot(f, null, drawable.getGL(), screenshotRGBA, TextureIO.PNG, null);
+ snapshot(f, null, drawable.getGL(), screenshotRGB, TextureIO.PNG, null);
f++;
}
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { }
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite01NEWT.java
index 5681df0ad..16bd94cfe 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite01NEWT.java
@@ -75,12 +75,12 @@ public class TestGLReadBufferUtilTextureIOWrite01NEWT extends UITestCase {
public void init(GLAutoDrawable drawable) {}
public void dispose(GLAutoDrawable drawable) {}
public void display(GLAutoDrawable drawable) {
- snapshot(getSimpleTestName("."), f++, null, drawable.getGL(), screenshotRGBA, TextureIO.PNG, null);
- snapshot(getSimpleTestName("."), f++, null, drawable.getGL(), screenshotRGB, TextureIO.PNG, null);
- snapshot(getSimpleTestName("."), f++, null, drawable.getGL(), screenshotRGBA, TextureIO.TGA, null);
- snapshot(getSimpleTestName("."), f++, null, drawable.getGL(), screenshotRGB, TextureIO.TGA, null);
- snapshot(getSimpleTestName("."), f++, null, drawable.getGL(), screenshotRGBA, TextureIO.PAM, null);
- snapshot(getSimpleTestName("."), f++, null, drawable.getGL(), screenshotRGB, TextureIO.PAM, null);
+ snapshot(f++, null, drawable.getGL(), screenshotRGBA, TextureIO.PNG, null);
+ snapshot(f++, null, drawable.getGL(), screenshotRGB, TextureIO.PNG, null);
+ snapshot(f++, null, drawable.getGL(), screenshotRGBA, TextureIO.TGA, null);
+ snapshot(f++, null, drawable.getGL(), screenshotRGB, TextureIO.TGA, null);
+ snapshot(f++, null, drawable.getGL(), screenshotRGBA, TextureIO.PAM, null);
+ snapshot(f++, null, drawable.getGL(), screenshotRGB, TextureIO.PAM, null);
}
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { }
});
@@ -103,8 +103,8 @@ public class TestGLReadBufferUtilTextureIOWrite01NEWT extends UITestCase {
public void init(GLAutoDrawable drawable) {}
public void dispose(GLAutoDrawable drawable) {}
public void display(GLAutoDrawable drawable) {
- snapshot(getSimpleTestName("."), f, null, drawable.getGL(), screenshotRGBA, TextureIO.PNG, null);
- snapshot(getSimpleTestName("."), f, null, drawable.getGL(), screenshotRGB, TextureIO.PNG, null);
+ snapshot(f, null, drawable.getGL(), screenshotRGBA, TextureIO.PNG, null);
+ snapshot(f, null, drawable.getGL(), screenshotRGB, TextureIO.PNG, null);
f++;
}
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { }
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02AWT.java
index 43641fe6d..bec55d868 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02AWT.java
@@ -111,7 +111,7 @@ public class TestGLReadBufferUtilTextureIOWrite02AWT extends UITestCase {
if(snap) {
System.err.println("XXX: ["+fw_old+", "+dw_old+"], "+fw+"x"+fh+", "+dw+"x"+dh+", sz_changed "+sz_changed+", snap "+snap);
c=0;
- snapshot(getSimpleTestName("."), i++, null, drawable.getGL(), screenshot, TextureIO.PNG, null);
+ snapshot(i++, null, drawable.getGL(), screenshot, TextureIO.PNG, null);
dw_old = dw;
fw_old = fw;
Threading.invoke(true, new Runnable() {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02NEWT.java
index d1ffa84cf..36d905a2c 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02NEWT.java
@@ -94,7 +94,7 @@ public class TestGLReadBufferUtilTextureIOWrite02NEWT extends UITestCase {
if(snap) {
System.err.println("XXX: ["+dw_old+"], "+dw+"x"+dh+", sz_changed "+sz_changed+", snap "+snap);
c=0;
- snapshot(getSimpleTestName("."), i++, null, drawable.getGL(), screenshot, TextureIO.PNG, null);
+ snapshot(i++, null, drawable.getGL(), screenshot, TextureIO.PNG, null);
dw_old = dw;
new Thread() {
@Override
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileAWT.java
index 0d4f2b01e..7dbccd5e0 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileAWT.java
@@ -140,7 +140,7 @@ public class TestPNGTextureFromFileAWT extends UITestCase {
// 1 snapshot
if(null!=((TextureDraw01Accessor)gle).getTexture() && !shot) {
shot = true;
- snapshot(getSimpleTestName("."), 0, null, drawable.getGL(), screenshot, TextureIO.PNG, null);
+ snapshot(0, null, drawable.getGL(), screenshot, TextureIO.PNG, null);
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileNEWT.java
index b4faafbe7..e9ef9b9b6 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileNEWT.java
@@ -112,7 +112,7 @@ public class TestPNGTextureFromFileNEWT extends UITestCase {
// 1 snapshot
if(null!=((TextureDraw01Accessor)gle).getTexture() && !shot) {
shot = true;
- snapshot(getSimpleTestName("."), 0, null, drawable.getGL(), screenshot, TextureIO.PNG, null);
+ snapshot(0, null, drawable.getGL(), screenshot, TextureIO.PNG, null);
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java b/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java
index bb67e77ea..592b00144 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java
@@ -35,6 +35,7 @@ import org.junit.Assume;
import java.awt.AWTException;
import java.awt.BorderLayout;
import java.awt.Button;
+import java.awt.Container;
import java.awt.Robot;
import java.lang.reflect.InvocationTargetException;
@@ -55,6 +56,15 @@ import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2;
import com.jogamp.opengl.test.junit.util.*;
+/**
+ * Testing focus traversal of an AWT component tree with {@link NewtCanvasAWT} attached.
+ * <p>
+ * {@link JFrame} . {@link Container}+ . {@link NewtCanvasAWT} . {@link GLWindow}
+ * </p>
+ * <p>
+ * <i>+ Container is the JFrame's implicit root content pane</i><br/>
+ * </p>
+ */
public class TestFocus01SwingAWTRobot extends UITestCase {
static int width, height;
static long durationPerTest = 10;
@@ -125,6 +135,10 @@ public class TestFocus01SwingAWTRobot extends UITestCase {
AWTKeyAdapter buttonKA = new AWTKeyAdapter("Button");
button.addKeyListener(buttonKA);
eventCountAdapters.add(buttonKA);
+ AWTMouseAdapter buttonMA = new AWTMouseAdapter("Button");
+ button.addMouseListener(buttonMA);
+ eventCountAdapters.add(buttonMA);
+
frame1.getContentPane().add(button, BorderLayout.NORTH);
frame1.setSize(width, height);
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
@@ -158,13 +172,18 @@ public class TestFocus01SwingAWTRobot extends UITestCase {
Assert.assertEquals(false, newtCanvasAWTFA.focusGained());
System.err.println("FOCUS AWT Button sync");
AWTRobotUtil.assertKeyType(robot, java.awt.event.KeyEvent.VK_A, 2, button, buttonKA);
+ AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 1,
+ button, buttonMA);
+ AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 2,
+ button, buttonMA);
// Request the AWT focus, which should automatically provide the NEWT window with focus.
Thread.sleep(100); // allow event sync
System.err.println("FOCUS NEWT Canvas/GLWindow request");
EventCountAdapterUtil.reset(eventCountAdapters);
AWTRobotUtil.assertRequestFocusAndWait(robot, newtCanvasAWT, newtCanvasAWT.getNEWTChild(), glWindow1FA, buttonFA);
- Assert.assertEquals(false, newtCanvasAWTFA.focusGained());
+ Assert.assertTrue("Focus prev. gained, but NewtCanvasAWT didn't loose it. Gainer: "+glWindow1FA+"; Looser "+newtCanvasAWTFA,
+ AWTRobotUtil.waitForFocus(glWindow1FA, newtCanvasAWTFA));
System.err.println("FOCUS NEWT Canvas/GLWindow sync");
AWTRobotUtil.assertKeyType(robot, java.awt.event.KeyEvent.VK_A, 2, glWindow1, glWindow1KA);
Assert.assertEquals("AWT parent canvas received keyboard events", 0, newtCanvasAWTKA.getCount());
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java b/src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java
index a0efa53ad..d8a9640c1 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java
@@ -56,6 +56,15 @@ import java.io.IOException;
import com.jogamp.opengl.test.junit.util.*;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+/**
+ * Testing focus traversal of an AWT component tree with {@link NewtCanvasAWT} attached.
+ * <p>
+ * {@link JFrame} . {@link JPanel}+ . {@link Container} . {@link NewtCanvasAWT} . {@link GLWindow}
+ * </p>
+ * <p>
+ * <i>+ JPanel is set as JFrame's root content pane</i><br/>
+ * </p>
+ */
public class TestFocus02SwingAWTRobot extends UITestCase {
static int width, height;
static long durationPerTest = 10;
@@ -85,9 +94,6 @@ public class TestFocus02SwingAWTRobot extends UITestCase {
ArrayList<EventCountAdapter> eventCountAdapters = new ArrayList<EventCountAdapter>();
- /**
- * JFrame . JPanel . Container . NewtCanvasAWT . GLWindow
- */
GLWindow glWindow1 = GLWindow.create(glCaps);
glWindow1.setTitle("testWindowParenting01CreateVisibleDestroy");
GLEventListener demo1 = new GearsES2();
@@ -225,7 +231,9 @@ public class TestFocus02SwingAWTRobot extends UITestCase {
System.err.println("FOCUS NEWT Canvas/GLWindow request");
EventCountAdapterUtil.reset(eventCountAdapters);
AWTRobotUtil.assertRequestFocusAndWait(robot, newtCanvasAWT, newtCanvasAWT.getNEWTChild(), glWindow1FA, buttonNorthInnerFA);
- Assert.assertTrue(AWTRobotUtil.waitForFocusCount(false, newtCanvasAWTFA));
+ Assert.assertTrue("Focus prev. gained, but NewtCanvasAWT didn't loose it. Gainer: "+glWindow1FA+"; Looser "+newtCanvasAWTFA,
+ AWTRobotUtil.waitForFocus(glWindow1FA, newtCanvasAWTFA));
+
Assert.assertEquals(false, newtCanvasAWTFA.focusGained());
Assert.assertEquals(false, buttonNorthOuterFA.focusGained());
Assert.assertEquals(false, jFrame1FA.focusGained());
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestWindows01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestWindows01NEWT.java
index bf72348f9..e03b5e7d6 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestWindows01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestWindows01NEWT.java
@@ -33,7 +33,6 @@ import org.junit.BeforeClass;
import org.junit.Test;
import javax.media.nativewindow.*;
-import javax.media.nativewindow.util.Point;
import com.jogamp.newt.*;
import java.io.IOException;
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java
index 473f2f584..f7881615d 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java
@@ -36,7 +36,7 @@ import com.jogamp.newt.event.KeyAdapter;
import com.jogamp.newt.event.KeyEvent;
import com.jogamp.newt.opengl.GLWindow;
-class NewtAWTReparentingKeyAdapter extends KeyAdapter {
+public class NewtAWTReparentingKeyAdapter extends KeyAdapter {
Frame frame;
NewtCanvasAWT newtCanvasAWT;
GLWindow glWindow;
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 9e96db5e1..160653cd5 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java
@@ -275,24 +275,29 @@ public class AWTRobotUtil {
*
* @return True if the Window became the global focused Window within TIME_OUT
*/
- public static boolean waitForFocus(Object obj, FocusEventCountAdapter gain,
- FocusEventCountAdapter lost) throws InterruptedException {
- if(!waitForFocus(obj)) {
- return false;
- }
- if(null == gain) {
- return true;
- }
-
+ public static boolean waitForFocus(FocusEventCountAdapter gain,
+ FocusEventCountAdapter lost) throws InterruptedException {
int wait;
for (wait=0; wait<POLL_DIVIDER; wait++) {
- if( ( null == lost || lost.focusLost() ) && gain.focusGained() ) {
+ if( ( null == lost || lost.focusLost() ) && ( null == gain || gain.focusGained() ) ) {
return true;
}
Thread.sleep(TIME_SLICE);
}
return false;
}
+
+ /**
+ *
+ * @return True if the Window became the global focused Window within TIME_OUT
+ */
+ public static boolean waitForFocus(Object obj, FocusEventCountAdapter gain,
+ FocusEventCountAdapter lost) throws InterruptedException {
+ if(!waitForFocus(obj)) {
+ return false;
+ }
+ return waitForFocus(gain, lost);
+ }
public static void assertRequestFocusAndWait(Robot robot, Object requestFocus, Object waitForFocus,
FocusEventCountAdapter gain, FocusEventCountAdapter lost)
@@ -461,20 +466,6 @@ public class AWTRobotUtil {
/**
*
- * @return True if the FocusEventCountAdapter became the desired value within TIME_OUT
- */
- public static boolean waitForFocusCount(boolean desired, FocusEventCountAdapter eca) throws InterruptedException {
- for (int wait=0; wait<POLL_DIVIDER; wait++) {
- if( desired && eca.focusGained() || !desired && eca.focusLost() ) {
- return true;
- }
- Thread.sleep(TIME_SLICE);
- }
- return false;
- }
-
- /**
- *
* @return True if the Component becomes <code>visible</code> within TIME_OUT
*/
public static boolean waitForVisible(Object obj, boolean visible) throws InterruptedException {
diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTGLContext.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTGLContext.java
index 3f989bfa4..a76b67d57 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/NEWTGLContext.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTGLContext.java
@@ -70,8 +70,8 @@ public class NEWTGLContext {
Assert.assertNotNull(window);
window.setSize(width, height);
window.setVisible(true);
- AWTRobotUtil.waitForVisible(window, true);
- AWTRobotUtil.waitForRealized(window, true);
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(window, true));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(window, true));
GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile());
GLDrawable drawable = factory.createGLDrawable(window);
diff --git a/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java b/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java
index c07d5b741..c42d9ff62 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java
@@ -29,12 +29,14 @@
package com.jogamp.opengl.test.junit.util;
import java.io.File;
-import java.io.PrintWriter;
-import java.io.StringWriter;
+import java.util.Iterator;
+import java.util.List;
import javax.media.opengl.GL;
+import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilitiesImmutable;
import javax.media.opengl.GLDrawable;
+import javax.media.opengl.GLEventListener;
import com.jogamp.common.util.locks.SingletonInstance;
import com.jogamp.opengl.util.GLReadBufferUtil;
@@ -47,6 +49,8 @@ import org.junit.After;
import org.junit.AfterClass;
import org.junit.Rule;
import org.junit.rules.TestName;
+import org.junit.runners.model.FrameworkMethod;
+import org.junit.runners.model.TestClass;
public abstract class UITestCase {
@@ -58,9 +62,11 @@ public abstract class UITestCase {
public static final long SINGLE_INSTANCE_LOCK_TO = 3*60*1000; // wait up to 3 min
public static final long SINGLE_INSTANCE_LOCK_POLL = 1000; // poll every 1s
- static volatile SingletonInstance singletonInstance;
+ private static volatile SingletonInstance singletonInstance;
- static volatile boolean testSupported = true;
+ private static volatile boolean testSupported = true;
+
+ private static volatile int maxMethodNameLen = 0;
private static final synchronized void initSingletonInstance() {
if( null == singletonInstance ) {
@@ -77,6 +83,20 @@ public abstract class UITestCase {
testSupported = v;
}
+ public int getMaxTestNameLen() {
+ if(0 == maxMethodNameLen) {
+ int ml = 0;
+ final TestClass tc = new TestClass(getClass());
+ final List<FrameworkMethod> testMethods = tc.getAnnotatedMethods(org.junit.Test.class);
+ for(Iterator<FrameworkMethod> iter=testMethods.iterator(); iter.hasNext(); ) {
+ final int l = iter.next().getName().length();
+ if( ml < l ) { ml = l; }
+ }
+ maxMethodNameLen = ml;
+ }
+ return maxMethodNameLen;
+ }
+
public final String getTestMethodName() {
return _unitTestName.getMethodName();
}
@@ -120,13 +140,12 @@ public abstract class UITestCase {
static final String unsupportedTestMsg = "Test not supported on this platform.";
/**
- * Takes a snapshot of the drawable's current framebuffer. Example filenames:
+ * Takes a snapshot of the drawable's current front framebuffer. Example filenames:
* <pre>
- * TestFBODrawableNEWT.test01-F_rgba-I_rgba-S0_default-GL2-n0004-0800x0600.png
- * TestFBODrawableNEWT.test01-F_rgba-I_rgba-S0_default-GL2-n0005-0800x0600.png
+ * TestGLDrawableAutoDelegateOnOffscrnCapsNEWT.testES2OffScreenFBOSglBuf____-n0001-msaa0-GLES2_-sw-fbobject-Bdbl-Frgb__Irgb_-S00_default-0400x0300.png
+ * TestGLDrawableAutoDelegateOnOffscrnCapsNEWT.testES2OffScreenPbufferDblBuf-n0003-msaa0-GLES2_-sw-pbuffer_-Bdbl-Frgb__Irgb_-S00_default-0200x0150.png
+ * TestGLDrawableAutoDelegateOnOffscrnCapsNEWT.testGL2OffScreenPbufferSglBuf-n0003-msaa0-GL2___-hw-pbuffer_-Bone-Frgb__Irgb_-S00_default-0200x0150.png
* </pre>
- *
- * @param simpleTestName will be used as the filename prefix
* @param sn sequential number
* @param postSNDetail optional detail to be added to the filename after <code>sn</code>
* @param gl the current GL context object. It's read drawable is being used as the pixel source and to gather some details which will end up in the filename.
@@ -137,30 +156,80 @@ public abstract class UITestCase {
* It shall not end with a directory separator, {@link File#separatorChar}.
* If <code>null</code> the current working directory is being used.
*/
- public static void snapshot(String simpleTestName, int sn, String postSNDetail, GL gl, GLReadBufferUtil readBufferUtil, String fileSuffix, String destPath) {
+ public void snapshot(int sn, String postSNDetail, GL gl, GLReadBufferUtil readBufferUtil, String fileSuffix, String destPath) {
if(null == fileSuffix) {
fileSuffix = TextureIO.PNG;
}
- final StringWriter filenameSW = new StringWriter();
- {
+ final int maxSimpleTestNameLen = getMaxTestNameLen()+getClass().getSimpleName().length()+1;
+ final String simpleTestName = this.getSimpleTestName(".");
+ final String filenameBaseName;
+ {
final GLDrawable drawable = gl.getContext().getGLReadDrawable();
final GLCapabilitiesImmutable caps = drawable.getChosenGLCapabilities();
+ final String accel = caps.getHardwareAccelerated() ? "hw" : "sw" ;
+ final String scrnm;
+ if(caps.isOnscreen()) {
+ scrnm = "onscreen";
+ } else if(caps.isFBO()) {
+ scrnm = "fbobject";
+ } else if(caps.isPBuffer()) {
+ scrnm = "pbuffer_";
+ } else if(caps.isBitmap()) {
+ scrnm = "bitmap__";
+ } else {
+ scrnm = "unknown_";
+ }
+ final String dblb = caps.getDoubleBuffered() ? "dbl" : "one";
final String F_pfmt = readBufferUtil.hasAlpha() ? "rgba" : "rgb_";
final String pfmt = caps.getAlphaBits() > 0 ? "rgba" : "rgb_";
- final String aaext = caps.getSampleExtension();
final int samples = caps.getNumSamples() ;
+ final String aaext = caps.getSampleExtension();
postSNDetail = null != postSNDetail ? "-"+postSNDetail : "";
- final PrintWriter pw = new PrintWriter(filenameSW);
- pw.printf("%s-n%04d%s-F_%s-I_%s-S%d_%s-%s-%04dx%04d.%s",
- simpleTestName, sn, postSNDetail, F_pfmt, pfmt, samples, aaext, drawable.getGLProfile().getName(),
- drawable.getWidth(), drawable.getHeight(), fileSuffix);
+
+ filenameBaseName = String.format("%-"+maxSimpleTestNameLen+"s-n%04d%s-%-6s-%s-%s-B%s-F%s_I%s-S%02d_%s-%04dx%04d.%s",
+ simpleTestName, sn, postSNDetail, drawable.getGLProfile().getName(), accel,
+ scrnm, dblb, F_pfmt, pfmt, samples, aaext,
+ drawable.getWidth(), drawable.getHeight(), fileSuffix).replace(' ', '_');
}
- final String filename = null != destPath ? destPath + File.separator + filenameSW.toString() : filenameSW.toString();
- System.err.println(Thread.currentThread().getName()+": ** screenshot: "+filename);
+ final String filename = null != destPath ? destPath + File.separator + filenameBaseName : filenameBaseName;
+ System.err.println(Thread.currentThread().getName()+": ** screenshot: "+filename+", maxTestNameLen "+maxSimpleTestNameLen+", <"+simpleTestName+">");
gl.glFinish(); // just make sure rendering finished ..
if(readBufferUtil.readPixels(gl, false)) {
readBufferUtil.write(new File(filename));
}
- }
+ }
+
+ public class SnapshotGLEventListener implements GLEventListener {
+ private final GLReadBufferUtil screenshot;
+ private volatile boolean makeShot = false;
+ private volatile int displayCount=0;
+ private volatile int reshapeCount=0;
+ public SnapshotGLEventListener(GLReadBufferUtil screenshot) {
+ this.screenshot = screenshot;
+ }
+ public SnapshotGLEventListener() {
+ this.screenshot = new GLReadBufferUtil(false, false);
+ }
+
+ public void init(GLAutoDrawable drawable) {}
+ public void dispose(GLAutoDrawable drawable) {}
+ public void display(GLAutoDrawable drawable) {
+ final GL gl = drawable.getGL();
+ System.err.println(Thread.currentThread().getName()+": ** display: "+displayCount+": "+drawable.getWidth()+"x"+drawable.getHeight()+", makeShot "+makeShot);
+ if(makeShot) {
+ makeShot=false;
+ snapshot(displayCount, null, gl, screenshot, TextureIO.PNG, null);
+ }
+ displayCount++;
+ }
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ System.err.println(Thread.currentThread().getName()+": ** reshape: "+reshapeCount+": "+width+"x"+height+" - "+drawable.getWidth()+"x"+drawable.getHeight());
+ reshapeCount++;
+ }
+ public void setMakeSnapshot() {
+ makeShot=true;
+ }
+ };
+
}