From 7f7a23dd0ddf106e6f0c69fc2a05ff92ac56200e Mon Sep 17 00:00:00 2001
From: Sven Gothel
+ * The {@link GLContext} can be assigned later manually via {@link GLAutoDrawable#setContext(GLContext, boolean) setContext(ctx)}
+ * or it will be created lazily at the 1st {@link GLAutoDrawable#display() display()} method call.
* In case the passed {@link GLCapabilitiesImmutable} contains default values, i.e.
* {@link GLCapabilitiesImmutable#isOnscreen() caps.isOnscreen()}
* A FBO based auto drawable, {@link GLOffscreenAutoDrawable.FBO}, is created if both {@link GLCapabilitiesImmutable#isFBO() caps.isFBO()}
@@ -501,12 +502,62 @@ public abstract class GLDrawableFactory {
* the creation of the Offscreen to fail.
*
* @see #createOffscreenDrawable(AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int)
+ * @deprecated Use {@link #createOffscreenAutoDrawable(AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int)
*/
public abstract GLOffscreenAutoDrawable createOffscreenAutoDrawable(AbstractGraphicsDevice device,
GLCapabilitiesImmutable caps,
GLCapabilitiesChooser chooser,
int width, int height,
GLContext shareWith) throws GLException;
+
+ /**
+ * Creates a {@link GLDrawable#isRealized() realized} {@link GLOffscreenAutoDrawable}
+ * incl it's offscreen {@link javax.media.nativewindow.NativeSurface} with the given capabilites and dimensions.
+ *
+ * The {@link GLOffscreenAutoDrawable}'s {@link GLDrawable} is {@link GLDrawable#isRealized() realized}
+ * without an assigned {@link GLContext}.
+ * In case the passed {@link GLCapabilitiesImmutable} contains default values, i.e.
+ * {@link GLCapabilitiesImmutable#isOnscreen() caps.isOnscreen()}
+ * A FBO based auto drawable, {@link GLOffscreenAutoDrawable.FBO}, is created if both {@link GLCapabilitiesImmutable#isFBO() caps.isFBO()}
+ * and {@link GLContext#isFBOAvailable(AbstractGraphicsDevice, GLProfile) canCreateFBO(device, caps.getGLProfile())} is true.
+ *
+ * A Pbuffer based auto drawable is created if both {@link GLCapabilitiesImmutable#isPBuffer() caps.isPBuffer()}
+ * and {@link #canCreateGLPbuffer(AbstractGraphicsDevice, GLProfile) canCreateGLPbuffer(device)} is true.
+ *
+ * If neither FBO nor Pbuffer is available,
+ * a simple pixmap/bitmap auto drawable is created, which is unlikely to be hardware accelerated.
+ *
+ * Lazy {@link GLContext} creation will take a shared {@link GLContext} into account
+ * which has been set {@link #setSharedContext(GLContext) directly}
+ * or {@link #setSharedAutoDrawable(GLAutoDrawable) via another GLAutoDrawable}.
+ * drawable
yet,
- * may be
null
for lazy initialization
+ * may be null
for lazy initialization at 1st {@link #display()}.
* @param upstreamWidget optional UI element holding this instance, see {@link #getUpstreamWidget()}.
* @param ownDevice pass true
if {@link AbstractGraphicsDevice#close()} shall be issued,
* otherwise pass false
. Closing the device is required in case
diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java
index 1a3e1e0c0..5e3731984 100644
--- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java
+++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java
@@ -242,7 +242,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
private class DisposeGLEventListenerAction implements Runnable {
private GLEventListener listener;
- private boolean remove;
+ private final boolean remove;
private DisposeGLEventListenerAction(GLEventListener listener, boolean remove) {
this.listener = listener;
this.remove = remove;
@@ -677,7 +677,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
@Override
public GLContext getContext() {
- return null != drawable ? context : null;
+ return context;
}
@Override
diff --git a/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java b/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java
index 3662223f4..46dc73003 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java
@@ -159,20 +159,20 @@ public class TextRenderer {
static final int kTotalBufferSizeBytesTex = kTotalBufferSizeCoordsTex * 4;
static final int kSizeInBytes_OneVertices_VertexData = kCoordsPerVertVerts * 4;
static final int kSizeInBytes_OneVertices_TexData = kCoordsPerVertTex * 4;
- private Font font;
- private boolean antialiased;
- private boolean useFractionalMetrics;
+ private final Font font;
+ private final boolean antialiased;
+ private final boolean useFractionalMetrics;
// Whether we're attempting to use automatic mipmap generation support
private boolean mipmap;
private RectanglePacker packer;
private boolean haveMaxSize;
- private RenderDelegate renderDelegate;
+ private final RenderDelegate renderDelegate;
private TextureRenderer cachedBackingStore;
private Graphics2D cachedGraphics;
private FontRenderContext cachedFontRenderContext;
- private Mapnull
.
@@ -590,7 +607,7 @@ public abstract class GLContext {
sb.append(toHexString(hashCode()));
sb.append(", handle ");
sb.append(toHexString(contextHandle));
- sb.append(", ");
+ sb.append(", isShared "+isShared()+", ");
sb.append(getGL());
sb.append(",\n\t quirks: ");
if(null != glRendererQuirks) {
diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
index 26bafd961..817dff8ad 100644
--- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
+++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
@@ -475,7 +475,8 @@ public abstract class GLDrawableFactory {
* == true
,
- * it is auto-configured. The latter will set offscreen and also FBO or Pbuffer, whichever is available in that order.
+ * it is auto-configured. Auto configuration will set {@link GLCapabilitiesImmutable caps} to offscreen
+ * and FBO or Pbuffer, whichever is available in that order.
*
+ * The {@link GLContext} can be assigned later manually via {@link GLAutoDrawable#setContext(GLContext, boolean) setContext(ctx)}
+ * or it will be created lazily at the 1st {@link GLAutoDrawable#display() display()} method call.
+ * Lazy {@link GLContext} creation will take a shared {@link GLContext} into account
+ * which has been set {@link GLOffscreenAutoDrawable#setSharedContext(GLContext) directly}
+ * or {@link GLOffscreenAutoDrawable#setSharedAutoDrawable(GLAutoDrawable) via another GLAutoDrawable}.
+ * == true
,
+ * it is auto-configured. Auto configuration will set {@link GLCapabilitiesImmutable caps} to offscreen
+ * and FBO or Pbuffer, whichever is available in that order.
+ * null
for the platform's default device.
+ * @param caps the requested GLCapabilties
+ * @param chooser the custom chooser, may be null for default
+ * @param width the requested offscreen width
+ * @param height the requested offscreen height
+ * @return the created and initialized offscreen {@link GLOffscreenAutoDrawable} instance
+ *
+ * @throws GLException if any window system-specific errors caused
+ * the creation of the Offscreen to fail.
+ *
+ * @see #createOffscreenDrawable(AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int)
+ */
+ public abstract GLOffscreenAutoDrawable createOffscreenAutoDrawable(AbstractGraphicsDevice device,
+ GLCapabilitiesImmutable caps,
+ GLCapabilitiesChooser chooser,
+ int width, int height) throws GLException;
+
/**
* Creates an {@link GLDrawable#isRealized() unrealized} offscreen {@link GLDrawable}
* incl it's offscreen {@link javax.media.nativewindow.NativeSurface} with the given capabilites and dimensions.
@@ -625,7 +676,7 @@ public abstract class GLDrawableFactory {
*
null
for the platform's default device.
* @param capabilities the requested capabilities
diff --git a/src/jogl/classes/javax/media/opengl/GLOffscreenAutoDrawable.java b/src/jogl/classes/javax/media/opengl/GLOffscreenAutoDrawable.java
index be90d935f..d34edaf2e 100644
--- a/src/jogl/classes/javax/media/opengl/GLOffscreenAutoDrawable.java
+++ b/src/jogl/classes/javax/media/opengl/GLOffscreenAutoDrawable.java
@@ -40,7 +40,7 @@ import com.jogamp.opengl.FBObject;
* with it's {@link #setSize(int, int)} functionality.
*
*/
-public interface GLOffscreenAutoDrawable extends GLAutoDrawable {
+public interface GLOffscreenAutoDrawable extends GLAutoDrawable, GLSharedContextSetter {
/**
* Resize this auto drawable.
diff --git a/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java b/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java
new file mode 100644
index 000000000..d5a10931e
--- /dev/null
+++ b/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java
@@ -0,0 +1,78 @@
+/**
+ * Copyright 2013 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package javax.media.opengl;
+
+/**
+ * Adds capabilities to set a shared {@link GLContext} directly or via an {@link GLAutoDrawable}.
+ * + * Warning: Don't reference this interface directly, since it may end up in {@link GLAutoDrawable} + *
+ */ +public interface GLSharedContextSetter extends GLAutoDrawable { + /** + * Specifies an {@link GLContext OpenGL context}, which shall be shared by this {@link GLAutoDrawable}'s {@link GLContext}. + *+ * Since the {@link GLDrawable drawable} and {@link GLContext context} is created + * at {@link GLAutoDrawable#initialization GLAutoDrawable initialization} + * this method shall be called beforehand to have any effect. + *
+ *+ * A set sharedContext will block context creation, i.e. {@link GLAutoDrawable#initialization GLAutoDrawable initialization}, + * as long it is not {@link GLContext#isCreated() created natively}. + *
+ * + * @param sharedContext The OpenGL context to be shared by this {@link GLAutoDrawable}'s {@link GLContext}. + * @throws IllegalStateException if a {@link #setSharedContext(GLContext) shared GLContext} + * or {@link #setSharedAutoDrawable(GLAutoDrawable) shared GLAutoDrawable} is already set, + * the given sharedContext is null or equal to this {@link GLAutoDrawable}'s context. + * @see #setSharedAutoDrawable(GLAutoDrawable) + */ + void setSharedContext(GLContext sharedContext) throws IllegalStateException; + + /** + * Specifies an {@link GLAutoDrawable}, which {@link GLContext OpenGL context} shall be shared by this {@link GLAutoDrawable}'s {@link GLContext}. + *+ * Since the {@link GLDrawable drawable} and {@link GLContext context} is created + * at {@link GLAutoDrawable#initialization GLAutoDrawable initialization} + * this method shall be called beforehand to have any effect. + *
+ *
+ * A set sharedAutoDrawable will block context creation, i.e. {@link GLAutoDrawable#initialization GLAutoDrawable initialization},
+ * as long it's {@link GLContext} is null
+ * or has not been {@link GLContext#isCreated() created natively}.
+ *
false
.
*
*
- * sun.java2d.noddraw=true
+
The GLJPanel can be made transparent by creating it with a GLCapabilities object with alpha bits specified and calling {@link #setOpaque}(false). Pixels with resulting OpenGL alpha values less - than 1.0 will be overlaid on any underlying Swing rendering.
-+ than 1.0 will be overlaid on any underlying Swing rendering. +
+
This component attempts to use hardware-accelerated rendering via FBO or pbuffers and
falls back on to software rendering if none of the former are available
using {@link GLDrawableFactory#createOffscreenDrawable(AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int) GLDrawableFactory.createOffscreenDrawable(..)}.
-
+
+
In case FBO is used and GLSL is available, a fragment shader is utilized
to flip the FBO texture vertically. This hardware-accelerated step can be disabled via system property jogl.gljpanel.noglsl
.
See details here.
-
+
+The OpenGL path is concluded by copying the rendered pixels an {@link BufferedImage} via {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer) glReadPixels(..)} for later Java2D composition.
@@ -210,7 +211,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing return singleAWTGLPixelBufferProvider; } - private GLDrawableHelper helper = new GLDrawableHelper(); + private final GLDrawableHelper helper = new GLDrawableHelper(); private volatile boolean isInitialized; // @@ -219,10 +220,10 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private AWTGLPixelBufferProvider customPixelBufferProvider = null; /** Single buffered offscreen caps */ private GLCapabilitiesImmutable offscreenCaps; - private GLProfile glProfile; - private GLDrawableFactoryImpl factory; - private GLCapabilitiesChooser chooser; - private GLContext shareWith; + private final GLProfile glProfile; + private final GLDrawableFactoryImpl factory; + private final GLCapabilitiesChooser chooser; + private final GLContext shareWith; private int additionalCtxCreationFlags = 0; // Lazy reshape notification: reshapeWidth -> panelWidth -> backend.width @@ -248,13 +249,13 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private volatile Backend backend; // Used by all backends either directly or indirectly to hook up callbacks - private Updater updater = new Updater(); + private final Updater updater = new Updater(); private boolean oglPipelineUsable() { return null == customPixelBufferProvider && useJava2DGLPipeline && java2DGLPipelineOK; } - private AWTWindowClosingProtocol awtWindowClosingProtocol = + private final AWTWindowClosingProtocol awtWindowClosingProtocol = new AWTWindowClosingProtocol(this, new Runnable() { @Override public void run() { @@ -289,7 +290,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing GLContext specifies an OpenGL context with which to share textures, display lists and other OpenGL state, and may be null if sharing is not desired. See the note in the overview documentation on - context sharing. + context sharing.Note: Sharing cannot be enabled using J2D OpenGL FBO sharing, since J2D GL Context must be shared and we can only share one context. @@ -572,8 +573,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE, - printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE, - null); + printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE); GLDrawableUtil.swapGLContextAndAllGLEventListener(GLJPanel.this, printGLAD); printDrawable = printGLAD.getDelegatedDrawable(); } @@ -1158,7 +1158,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private class DisposeGLEventListenerAction implements Runnable { GLEventListener listener; - private boolean remove; + private final boolean remove; private DisposeGLEventListenerAction(GLEventListener listener, boolean remove) { this.listener = listener; this.remove = remove; @@ -1268,12 +1268,12 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing protected IntBuffer readBackIntsForCPUVFlip; // Implementation using software rendering - private GLDrawableImpl offscreenDrawable; + private volatile GLDrawableImpl offscreenDrawable; private boolean offscreenIsFBO; private FBObject fboFlipped; private GLSLTextureRaster glslTextureRaster; - private GLContextImpl offscreenContext; + private volatile GLContextImpl offscreenContext; private boolean flipVertical; // For saving/restoring of OpenGL state during ReadPixels @@ -1694,11 +1694,11 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private GLContext joglContext; // State captured from Java2D OpenGL context necessary in order to // properly render into Java2D back buffer - private int[] drawBuffer = new int[1]; - private int[] readBuffer = new int[1]; + private final int[] drawBuffer = new int[1]; + private final int[] readBuffer = new int[1]; // This is required when the FBO option of the Java2D / OpenGL // pipeline is active - private int[] frameBuffer = new int[1]; + private final int[] frameBuffer = new int[1]; // Current (as of this writing) NVidia drivers have a couple of bugs // relating to the sharing of framebuffer and renderbuffer objects // between contexts. It appears we have to (a) reattach the color diff --git a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java index bb2983399..42d0a2ec4 100644 --- a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java +++ b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java @@ -45,8 +45,10 @@ import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawable; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLException; +import javax.media.opengl.GLOffscreenAutoDrawable; import javax.media.opengl.GLProfile; import javax.media.opengl.GLRunnable; +import javax.media.opengl.GLSharedContextSetter; import com.jogamp.common.util.locks.RecursiveLock; import com.jogamp.opengl.GLAutoDrawableDelegate; @@ -59,17 +61,18 @@ import com.jogamp.opengl.GLStateKeeper; * * @see GLAutoDrawable * @see GLAutoDrawableDelegate + * @see GLOffscreenAutoDrawable + * @see GLOffscreenAutoDrawableImpl * @see GLPBufferImpl - * @see GLWindow + * @see com.jogamp.newt.opengl.GLWindow */ -public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeeper, FPSCounter { +public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeeper, FPSCounter, GLSharedContextSetter { public static final boolean DEBUG = GLDrawableImpl.DEBUG; - protected final GLDrawableHelper helper = new GLDrawableHelper(); protected final FPSCounterImpl fpsCounter = new FPSCounterImpl(); protected volatile GLDrawableImpl drawable; // volatile: avoid locking for read-only access - protected GLContextImpl context; + protected volatile GLContextImpl context; protected boolean preserveGLELSAtDestroy; protected GLEventListenerState glels; protected GLStateKeeper.Listener glStateKeeperListener; @@ -79,12 +82,19 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe protected volatile boolean sendDestroy = false; // volatile: maybe written by WindowManager thread w/o locking /** + *
+ * The {@link GLContext} can be assigned later manually via {@link GLAutoDrawable#setContext(GLContext, boolean) setContext(ctx)}
+ * or it will be created lazily at the 1st {@link GLAutoDrawable#display() display()} method call.
+ * Lazy {@link GLContext} creation will take a shared {@link GLContext} into account
+ * which has been set {@link #setSharedContext(GLContext) directly}
+ * or {@link #setSharedAutoDrawable(GLAutoDrawable) via another GLAutoDrawable}.
+ *
null
for lazy initialization
* @param context upstream {@link GLContextImpl} instance,
* may not have been made current (created) yet,
* may not be associated w/ drawable yet,
- * may be null
for lazy initialization
+ * may be null
for lazy initialization at 1st {@link #display()}.
* @param ownsDevice pass true
if {@link AbstractGraphicsDevice#close()} shall be issued,
* otherwise pass false
. Closing the device is required in case
* the drawable is created w/ it's own new instance, e.g. offscreen drawables,
@@ -103,6 +113,16 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe
resetFPSCounter();
}
+ @Override
+ public final void setSharedContext(GLContext sharedContext) throws IllegalStateException {
+ helper.setSharedContext(this.context, sharedContext);
+ }
+
+ @Override
+ public final void setSharedAutoDrawable(GLAutoDrawable sharedAutoDrawable) throws IllegalStateException {
+ helper.setSharedAutoDrawable(this, sharedAutoDrawable);
+ }
+
/** Returns the recursive lock object of the upstream implementation, which synchronizes multithreaded access on top of {@link NativeSurface#lockSurface()}. */
protected abstract RecursiveLock getLock();
@@ -142,16 +162,16 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe
}
/**
- * Pulls the {@link GLEventListenerState} from this {@link GLAutoDrawable}.
+ * Preserves the {@link GLEventListenerState} from this {@link GLAutoDrawable}.
*
- * @return true
if the {@link GLEventListenerState} is pulled successfully from this {@link GLAutoDrawable},
+ * @return true
if the {@link GLEventListenerState} is preserved successfully from this {@link GLAutoDrawable},
* otherwise false
.
*
- * @throws IllegalStateException if the {@link GLEventListenerState} is already pulled
+ * @throws IllegalStateException if the {@link GLEventListenerState} is already preserved
*
- * @see #pushGLEventListenerState()
+ * @see #restoreGLEventListenerState()
*/
- protected final boolean pullGLEventListenerState() throws IllegalStateException {
+ protected final boolean preserveGLEventListenerState() throws IllegalStateException {
if( null != glels ) {
throw new IllegalStateException("GLEventListenerState already pulled");
}
@@ -166,15 +186,15 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe
}
/**
- * Pushes a previously {@link #pullGLEventListenerState() pulled} {@link GLEventListenerState} to this {@link GLAutoDrawable}.
+ * Restores a previously {@link #preserveGLEventListenerState() preserved} {@link GLEventListenerState} to this {@link GLAutoDrawable}.
*
- * @return true
if the {@link GLEventListenerState} was previously {@link #pullGLEventListenerState() pulled}
- * and is pushed successfully to this {@link GLAutoDrawable},
+ * @return true
if the {@link GLEventListenerState} was previously {@link #preserveGLEventListenerState() preserved}
+ * and is moved successfully to this {@link GLAutoDrawable},
* otherwise false
.
*
- * @see #pullGLEventListenerState()
+ * @see #preserveGLEventListenerState()
*/
- protected final boolean pushGLEventListenerState() {
+ protected final boolean restoreGLEventListenerState() {
if( null != glels ) {
glels.moveTo(this);
glels = null;
@@ -320,7 +340,7 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe
protected void destroyImplInLock() {
if( preserveGLELSAtDestroy ) {
preserveGLStateAtDestroy(false);
- pullGLEventListenerState();
+ preserveGLEventListenerState();
}
if( null != context ) {
if( context.isCreated() ) {
@@ -389,7 +409,25 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe
final RecursiveLock _lock = getLock();
_lock.lock();
try {
- if( null != context ) {
+ if( null == context ) {
+ boolean contextCreated = false;
+ final GLDrawableImpl _drawable = drawable;
+ if ( null != _drawable && _drawable.isRealized() && 0<_drawable.getWidth()*_drawable.getHeight() ) {
+ final GLContext[] shareWith = { null };
+ if( !helper.isSharedGLContextPending(shareWith) ) {
+ if( !restoreGLEventListenerState() ) {
+ context = (GLContextImpl) _drawable.createContext(shareWith[0]);
+ context.setContextCreationFlags(additionalCtxCreationFlags);
+ contextCreated = true;
+ // surface is locked/unlocked implicit by context's makeCurrent/release
+ helper.invokeGL(_drawable, context, defaultDisplayAction, defaultInitAction);
+ }
+ }
+ }
+ if(DEBUG) {
+ System.err.println("GLAutoDrawableBase.defaultDisplay: contextCreated "+contextCreated);
+ }
+ } else {
// surface is locked/unlocked implicit by context's makeCurrent/release
helper.invokeGL(drawable, context, defaultDisplayAction, defaultInitAction);
}
diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
index dff55488d..377ebd9f5 100644
--- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
@@ -429,7 +429,7 @@ public abstract class GLContextImpl extends GLContext {
contextHandle = 0;
glDebugHandler = null;
// this maybe impl. in a platform specific way to release remaining shared ctx.
- if(GLContextShareSet.contextDestroyed(this) && !GLContextShareSet.hasCreatedSharedLeft(this)) {
+ if( GLContextShareSet.contextDestroyed(this) && !GLContextShareSet.hasCreatedSharedLeft(this) ) {
GLContextShareSet.unregisterSharing(this);
}
resetStates(false);
@@ -647,7 +647,7 @@ public abstract class GLContextImpl extends GLContext {
additionalCtxCreationFlags |= GLContext.CTX_OPTION_DEBUG ;
}
- final GLContextImpl shareWith = (GLContextImpl) GLContextShareSet.getShareContext(this);
+ final GLContextImpl shareWith = (GLContextImpl) GLContextShareSet.getCreatedShare(this);
if (null != shareWith) {
shareWith.getDrawableImpl().lockSurface();
}
diff --git a/src/jogl/classes/jogamp/opengl/GLContextShareSet.java b/src/jogl/classes/jogamp/opengl/GLContextShareSet.java
index 70ade34b7..483767b44 100644
--- a/src/jogl/classes/jogamp/opengl/GLContextShareSet.java
+++ b/src/jogl/classes/jogamp/opengl/GLContextShareSet.java
@@ -40,7 +40,8 @@
package jogamp.opengl;
-import java.util.HashMap;
+import java.util.ArrayList;
+import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
@@ -59,15 +60,15 @@ public class GLContextShareSet {
// This class is implemented using a HashMap which maps from all shared contexts
// to a share set, containing all shared contexts itself.
- private static final Map shareMap = new HashMap();
+ private static final Map shareMap = new IdentityHashMap();
private static final Object dummyValue = new Object();
private static class ShareSet {
- private Map allShares = new HashMap();
- private Map createdShares = new HashMap();
- private Map destroyedShares = new HashMap();
+ private final Map allShares = new IdentityHashMap();
+ private final Map createdShares = new IdentityHashMap();
+ private final Map destroyedShares = new IdentityHashMap();
- public void add(GLContext ctx) {
+ public void add(final GLContext ctx) {
if (allShares.put(ctx, dummyValue) == null) {
if (ctx.isCreated()) {
createdShares.put(ctx, dummyValue);
@@ -85,9 +86,9 @@ public class GLContextShareSet {
return destroyedShares.keySet();
}
- public GLContext getCreatedShare(GLContext ignore) {
- for (Iterator iter = createdShares.keySet().iterator(); iter.hasNext(); ) {
- GLContext ctx = iter.next();
+ public GLContext getCreatedShare(final GLContext ignore) {
+ for (final Iterator iter = createdShares.keySet().iterator(); iter.hasNext(); ) {
+ final GLContext ctx = iter.next();
if (ctx != ignore) {
return ctx;
}
@@ -95,21 +96,21 @@ public class GLContextShareSet {
return null;
}
- public void contextCreated(GLContext ctx) {
- Object res = destroyedShares.remove(ctx);
+ public void contextCreated(final GLContext ctx) {
+ final Object res = destroyedShares.remove(ctx);
assert res != null : "State of ShareSet corrupted; thought context " +
ctx + " should have been in destroyed set but wasn't";
- res = createdShares.put(ctx, dummyValue);
- assert res == null : "State of ShareSet corrupted; thought context " +
+ final Object res2 = createdShares.put(ctx, dummyValue);
+ assert res2 == null : "State of ShareSet corrupted; thought context " +
ctx + " shouldn't have been in created set but was";
}
- public void contextDestroyed(GLContext ctx) {
- Object res = createdShares.remove(ctx);
+ public void contextDestroyed(final GLContext ctx) {
+ final Object res = createdShares.remove(ctx);
assert res != null : "State of ShareSet corrupted; thought context " +
ctx + " should have been in created set but wasn't";
- res = destroyedShares.put(ctx, dummyValue);
- assert res == null : "State of ShareSet corrupted; thought context " +
+ final Object res2 = destroyedShares.put(ctx, dummyValue);
+ assert res2 == null : "State of ShareSet corrupted; thought context " +
ctx + " shouldn't have been in destroyed set but was";
}
}
@@ -117,7 +118,7 @@ public class GLContextShareSet {
/** Indicate that contexts share1
and
share2
will share textures and display lists. Both
must be non-null. */
- public static synchronized void registerSharing(GLContext share1, GLContext share2) {
+ public static synchronized void registerSharing(final GLContext share1, final GLContext share2) {
if (share1 == null || share2 == null) {
throw new IllegalArgumentException("Both share1 and share2 must be non-null");
}
@@ -138,7 +139,7 @@ public class GLContextShareSet {
}
}
- public static synchronized void unregisterSharing(GLContext lastContext) {
+ public static synchronized void unregisterSharing(final GLContext lastContext) {
if (lastContext == null) {
throw new IllegalArgumentException("Last context is null");
}
@@ -166,7 +167,25 @@ public class GLContextShareSet {
}
}
- private static synchronized Set getCreatedSharedImpl(GLContext context) {
+ /** Returns true if the given GLContext is shared, otherwise false. */
+ public static synchronized boolean isShared(final GLContext context) {
+ if (context == null) {
+ throw new IllegalArgumentException("context is null");
+ }
+ final ShareSet share = entryFor(context);
+ return share != null;
+ }
+
+ /** Returns one created GLContext shared with the given context
, otherwise return null
. */
+ public static synchronized GLContext getCreatedShare(final GLContext context) {
+ final ShareSet share = entryFor(context);
+ if (share == null) {
+ return null;
+ }
+ return share.getCreatedShare(context);
+ }
+
+ private static synchronized Set getCreatedSharesImpl(final GLContext context) {
if (context == null) {
throw new IllegalArgumentException("context is null");
}
@@ -176,50 +195,56 @@ public class GLContextShareSet {
}
return null;
}
-
- public static synchronized boolean isShared(GLContext context) {
+ private static synchronized Set getDestroyedSharesImpl(final GLContext context) {
if (context == null) {
throw new IllegalArgumentException("context is null");
}
final ShareSet share = entryFor(context);
- return share != null;
+ if (share != null) {
+ return share.getDestroyedShares();
+ }
+ return null;
}
+ /** Returns true if the given GLContext has shared and created GLContext left including itself, otherwise false. */
public static synchronized boolean hasCreatedSharedLeft(GLContext context) {
- final Set s = getCreatedSharedImpl(context);
- return null != s && s.size()>0 ;
+ final Set s = getCreatedSharesImpl(context);
+ return null != s && s.size() > 0;
}
- /** currently not used ..
- public static synchronized Set getCreatedShared(GLContext context) {
- final Set s = getCreatedSharedImpl(context);
- if (s == null) {
- throw new GLException("context is unknown: "+context);
- }
- return s;
+ /** Returns a new array-list of created GLContext shared with the given GLContext. */
+ public static synchronized ArrayList getCreatedShares(final GLContext context) {
+ final ArrayList otherShares = new ArrayList();
+ final Set createdShares = getCreatedSharesImpl(context);
+ if( null != createdShares ) {
+ for (final Iterator iter = createdShares.iterator(); iter.hasNext(); ) {
+ final GLContext ctx = iter.next();
+ if (ctx != context) {
+ otherShares.add(ctx);
+ }
+ }
+ }
+ return otherShares;
}
- public static synchronized Set getDestroyedShared(GLContext context) {
- if (context == null) {
- throw new IllegalArgumentException("context is null");
- }
- ShareSet share = entryFor(context);
- if (share == null) {
- throw new GLException("context is unknown: "+context);
- }
- return share.getDestroyedShares();
- } */
-
- public static synchronized GLContext getShareContext(GLContext contextToCreate) {
- ShareSet share = entryFor(contextToCreate);
- if (share == null) {
- return null;
- }
- return share.getCreatedShare(contextToCreate);
+ /** Returns a new array-list of destroyed GLContext shared with the given GLContext. */
+ public static synchronized ArrayList getDestroyedShares(final GLContext context) {
+ final ArrayList otherShares = new ArrayList();
+ final Set destroyedShares = getDestroyedSharesImpl(context);
+ if( null != destroyedShares ) {
+ for (final Iterator iter = destroyedShares.iterator(); iter.hasNext(); ) {
+ final GLContext ctx = iter.next();
+ if (ctx != context) {
+ otherShares.add(ctx);
+ }
+ }
+ }
+ return otherShares;
}
- public static synchronized boolean contextCreated(GLContext context) {
- ShareSet share = entryFor(context);
+ /** Mark the given GLContext as being created. */
+ public static synchronized boolean contextCreated(final GLContext context) {
+ final ShareSet share = entryFor(context);
if (share != null) {
share.contextCreated(context);
return true;
@@ -227,8 +252,9 @@ public class GLContextShareSet {
return false;
}
- public static synchronized boolean contextDestroyed(GLContext context) {
- ShareSet share = entryFor(context);
+ /** Mark the given GLContext as being destroyed. */
+ public static synchronized boolean contextDestroyed(final GLContext context) {
+ final ShareSet share = entryFor(context);
if (share != null) {
share.contextDestroyed(context);
return true;
@@ -245,9 +271,9 @@ public class GLContextShareSet {
currently only needed in a fairly esoteric case, when the
Java2D/JOGL bridge is active, but the GLBufferSizeTracker
mechanism is now always required.) */
- public static void synchronizeBufferObjectSharing(GLContext olderContextOrNull, GLContext newContext) {
- GLContextImpl older = (GLContextImpl) olderContextOrNull;
- GLContextImpl newer = (GLContextImpl) newContext;
+ public static void synchronizeBufferObjectSharing(final GLContext olderContextOrNull, final GLContext newContext) {
+ final GLContextImpl older = (GLContextImpl) olderContextOrNull;
+ final GLContextImpl newer = (GLContextImpl) newContext;
GLBufferSizeTracker tracker = null;
if (older != null) {
tracker = older.getBufferSizeTracker();
@@ -264,20 +290,20 @@ public class GLContextShareSet {
// Internals only below this point
- private static ShareSet entryFor(GLContext context) {
- return (ShareSet) shareMap.get(context);
+ private static ShareSet entryFor(final GLContext context) {
+ return shareMap.get(context);
}
- private static void addEntry(GLContext context, ShareSet share) {
+ private static void addEntry(final GLContext context, final ShareSet share) {
if (shareMap.get(context) == null) {
shareMap.put(context, share);
}
}
- private static ShareSet removeEntry(GLContext context) {
- return (ShareSet) shareMap.remove(context);
+ private static ShareSet removeEntry(final GLContext context) {
+ return shareMap.remove(context);
}
- protected static String toHexString(long hex) {
+ private static String toHexString(long hex) {
return "0x" + Long.toHexString(hex);
}
}
diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java
index 1e4cb38fa..ecb9f7dd1 100644
--- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java
@@ -312,6 +312,19 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
return new GLOffscreenAutoDrawableImpl( drawable, context, null, null);
}
+ @Override
+ public final GLOffscreenAutoDrawable createOffscreenAutoDrawable(AbstractGraphicsDevice deviceReq,
+ GLCapabilitiesImmutable capsRequested,
+ GLCapabilitiesChooser chooser,
+ int width, int height) {
+ final GLDrawable drawable = createOffscreenDrawable( deviceReq, capsRequested, chooser, width, height );
+ drawable.setRealized(true);
+ if(drawable instanceof GLFBODrawableImpl) {
+ return new GLOffscreenAutoDrawableImpl.FBOImpl( (GLFBODrawableImpl)drawable, null, null, null );
+ }
+ return new GLOffscreenAutoDrawableImpl( drawable, null, null, null);
+ }
+
@Override
public final GLDrawable createOffscreenDrawable(AbstractGraphicsDevice deviceReq,
GLCapabilitiesImmutable capsRequested,
diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java
index 4ce6a7121..cf5d7a206 100644
--- a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java
+++ b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java
@@ -82,6 +82,10 @@ public class GLDrawableHelper {
private GLAnimatorControl animatorCtrl;
private static Runnable nop = new Runnable() { @Override public void run() {} };
+ private GLContext sharedContext;
+ private GLAutoDrawable sharedAutoDrawable;
+
+
public GLDrawableHelper() {
reset();
}
@@ -98,6 +102,60 @@ public class GLDrawableHelper {
glRunnables.clear();
}
animatorCtrl = null;
+ sharedContext = null;
+ sharedAutoDrawable = null;
+ }
+
+ public final void setSharedContext(GLContext thisContext, GLContext sharedContext) throws IllegalStateException {
+ if( null == sharedContext ) {
+ throw new IllegalStateException("Null shared GLContext");
+ }
+ if( thisContext == sharedContext ) {
+ throw new IllegalStateException("Shared GLContext same as local");
+ }
+ if( null != this.sharedContext ) {
+ throw new IllegalStateException("Shared GLContext already set");
+ }
+ if( null != this.sharedAutoDrawable ) {
+ throw new IllegalStateException("Shared GLAutoDrawable already set");
+ }
+ this.sharedContext = sharedContext;
+ }
+
+ public final void setSharedAutoDrawable(GLAutoDrawable thisAutoDrawable, GLAutoDrawable sharedAutoDrawable) throws IllegalStateException {
+ if( null == sharedAutoDrawable ) {
+ throw new IllegalStateException("Null shared GLAutoDrawable");
+ }
+ if( thisAutoDrawable == sharedAutoDrawable ) {
+ throw new IllegalStateException("Shared GLAutoDrawable same as this");
+ }
+ if( null != this.sharedContext ) {
+ throw new IllegalStateException("Shared GLContext already set");
+ }
+ if( null != this.sharedAutoDrawable ) {
+ throw new IllegalStateException("Shared GLAutoDrawable already set");
+ }
+ this.sharedAutoDrawable = sharedAutoDrawable;
+ }
+
+ /**
+ * @param shared returns the shared GLContext, based on set shared GLAutoDrawable
+ * or GLContext. Maybe null if none is set.
+ * @return true if initialization is pending due to a set shared GLAutoDrawable or GLContext
+ * which is not ready yet. Otherwise false.
+ */
+ public boolean isSharedGLContextPending(GLContext[] shared) {
+ final GLContext shareWith;
+ final boolean pending;
+ if ( null != sharedAutoDrawable ) {
+ shareWith = sharedAutoDrawable.getContext();
+ pending = null == shareWith || !shareWith.isCreated();
+ } else {
+ shareWith = sharedContext;
+ pending = null != shareWith && !shareWith.isCreated();
+ }
+ shared[0] = shareWith;
+ return pending;
}
@Override
@@ -612,7 +670,7 @@ public class GLDrawableHelper {
public final void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
synchronized(listenersLock) {
for (int i=0; i < listeners.size(); i++) {
- reshape((GLEventListener) listeners.get(i), drawable, x, y, width, height, 0==i /* setViewport */, true /* checkInit */);
+ reshape(listeners.get(i), drawable, x, y, width, height, 0==i /* setViewport */, true /* checkInit */);
}
}
}
diff --git a/src/jogl/classes/jogamp/opengl/GLOffscreenAutoDrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLOffscreenAutoDrawableImpl.java
index f175acf28..345f08e4c 100644
--- a/src/jogl/classes/jogamp/opengl/GLOffscreenAutoDrawableImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLOffscreenAutoDrawableImpl.java
@@ -48,7 +48,7 @@ public class GLOffscreenAutoDrawableImpl extends GLAutoDrawableDelegate implemen
* @param context a valid {@link GLContext},
* may not have been made current (created) yet,
* may not be associated w/ drawable yet,
- * may be null
for lazy initialization
+ * may be null
for lazy initialization at 1st {@link #display()}.
* @param upstreamWidget optional UI element holding this instance, see {@link #getUpstreamWidget()}.
* @param lock optional upstream lock, may be null
*/
diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
index 1f5c26f27..70157fe4b 100644
--- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
+++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
@@ -105,7 +105,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
private AWTAdapter awtMouseAdapter = null;
private AWTAdapter awtKeyAdapter = null;
- private AWTWindowClosingProtocol awtWindowClosingProtocol =
+ private final AWTWindowClosingProtocol awtWindowClosingProtocol =
new AWTWindowClosingProtocol(this, new Runnable() {
@Override
public void run() {
@@ -204,7 +204,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
return false; // NEWT shall proceed requesting the native focus
}
}
- private FocusAction focusAction = new FocusAction();
+ private final FocusAction focusAction = new FocusAction();
WindowListener clearAWTMenusOnNewtFocus = new WindowAdapter() {
@Override
@@ -559,8 +559,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile());
printGLAD = factory.createOffscreenAutoDrawable(null, caps, null,
printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE,
- printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE,
- null);
+ printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE);
GLDrawableUtil.swapGLContextAndAllGLEventListener(glad, printGLAD);
printDrawable = printGLAD.getDelegatedDrawable();
}
diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
index 8c1110ed3..4f259fe9a 100644
--- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
+++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
@@ -499,21 +499,24 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind
if( ( null != context ) ) {
throw new InternalError("GLWindow.LifecycleHook.setVisiblePost: "+WindowImpl.getThreadName()+" - Null drawable, but valid context - "+GLWindow.this);
}
- final NativeSurface ns;
- {
- final NativeSurface wrapped_ns = window.getWrappedSurface();
- ns = null != wrapped_ns ? wrapped_ns : window;
- }
- final GLCapabilitiesImmutable glCaps = (GLCapabilitiesImmutable) ns.getGraphicsConfiguration().getChosenCapabilities();
- if(null==factory) {
- factory = GLDrawableFactory.getFactory(glCaps.getGLProfile());
- }
- drawable = (GLDrawableImpl) factory.createGLDrawable(ns);
- drawable.setRealized(true);
+ final GLContext[] shareWith = { null };
+ if( !helper.isSharedGLContextPending(shareWith) ) {
+ final NativeSurface ns;
+ {
+ final NativeSurface wrapped_ns = window.getWrappedSurface();
+ ns = null != wrapped_ns ? wrapped_ns : window;
+ }
+ final GLCapabilitiesImmutable glCaps = (GLCapabilitiesImmutable) ns.getGraphicsConfiguration().getChosenCapabilities();
+ if(null==factory) {
+ factory = GLDrawableFactory.getFactory(glCaps.getGLProfile());
+ }
+ drawable = (GLDrawableImpl) factory.createGLDrawable(ns);
+ drawable.setRealized(true);
- if( !GLWindow.this.pushGLEventListenerState() ) {
- context = (GLContextImpl) drawable.createContext(sharedContext);
- context.setContextCreationFlags(additionalCtxCreationFlags);
+ if( !GLWindow.this.restoreGLEventListenerState() ) {
+ context = (GLContextImpl) drawable.createContext(shareWith[0]);
+ context.setContextCreationFlags(additionalCtxCreationFlags);
+ }
}
}
if(Window.DEBUG_IMPLEMENTATION) {
@@ -573,25 +576,11 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind
// OpenGL-related methods and state
//
- private GLContext sharedContext = null;
-
@Override
protected final RecursiveLock getLock() {
return window.getLock();
}
- /**
- * Specifies an {@link javax.media.opengl.GLContext OpenGL context} to share with.
- * At native creation, {@link #setVisible(boolean) setVisible(true)},
- * a {@link javax.media.opengl.GLDrawable drawable} and {@link javax.media.opengl.GLContext context} is created besides the native Window itself,
- * hence you shall set the shared context before.
- *
- * @param sharedContext The OpenGL context shared by this GLWindow's one
- */
- public void setSharedContext(GLContext sharedContext) {
- this.sharedContext = sharedContext;
- }
-
@Override
public void display() {
if( !isNativeValid() || !isVisible() ) { return; }
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableDeadlockAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableDeadlockAWT.java
index 2df14d151..1548c08b5 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableDeadlockAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableDeadlockAWT.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,7 +20,7 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
@@ -61,12 +61,8 @@ public class TestFBOAutoDrawableDeadlockAWT extends UITestCase {
}
protected void runTestGL( GLCapabilities caps ) throws InterruptedException, InvocationTargetException {
- final GLOffscreenAutoDrawable fbod = GLDrawableFactory.getFactory(caps.getGLProfile()).createOffscreenAutoDrawable(
- null,
- caps, new DefaultGLCapabilitiesChooser(),
- 512, 512,
- null
- );
+ final GLOffscreenAutoDrawable fbod = GLDrawableFactory.getFactory(caps.getGLProfile()).createOffscreenAutoDrawable(
+ null, caps, new DefaultGLCapabilitiesChooser(), 512, 512);
final boolean[] done = {false};
final Runnable pbufferCreationAction = new Runnable() {
@@ -77,30 +73,30 @@ public class TestFBOAutoDrawableDeadlockAWT extends UITestCase {
System.err.println("AA.X");
}
};
-
+
EventQueue.invokeAndWait(new Runnable() {
public void run() {
Assert.assertTrue(EventQueue.isDispatchThread());
JAWTUtil.lockToolkit();
try {
- final RunnableTask rTask = new RunnableTask(pbufferCreationAction, new Object(), false, null);
+ final RunnableTask rTask = new RunnableTask(pbufferCreationAction, new Object(), false, null);
System.err.println("BB.0: "+rTask.getSyncObject());
synchronized (rTask.getSyncObject()) {
System.err.println("BB.1: "+rTask.getSyncObject());
- new Thread(rTask, Thread.currentThread().getName()+"-Pbuffer_Creation").start();
+ new Thread(rTask, Thread.currentThread().getName()+"-Pbuffer_Creation").start();
try {
System.err.println("BB.2");
rTask.getSyncObject().wait();
System.err.println("BB.3");
} catch (InterruptedException e) {
throw new RuntimeException(e);
- }
+ }
System.err.println("BB.X");
}
} finally {
JAWTUtil.unlockToolkit();
}
- }
+ }
});
Assert.assertTrue(done[0]);
fbod.destroy();
@@ -128,4 +124,4 @@ public class TestFBOAutoDrawableDeadlockAWT extends UITestCase {
}
org.junit.runner.JUnitCore.main( TestFBOAutoDrawableDeadlockAWT.class.getName() );
}
-}
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableFactoryNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableFactoryNEWT.java
index 9151a88a5..cc06136d6 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableFactoryNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableFactoryNEWT.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,12 +20,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.opengl.test.junit.jogl.acore;
import java.io.IOException;
@@ -52,53 +52,53 @@ import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
import com.jogamp.opengl.test.junit.util.UITestCase;
/**
- * Toolkit agnostic {@link GLOffscreenAutoDrawable.FBO} tests using the
- * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}.
+ * Toolkit agnostic {@link GLOffscreenAutoDrawable.FBO} tests using the
+ * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}.
*
- * The created {@link GLOffscreenAutoDrawable.FBO} is being used to run the {@link GLEventListener}.
+ * The created {@link GLOffscreenAutoDrawable.FBO} is being used to run the {@link GLEventListener}.
*
*
* Extensive FBO reconfiguration (size and sample buffer count) and validation are performed.
- *
+ *
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestFBOAutoDrawableFactoryNEWT extends UITestCase {
-
+
static final int widthStep = 800/4;
static final int heightStep = 600/4;
volatile int szStep = 2;
-
+
interface MyGLEventListener extends GLEventListener {
void setMakeSnapshot();
}
-
+
@Test
- public void testGL2ES2_Demo1_SingleBuffer_Normal() throws InterruptedException {
+ public void testGL2ES2_Demo1_SingleBuffer_Normal() throws InterruptedException {
final GLProfile glp = GLProfile.getGL2ES2();
final GLCapabilities caps = new GLCapabilities(glp);
caps.setDoubleBuffered(false);
testGLFBODrawableImpl(caps, new GearsES2(0));
}
-
+
@Test
- public void testGL2ES2_Demo1_DoubleBuffer_Normal() throws InterruptedException {
+ public void testGL2ES2_Demo1_DoubleBuffer_Normal() throws InterruptedException {
final GLProfile glp = GLProfile.getGL2ES2();
final GLCapabilities caps = new GLCapabilities(glp);
caps.setDoubleBuffered(true); // default
testGLFBODrawableImpl(caps, new GearsES2(0));
}
-
+
@Test
- public void testGL2ES2_Demo2MSAA4() throws InterruptedException {
+ public void testGL2ES2_Demo2MSAA4() throws InterruptedException {
final GLProfile glp = GLProfile.getGL2ES2();
final GLCapabilities caps = new GLCapabilities(glp);
caps.setSampleBuffers(true);
caps.setNumSamples(4);
testGLFBODrawableImpl(caps, new MultisampleDemoES2(true));
}
-
+
@Test
- public void testGL2ES2_FBODemoMSAA4() throws InterruptedException {
+ public void testGL2ES2_FBODemoMSAA4() throws InterruptedException {
final GLProfile glp = GLProfile.getGL2ES2();
final FBOMix2DemosES2 demo = new FBOMix2DemosES2(0);
demo.setDoRotation(false);
@@ -107,9 +107,9 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase {
caps.setNumSamples(4);
testGLFBODrawableImpl(caps, demo);
}
-
+
@Test
- public void testEGLES2_Demo0Normal() throws InterruptedException {
+ public void testEGLES2_Demo0Normal() throws InterruptedException {
if( GLProfile.isAvailable(GLProfile.GLES2) ) {
final GLProfile glp = GLProfile.get(GLProfile.GLES2);
final GLCapabilities caps = new GLCapabilities(glp);
@@ -118,9 +118,9 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase {
System.err.println("EGL ES2 n/a");
}
}
-
+
@Test
- public void testEGLES2_Demo0MSAA4() throws InterruptedException {
+ public void testEGLES2_Demo0MSAA4() throws InterruptedException {
if( GLProfile.isAvailable(GLProfile.GLES2) ) {
final GLProfile glp = GLProfile.get(GLProfile.GLES2);
final GLCapabilities caps = new GLCapabilities(glp);
@@ -136,71 +136,71 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase {
caps.setFBO(true);
final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile());
final GLOffscreenAutoDrawable.FBO glad = (GLOffscreenAutoDrawable.FBO)
- factory.createOffscreenAutoDrawable(null, caps, null, widthStep*szStep, heightStep*szStep, null);
+ factory.createOffscreenAutoDrawable(null, caps, null, widthStep*szStep, heightStep*szStep);
Assert.assertNotNull(glad);
-
+
System.out.println("Realized GLAD: "+glad);
System.out.println("Realized GLAD: "+glad.getChosenGLCapabilities());
Assert.assertTrue("FBO drawable is initialized before ctx creation", !glad.isInitialized());
-
+
glad.display(); // initial display incl. init!
{
final GLContext context = glad.getContext();
Assert.assertNotNull(context);
Assert.assertTrue(context.isCreated());
}
- Assert.assertTrue("FBO drawable is not initialized after ctx creation", glad.isInitialized());
-
+ Assert.assertTrue("FBO drawable is not initialized after ctx creation", glad.isInitialized());
+
//
// FBO incl. MSAA is fully initialized now
//
-
+
final GLCapabilitiesImmutable chosenCaps = glad.getChosenGLCapabilities();
System.out.println("Init GLAD: "+glad);
System.out.println("Init GLAD: "+chosenCaps);
-
+
final FBObject fboFront = glad.getFBObject(GL.GL_FRONT);
final FBObject fboBack = glad.getFBObject(GL.GL_BACK);
-
+
System.out.println("Init front FBO: "+fboFront);
System.out.println("Init back FBO: "+fboBack);
-
+
Assert.assertTrue("FBO drawable is not initialized before ctx creation", glad.isInitialized());
Assert.assertTrue("FBO Front is not initialized before ctx creation", fboFront.isInitialized());
Assert.assertTrue("FBO Back is not initialized before ctx creation", fboBack.isInitialized());
-
+
if( chosenCaps.getDoubleBuffered() ) {
Assert.assertTrue("FBO are equal: "+fboFront+" == "+fboBack, !fboFront.equals(fboBack));
Assert.assertNotSame(fboFront, fboBack);
} else {
Assert.assertTrue("FBO are not equal: "+fboFront+" != "+fboBack, fboFront.equals(fboBack));
- Assert.assertSame(fboFront, fboBack);
+ Assert.assertSame(fboFront, fboBack);
}
-
+
final FBObject.TextureAttachment texAttachA, texAttachB;
-
+
texAttachA = glad.getTextureBuffer(GL.GL_FRONT);
if(0==glad.getNumSamples()) {
texAttachB = glad.getTextureBuffer(GL.GL_BACK);
} else {
texAttachB = null;
}
-
+
final FBObject.Colorbuffer colorA, colorB;
final FBObject.RenderAttachment depthA, depthB;
-
+
colorA = fboFront.getColorbuffer(0);
Assert.assertNotNull(colorA);
colorB = fboBack.getColorbuffer(0);
Assert.assertNotNull(colorB);
-
+
depthA = fboFront.getDepthAttachment();
Assert.assertNotNull(depthA);
depthB = fboBack.getDepthAttachment();
Assert.assertNotNull(depthB);
glad.display(); // SWAP_ODD
-
+
if( chosenCaps.getDoubleBuffered() ) {
// double buffer or MSAA
Assert.assertTrue("Color attachments are equal: "+colorB+" == "+colorA, !colorB.equals(colorA));
@@ -214,16 +214,16 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase {
Assert.assertEquals(depthA, depthB);
Assert.assertSame(depthA, depthB);
}
-
+
Assert.assertEquals(texAttachA, colorA);
Assert.assertSame(texAttachA, colorA);
if(0==glad.getNumSamples()) {
Assert.assertEquals(texAttachB, colorB);
- Assert.assertSame(texAttachB, colorB);
+ Assert.assertSame(texAttachB, colorB);
}
if( chosenCaps.getNumSamples() > 0 ) {
- // MSAA
+ // MSAA
FBObject _fboFront = glad.getFBObject(GL.GL_FRONT);
FBObject _fboBack = glad.getFBObject(GL.GL_BACK);
Assert.assertTrue("FBO are not equal: "+fboFront+" != "+_fboFront, fboFront.equals(_fboFront));
@@ -251,22 +251,22 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase {
Assert.assertTrue("FBO are not equal: "+fboFront+" != "+_fboBack, fboFront.equals(_fboBack));
Assert.assertSame(fboFront, _fboBack);
}
-
+
glad.addGLEventListener(demo);
-
+
final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener();
glad.addGLEventListener(snapshotGLEventListener);
-
+
glad.display(); // - SWAP_EVEN
// 1 - szStep = 2
snapshotGLEventListener.setMakeSnapshot();
glad.display(); // - SWAP_ODD
-
+
// 2, 3 (resize + display)
szStep = 1;
glad.setSize(widthStep*szStep, heightStep*szStep); // SWAP_EVEN
- Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
+ Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep));
snapshotGLEventListener.setMakeSnapshot();
glad.display(); // - SWAP_ODD
@@ -283,34 +283,34 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase {
Assert.assertSame(fboFront, _fboFront);
Assert.assertEquals(fboBack, _fboBack);
Assert.assertSame(fboBack, _fboBack);
-
+
FBObject.Colorbuffer _color = _fboFront.getColorbuffer(0);
Assert.assertNotNull(_color);
Assert.assertEquals(colorA, _color);
Assert.assertSame(colorA, _color);
-
+
FBObject.RenderAttachment _depth = _fboFront.getDepthAttachment();
System.err.println("Resize1.oldDepth "+depthA);
System.err.println("Resize1.newDepth "+_depth);
Assert.assertNotNull(_depth);
-
+
Assert.assertEquals(depthA, _depth);
Assert.assertSame(depthA, _depth);
_depth = _fboBack.getDepthAttachment();
Assert.assertNotNull(_depth);
Assert.assertEquals(depthB, _depth);
Assert.assertSame(depthB, _depth);
-
+
_color = _fboFront.getColorbuffer(colorA);
Assert.assertNotNull(_color);
Assert.assertEquals(colorA, _color);
Assert.assertSame(colorA, _color);
}
-
+
// 4, 5 (resize + display)
szStep = 4;
glad.setSize(widthStep*szStep, heightStep*szStep); // SWAP_ODD
- Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
+ Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep));
snapshotGLEventListener.setMakeSnapshot();
glad.display(); // - SWAP_EVEN
@@ -330,47 +330,47 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase {
} else {
// single or MSAA
Assert.assertEquals(fboFront, _fboFront);
- Assert.assertEquals(fboBack, _fboBack);
+ Assert.assertEquals(fboBack, _fboBack);
}
-
+
FBObject.Colorbuffer _color = fboBack.getColorbuffer(0);
Assert.assertNotNull(_color);
Assert.assertEquals(colorB, _color);
Assert.assertSame(colorB, _color);
-
+
FBObject.RenderAttachment _depth = fboBack.getDepthAttachment();
- Assert.assertNotNull(_depth); // MSAA back w/ depth
+ Assert.assertNotNull(_depth); // MSAA back w/ depth
Assert.assertEquals(depthB, _depth);
Assert.assertSame(depthB, _depth);
-
+
_depth = fboFront.getDepthAttachment();
Assert.assertNotNull(_depth);
Assert.assertEquals(depthA, _depth);
Assert.assertSame(depthA, _depth);
-
+
_color = fboBack.getColorbuffer(colorB);
Assert.assertNotNull(_color);
Assert.assertEquals(colorB, _color);
Assert.assertSame(colorB, _color);
}
-
+
// 6 + 7 (samples + display)
glad.setNumSamples(glad.getGL(), chosenCaps.getNumSamples() > 0 ? 0 : 4); // triggers repaint
snapshotGLEventListener.setMakeSnapshot();
glad.display(); // actual screenshot
-
+
// 8, 9 (resize + samples + display)
szStep = 3;
glad.setSize(widthStep*szStep, heightStep*szStep);
- Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
+ Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep));
snapshotGLEventListener.setMakeSnapshot();
glad.display();
-
+
glad.destroy();
System.out.println("Fin: "+glad);
}
-
+
public static void main(String args[]) throws IOException {
org.junit.runner.JUnitCore.main(TestFBOAutoDrawableFactoryNEWT.class.getName());
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java
index b3e5e95b0..51dd9df37 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,12 +20,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.opengl.test.junit.jogl.acore;
import java.io.BufferedReader;
@@ -68,10 +68,10 @@ import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
/**
- * Toolkit agnostic {@link GLOffscreenAutoDrawable.FBO} tests using the
- * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}.
+ * Toolkit agnostic {@link GLOffscreenAutoDrawable.FBO} tests using the
+ * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}.
*
- * The created {@link GLOffscreenAutoDrawable.FBO} is being used to run the {@link GLEventListener}.
+ * The created {@link GLOffscreenAutoDrawable.FBO} is being used to run the {@link GLEventListener}.
*
*
* This test simulates shared off-thread GL context / texture usage,
@@ -81,7 +81,7 @@ import org.junit.runners.MethodSorters;
*
* - 2 {@link GLOffscreenAutoDrawable.FBO} double buffered
*
- * - each with their own {@link GLContext}, which is shares the {@link GLWindow} one (see below)
+ * - each with their own {@link GLContext}, which is shares the {@link GLWindow} one (see below)
* - both run within one {@link FPSAnimator} @ 30fps
* - produce a texture
* - notify the onscreen renderer about new textureID (swapping double buffer)
@@ -91,18 +91,18 @@ import org.junit.runners.MethodSorters;
* - shares it's {@link GLContext} w/ above FBOs
* - running within one {@link Animator} at v-sync
* - uses the shared FBO textures and blends them onscreen
- *
- *
- *
+ *
+ *
+ *
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestFBOOffThreadSharedContextMix2DemosES2NEWT extends UITestCase {
+public class TestFBOOffThreadSharedContextMix2DemosES2NEWT extends UITestCase {
static long duration = 500; // ms
static int swapInterval = 1;
static boolean showFPS = false;
static boolean forceES2 = false;
static boolean mainRun = false;
-
+
@AfterClass
public static void releaseClass() {
}
@@ -110,37 +110,38 @@ public class TestFBOOffThreadSharedContextMix2DemosES2NEWT extends UITestCase {
protected void runTestGL(GLCapabilitiesImmutable caps) throws InterruptedException {
final GLReadBufferUtil screenshot = new GLReadBufferUtil(false, false);
System.err.println("requested: vsync "+swapInterval+", "+caps);
-
+
final GLWindow glWindow = GLWindow.create(caps);
Assert.assertNotNull(glWindow);
glWindow.setTitle("Gears NEWT Test (translucent "+!caps.isBackgroundOpaque()+"), swapInterval "+swapInterval);
if(mainRun) {
- glWindow.setSize(512, 512);
+ glWindow.setSize(512, 512);
} else {
glWindow.setSize(256, 256);
}
// eager initialization of context
glWindow.setVisible(true);
- glWindow.display();
+ glWindow.display();
final int fbod1_texUnit = 0;
final int fbod2_texUnit = 1;
-
+
final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile());
GLCapabilities fbodCaps = (GLCapabilities) caps.cloneMutable();
// fbodCaps.setDoubleBuffered(false);
-
+
final Mix2TexturesES2 mixerDemo = new Mix2TexturesES2(1, fbod1_texUnit, fbod2_texUnit);
- // FBOD1
+ // FBOD1
final GLOffscreenAutoDrawable.FBO fbod1 = (GLOffscreenAutoDrawable.FBO)
- factory.createOffscreenAutoDrawable(null, fbodCaps, null, glWindow.getWidth(), glWindow.getHeight(), glWindow.getContext());
+ factory.createOffscreenAutoDrawable(null, fbodCaps, null, glWindow.getWidth(), glWindow.getHeight());
+ fbod1.setSharedAutoDrawable(glWindow);
fbod1.setUpstreamWidget(glWindow); // connect the real GLWindow (mouse/key) to offscreen!
fbod1.setTextureUnit(fbod1_texUnit);
{
GearsES2 demo0 = new GearsES2(-1);
fbod1.addGLEventListener(demo0);
- fbod1.addGLEventListener(new GLFinishOnDisplay());
+ fbod1.addGLEventListener(new GLFinishOnDisplay());
demo0.setIgnoreFocus(true);
}
fbod1.getNativeSurface().addSurfaceUpdatedListener(new SurfaceUpdatedListener() {
@@ -151,13 +152,14 @@ public class TestFBOOffThreadSharedContextMix2DemosES2NEWT extends UITestCase {
fbod1.display(); // init
System.err.println("FBOD1 "+fbod1);
Assert.assertTrue(fbod1.isInitialized());
-
+
// FBOD2
final GLOffscreenAutoDrawable.FBO fbod2 = (GLOffscreenAutoDrawable.FBO)
- factory.createOffscreenAutoDrawable(null, fbodCaps, null, glWindow.getWidth(), glWindow.getHeight(), glWindow.getContext());
+ factory.createOffscreenAutoDrawable(null, fbodCaps, null, glWindow.getWidth(), glWindow.getHeight());
+ fbod2.setSharedAutoDrawable(glWindow);
fbod2.setTextureUnit(fbod2_texUnit);
fbod2.addGLEventListener(new RedSquareES2(-1));
- fbod2.addGLEventListener(new GLFinishOnDisplay());
+ fbod2.addGLEventListener(new GLFinishOnDisplay());
fbod2.getNativeSurface().addSurfaceUpdatedListener(new SurfaceUpdatedListener() {
@Override
public void surfaceUpdated(Object updater, NativeSurface ns, long when) {
@@ -170,7 +172,7 @@ public class TestFBOOffThreadSharedContextMix2DemosES2NEWT extends UITestCase {
// preinit texIDs
mixerDemo.setTexID0(fbod1.getTextureBuffer(GL.GL_FRONT).getName());
mixerDemo.setTexID1(fbod2.getTextureBuffer(GL.GL_FRONT).getName());
-
+
glWindow.addGLEventListener(mixerDemo);
glWindow.addGLEventListener(new GLEventListener() {
int i=0, c=0;
@@ -178,39 +180,39 @@ public class TestFBOOffThreadSharedContextMix2DemosES2NEWT extends UITestCase {
public void dispose(GLAutoDrawable drawable) {}
public void display(GLAutoDrawable drawable) {
if(mainRun) return;
-
+
final int dw = drawable.getWidth();
final int dh = drawable.getHeight();
c++;
-
+
if(dw<800) {
System.err.println("XXX: "+dw+"x"+dh+", c "+c);
if(8 == c) {
- snapshot(i++, "msaa"+fbod1.getNumSamples(), drawable.getGL(), screenshot, TextureIO.PNG, null);
+ snapshot(i++, "msaa"+fbod1.getNumSamples(), drawable.getGL(), screenshot, TextureIO.PNG, null);
}
if(9 == c) {
c=0;
- new Thread() {
+ new Thread() {
@Override
public void run() {
glWindow.setSize(dw+256, dh+256);
- } }.start();
+ } }.start();
}
}
}
- public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
fbod1.setSize(width, height);
fbod2.setSize(width, height);
}
});
-
+
final FPSAnimator animator0 = new FPSAnimator(30);
animator0.add(fbod1);
animator0.add(fbod2);
-
+
final Animator animator1 = new Animator();
animator1.add(glWindow);
-
+
QuitAdapter quitAdapter = new QuitAdapter();
//glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter));
@@ -224,22 +226,22 @@ public class TestFBOOffThreadSharedContextMix2DemosES2NEWT extends UITestCase {
}
public void windowMoved(WindowEvent e) {
System.err.println("window moved: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight());
- }
+ }
});
-
+
animator0.start();
animator1.start();
// glWindow.setSkipContextReleaseThread(animator.getThread());
glWindow.setVisible(true);
-
+
System.err.println("NW chosen: "+glWindow.getDelegatedWindow().getChosenCapabilities());
System.err.println("GL chosen: "+glWindow.getChosenCapabilities());
System.err.println("window pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets());
-
+
animator0.setUpdateFPSFrames(30, showFPS ? System.err : null);
animator1.setUpdateFPSFrames(60, showFPS ? System.err : null);
-
+
while(!quitAdapter.shouldQuit() && animator1.isAnimating() && animator1.getTotalFPSDuration()
- * The created {@link GLOffscreenAutoDrawable.FBO} is being used to run the {@link GLEventListener}.
+ * The created {@link GLOffscreenAutoDrawable.FBO} is being used to run the {@link GLEventListener}.
*
*
* This test simulates shared on-thread GL context / texture usage,
@@ -79,7 +79,7 @@ import org.junit.runners.MethodSorters;
*
* - 1 {@link GLOffscreenAutoDrawable.FBO} double buffered
*
- *
+ *
* - running within common {@link Animator} @ 60fps
* - produce a texture
* - notify the onscreen renderer about new textureID (swapping double buffer)
@@ -89,18 +89,18 @@ import org.junit.runners.MethodSorters;
* - shares it's {@link GLContext} w/ above FBO
* - running within common {@link Animator} @ 60fps
* - uses the shared FBO texture and draws it onscreen
- *
- *
- *
+ *
+ *
+ *
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestFBOOnThreadSharedContext1DemoES2NEWT extends UITestCase {
+public class TestFBOOnThreadSharedContext1DemoES2NEWT extends UITestCase {
static long duration = 500; // ms
static int swapInterval = 1;
static boolean showFPS = false;
static boolean forceES2 = false;
static boolean mainRun = false;
-
+
@AfterClass
public static void releaseClass() {
}
@@ -108,30 +108,31 @@ public class TestFBOOnThreadSharedContext1DemoES2NEWT extends UITestCase {
protected void runTestGL(GLCapabilitiesImmutable caps) throws InterruptedException {
final GLReadBufferUtil screenshot = new GLReadBufferUtil(false, false);
System.err.println("requested: vsync "+swapInterval+", "+caps);
-
+
final GLWindow glWindow = GLWindow.create(caps);
Assert.assertNotNull(glWindow);
glWindow.setTitle("Gears NEWT Test (translucent "+!caps.isBackgroundOpaque()+"), swapInterval "+swapInterval);
if(mainRun) {
- glWindow.setSize(512, 512);
+ glWindow.setSize(512, 512);
} else {
glWindow.setSize(256, 256);
}
// eager initialization of context
glWindow.setVisible(true);
- glWindow.display();
+ glWindow.display();
final int fbod1_texUnit = 0;
-
+
final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile());
GLCapabilities fbodCaps = (GLCapabilities) caps.cloneMutable();
// fbodCaps.setDoubleBuffered(false);
-
+
final Mix2TexturesES2 mixerDemo = new Mix2TexturesES2(1, fbod1_texUnit, 0);
- // FBOD1
+ // FBOD1
final GLOffscreenAutoDrawable.FBO fbod1 = (GLOffscreenAutoDrawable.FBO)
- factory.createOffscreenAutoDrawable(null, fbodCaps, null, glWindow.getWidth(), glWindow.getHeight(), glWindow.getContext());
+ factory.createOffscreenAutoDrawable(null, fbodCaps, null, glWindow.getWidth(), glWindow.getHeight());
+ fbod1.setSharedAutoDrawable(glWindow);
fbod1.setUpstreamWidget(glWindow); // connect the real GLWindow (mouse/key) to offscreen!
fbod1.setTextureUnit(fbod1_texUnit);
{
@@ -148,10 +149,10 @@ public class TestFBOOnThreadSharedContext1DemoES2NEWT extends UITestCase {
fbod1.display(); // init
System.err.println("FBOD1 "+fbod1);
Assert.assertTrue(fbod1.isInitialized());
-
+
// preinit texIDs
mixerDemo.setTexID0(fbod1.getTextureBuffer(GL.GL_FRONT).getName());
-
+
glWindow.addWindowListener(new WindowAdapter() {
@Override
public void windowResized(WindowEvent e) {
@@ -165,33 +166,33 @@ public class TestFBOOnThreadSharedContext1DemoES2NEWT extends UITestCase {
public void dispose(GLAutoDrawable drawable) {}
public void display(GLAutoDrawable drawable) {
if(mainRun) return;
-
+
final int dw = drawable.getWidth();
final int dh = drawable.getHeight();
c++;
-
+
if(dw<800) {
System.err.println("XXX: "+dw+"x"+dh+", c "+c);
if(8 == c) {
- snapshot(i++, "msaa"+fbod1.getNumSamples(), drawable.getGL(), screenshot, TextureIO.PNG, null);
+ snapshot(i++, "msaa"+fbod1.getNumSamples(), drawable.getGL(), screenshot, TextureIO.PNG, null);
}
if(9 == c) {
c=0;
- new Thread() {
+ new Thread() {
@Override
public void run() {
glWindow.setSize(dw+256, dh+256);
- } }.start();
+ } }.start();
}
}
}
- public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { }
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { }
});
-
+
final Animator animator1 = new Animator();
animator1.add(fbod1);
animator1.add(glWindow);
-
+
QuitAdapter quitAdapter = new QuitAdapter();
//glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter));
@@ -205,20 +206,20 @@ public class TestFBOOnThreadSharedContext1DemoES2NEWT extends UITestCase {
}
public void windowMoved(WindowEvent e) {
System.err.println("window moved: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight());
- }
+ }
});
-
+
animator1.start();
// glWindow.setSkipContextReleaseThread(animator.getThread());
glWindow.setVisible(true);
-
+
System.err.println("NW chosen: "+glWindow.getDelegatedWindow().getChosenCapabilities());
System.err.println("GL chosen: "+glWindow.getChosenCapabilities());
System.err.println("window pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets());
-
+
animator1.setUpdateFPSFrames(60, showFPS ? System.err : null);
-
+
while(!quitAdapter.shouldQuit() && animator1.isAnimating() && animator1.getTotalFPSDuration()
- * Creates a {@link GLDrawable} using the
+ * Creates a {@link GLDrawable} using the
* {@link GLDrawableFactory#createGLDrawable(javax.media.nativewindow.NativeSurface) factory model}.
* The {@link GLContext} is derived {@link GLDrawable#createContext(GLContext) from the drawable}.
*
*
* Finally a {@link GLAutoDrawableDelegate} is created with the just created {@link GLDrawable} and {@link GLContext}.
- * It is being used to run the {@link GLEventListener}.
- *
+ * It is being used to run the {@link GLEventListener}.
+ *
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestGLAutoDrawableDelegateNEWT extends UITestCase {
static long duration = 500; // ms
-
+
void doTest(GLCapabilitiesImmutable reqGLCaps, GLEventListener demo) throws InterruptedException {
final GLDrawableFactory factory = GLDrawableFactory.getFactory(reqGLCaps.getGLProfile());
-
+
//
// Create native windowing resources .. X11/Win/OSX
- //
+ //
final Window window = NewtFactory.createWindow(reqGLCaps);
Assert.assertNotNull(window);
window.setSize(640, 400);
@@ -85,24 +85,24 @@ public class TestGLAutoDrawableDelegateNEWT extends UITestCase {
Assert.assertTrue(AWTRobotUtil.waitForVisible(window, true));
Assert.assertTrue(AWTRobotUtil.waitForRealized(window, true));
System.out.println("Window: "+window.getClass().getName());
-
+
final GLDrawable drawable = factory.createGLDrawable(window);
Assert.assertNotNull(drawable);
drawable.setRealized(true);
-
- final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(drawable, drawable.createContext(null), window, false, null) {
+
+ final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(drawable, null, window, false, null) {
@Override
protected void destroyImplInLock() {
super.destroyImplInLock(); // destroys drawable/context
window.destroy(); // destroys the actual window, incl. the device
}
};
-
+
window.setWindowDestroyNotifyAction( new Runnable() {
public void run() {
glad.windowDestroyNotifyOp();
} } );
-
+
window.addWindowListener(new WindowAdapter() {
@Override
public void windowRepaint(WindowUpdateEvent e) {
@@ -116,13 +116,13 @@ public class TestGLAutoDrawableDelegateNEWT extends UITestCase {
});
glad.addGLEventListener(demo);
-
+
QuitAdapter quitAdapter = new QuitAdapter();
//glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter));
//glWindow.addWindowListener(new TraceWindowAdapter(quitAdapter));
window.addKeyListener(quitAdapter);
window.addWindowListener(quitAdapter);
-
+
Animator animator = new Animator();
animator.setUpdateFPSFrames(60, System.err);
animator.setModeBits(false, Animator.MODE_EXPECT_AWT_RENDERING_THREAD);
@@ -130,17 +130,17 @@ public class TestGLAutoDrawableDelegateNEWT extends UITestCase {
animator.start();
Assert.assertTrue(animator.isStarted());
Assert.assertTrue(animator.isAnimating());
-
+
while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()
- * The created {@link GLOffscreenAutoDrawable} is being used to run the {@link GLEventListener}.
- *
+ * The created {@link GLOffscreenAutoDrawable} is being used to run the {@link GLEventListener}.
+ *
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
@@ -71,7 +71,7 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
}
return new GLCapabilities(GLProfile.get(profile));
}
-
+
void doTest(GLCapabilitiesImmutable reqGLCaps, GLEventListener demo) throws InterruptedException {
System.out.println("Requested GL Caps: "+reqGLCaps);
final GLDrawableFactory factory = GLDrawableFactory.getFactory(reqGLCaps.getGLProfile());
@@ -79,15 +79,15 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
System.out.println("Expected GL Caps: "+expGLCaps);
//
- // Create native OpenGL resources .. XGL/WGL/CGL ..
+ // Create native OpenGL resources .. XGL/WGL/CGL ..
// equivalent to GLAutoDrawable methods: setVisible(true)
//
- final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, reqGLCaps, null, widthStep*szStep, heightStep*szStep, null);
-
+ final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, reqGLCaps, null, widthStep*szStep, heightStep*szStep);
+
Assert.assertNotNull(glad);
- System.out.println("Drawable Pre-GL(0): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName());
+ System.out.println("Drawable Pre-GL(0): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName());
Assert.assertTrue(glad.isRealized());
-
+
// Check caps of NativeWindow config w/o GL
final CapabilitiesImmutable chosenCaps = glad.getChosenGLCapabilities();
System.out.println("Drawable Caps Pre_GL : "+chosenCaps);
@@ -95,7 +95,7 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
Assert.assertTrue(chosenCaps.getGreenBits()>4);
Assert.assertTrue(chosenCaps.getBlueBits()>4);
Assert.assertTrue(chosenCaps.getRedBits()>4);
-
+
glad.display(); // force native context creation
// Check caps of GLDrawable after realization
@@ -113,45 +113,45 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
Assert.assertEquals(expGLCaps.isFBO(), chosenGLCaps.isFBO());
Assert.assertEquals(expGLCaps.isPBuffer(), chosenGLCaps.isPBuffer());
Assert.assertEquals(expGLCaps.isBitmap(), chosenGLCaps.isBitmap());
- /** Single/Double buffer cannot be checked since result may vary ..
+ /** Single/Double buffer cannot be checked since result may vary ..
if(chosenGLCaps.isOnscreen() || chosenGLCaps.isFBO()) {
// dbl buffer may be disabled w/ offscreen pbuffer and bitmap
Assert.assertEquals(expGLCaps.getDoubleBuffered(), chosenGLCaps.getDoubleBuffered());
- } */
+ } */
glad.addGLEventListener(demo);
-
+
final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener();
glad.addGLEventListener(snapshotGLEventListener);
-
+
glad.display(); // initial resize/display
-
+
// 1 - szStep = 2
- Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
+ Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep));
snapshotGLEventListener.setMakeSnapshot();
glad.display();
-
+
// 2, 3 (resize + display)
szStep = 1;
glad.setSize(widthStep*szStep, heightStep*szStep);
- Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
+ Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep));
snapshotGLEventListener.setMakeSnapshot();
glad.display();
-
+
// 4, 5 (resize + display)
szStep = 4;
glad.setSize(widthStep*szStep, heightStep*szStep);
- Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
+ Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep));
snapshotGLEventListener.setMakeSnapshot();
glad.display();
-
+
Thread.sleep(50);
-
+
glad.destroy();
- System.out.println("Fin Drawable: "+glad);
+ System.out.println("Fin Drawable: "+glad);
}
@Test
@@ -164,8 +164,8 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
if(null != f) {
System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString());
}
- }
-
+ }
+
@Test
public void testES2OffScreenAutoDblBuf() throws InterruptedException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
@@ -182,7 +182,7 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setFBO(true);
doTest(reqGLCaps, new GearsES2(1));
}
-
+
@Test
public void testES2OffScreenFBOSglBuf() throws InterruptedException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
@@ -191,8 +191,8 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setFBO(true);
reqGLCaps.setDoubleBuffered(false);
doTest(reqGLCaps, new GearsES2(1));
- }
-
+ }
+
@Test
public void testES2OffScreenFBODblBufStencil() throws InterruptedException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
@@ -202,7 +202,7 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setStencilBits(1);
doTest(reqGLCaps, new GearsES2(1));
}
-
+
@Test
public void testES2OffScreenFBODblBufMSAA() throws InterruptedException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
@@ -212,8 +212,8 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setSampleBuffers(true);
reqGLCaps.setNumSamples(4);
doTest(reqGLCaps, new GearsES2(1));
- }
-
+ }
+
@Test
public void testES2OffScreenFBODblBufStencilMSAA() throws InterruptedException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
@@ -224,8 +224,8 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setSampleBuffers(true);
reqGLCaps.setNumSamples(4);
doTest(reqGLCaps, new GearsES2(1));
- }
-
+ }
+
@Test
public void testES2OffScreenPbufferDblBuf() throws InterruptedException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
@@ -233,8 +233,8 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setOnscreen(false);
reqGLCaps.setPBuffer(true);
doTest(reqGLCaps, new GearsES2(1));
- }
-
+ }
+
@Test
public void testES2OffScreenPbufferSglBuf() throws InterruptedException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
@@ -244,7 +244,7 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setDoubleBuffered(false);
doTest(reqGLCaps, new GearsES2(1));
}
-
+
// Might be reduced to !stencil
@Test
public void testES2OffScreenPbufferDblBufStencil() throws InterruptedException {
@@ -255,7 +255,7 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setStencilBits(1);
doTest(reqGLCaps, new GearsES2(1));
}
-
+
// Might be reduced to !MSAA
@Test
public void testES2OffScreenPbufferDblBufMSAA() throws InterruptedException {
@@ -266,8 +266,8 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setSampleBuffers(true);
reqGLCaps.setNumSamples(4);
doTest(reqGLCaps, new GearsES2(1));
- }
-
+ }
+
// Might be reduced to !stencil && !MSAA
@Test
public void testES2OffScreenPbufferDblBufStencilMSAA() throws InterruptedException {
@@ -279,9 +279,9 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setSampleBuffers(true);
reqGLCaps.setNumSamples(4);
doTest(reqGLCaps, new GearsES2(1));
- }
+ }
- /** NOT Implemented:
+ /** NOT Implemented:
// Might be reduced to !double-buff
@Test
public void testES2OffScreenBitmapDblBuf() throws InterruptedException {
@@ -291,7 +291,7 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setBitmap(true);
doTest(reqGLCaps, new Gears(1));
}
-
+
@Test
public void testES2OffScreenBitmapSglBuf() throws InterruptedException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
@@ -301,7 +301,7 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setDoubleBuffered(false);
doTest(reqGLCaps, new Gears(1));
}
-
+
// Might be reduced to !stencil
@Test
public void testES2OffScreenBitmapDblBufStencil() throws InterruptedException {
@@ -312,7 +312,7 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setStencilBits(1);
doTest(reqGLCaps, new GearsES2(1));
}
-
+
// Might be reduced to !MSAA
@Test
public void testES2OffScreenBitmapDblBufMSAA() throws InterruptedException {
@@ -323,8 +323,8 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setSampleBuffers(true);
reqGLCaps.setNumSamples(4);
doTest(reqGLCaps, new GearsES2(1));
- }
-
+ }
+
// Might be reduced to !stencil && !MSAA
@Test
public void testES2OffScreenBitmapDblBufStencilMSAA() throws InterruptedException {
@@ -337,7 +337,7 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setNumSamples(4);
doTest(reqGLCaps, new GearsES2(1));
} */
-
+
public static void main(String args[]) throws IOException {
org.junit.runner.JUnitCore.main(TestGLAutoDrawableFactoryES2OffscrnCapsNEWT.class.getName());
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT.java
index 06dc7c83e..09e211332 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,12 +20,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.opengl.test.junit.jogl.acore;
import java.io.IOException;
@@ -52,11 +52,11 @@ import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
import com.jogamp.opengl.test.junit.util.UITestCase;
/**
- * Toolkit agnostic {@link GLOffscreenAutoDrawable} tests using the
- * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}.
+ * Toolkit agnostic {@link GLOffscreenAutoDrawable} tests using the
+ * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}.
*
- * The created {@link GLOffscreenAutoDrawable} is being used to run the {@link GLEventListener}.
- *
+ * The created {@link GLOffscreenAutoDrawable} is being used to run the {@link GLEventListener}.
+ *
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
@@ -71,7 +71,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
}
return new GLCapabilities(GLProfile.get(profile));
}
-
+
void doTest(GLCapabilitiesImmutable reqGLCaps, GLEventListener demo) throws InterruptedException {
System.out.println("Requested GL Caps: "+reqGLCaps);
final GLDrawableFactory factory = GLDrawableFactory.getFactory(reqGLCaps.getGLProfile());
@@ -79,15 +79,15 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
System.out.println("Expected GL Caps: "+expGLCaps);
//
- // Create native OpenGL resources .. XGL/WGL/CGL ..
+ // Create native OpenGL resources .. XGL/WGL/CGL ..
// equivalent to GLAutoDrawable methods: setVisible(true)
//
- final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, reqGLCaps, null, widthStep*szStep, heightStep*szStep, null);
-
+ final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, reqGLCaps, null, widthStep*szStep, heightStep*szStep);
+
Assert.assertNotNull(glad);
- System.out.println("Drawable Pre-GL(0): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName());
+ System.out.println("Drawable Pre-GL(0): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName());
Assert.assertTrue(glad.isRealized());
-
+
// Check caps of NativeWindow config w/o GL
final CapabilitiesImmutable chosenCaps = glad.getChosenGLCapabilities();
System.out.println("Drawable Caps Pre_GL : "+chosenCaps);
@@ -95,7 +95,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
Assert.assertTrue(chosenCaps.getGreenBits()>4);
Assert.assertTrue(chosenCaps.getBlueBits()>4);
Assert.assertTrue(chosenCaps.getRedBits()>4);
-
+
glad.display(); // force native context creation
// Check caps of GLDrawable after realization
@@ -113,45 +113,45 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
Assert.assertEquals(expGLCaps.isFBO(), chosenGLCaps.isFBO());
Assert.assertEquals(expGLCaps.isPBuffer(), chosenGLCaps.isPBuffer());
Assert.assertEquals(expGLCaps.isBitmap(), chosenGLCaps.isBitmap());
- /** Single/Double buffer cannot be checked since result may vary ..
+ /** Single/Double buffer cannot be checked since result may vary ..
if(chosenGLCaps.isOnscreen() || chosenGLCaps.isFBO()) {
// dbl buffer may be disabled w/ offscreen pbuffer and bitmap
Assert.assertEquals(expGLCaps.getDoubleBuffered(), chosenGLCaps.getDoubleBuffered());
- } */
+ } */
glad.addGLEventListener(demo);
-
+
final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener();
glad.addGLEventListener(snapshotGLEventListener);
-
+
glad.display(); // initial resize/display
-
+
// 1 - szStep = 2
- Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
+ Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep));
snapshotGLEventListener.setMakeSnapshot();
glad.display();
-
+
// 2, 3 (resize + display)
szStep = 1;
glad.setSize(widthStep*szStep, heightStep*szStep);
- Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
+ Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep));
snapshotGLEventListener.setMakeSnapshot();
glad.display();
-
+
// 4, 5 (resize + display)
szStep = 4;
glad.setSize(widthStep*szStep, heightStep*szStep);
- Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
+ Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep));
snapshotGLEventListener.setMakeSnapshot();
glad.display();
-
+
Thread.sleep(50);
-
+
glad.destroy();
- System.out.println("Fin Drawable: "+glad);
+ System.out.println("Fin Drawable: "+glad);
}
@Test
@@ -164,8 +164,8 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
if(null != f) {
System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString());
}
- }
-
+ }
+
@Test
public void testGL2OffScreenAutoDblBuf() throws InterruptedException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
@@ -182,7 +182,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setFBO(true);
doTest(reqGLCaps, new Gears(1));
}
-
+
@Test
public void testGL2OffScreenFBOSglBuf() throws InterruptedException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
@@ -191,8 +191,8 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setFBO(true);
reqGLCaps.setDoubleBuffered(false);
doTest(reqGLCaps, new Gears(1));
- }
-
+ }
+
@Test
public void testGL2OffScreenFBODblBufStencil() throws InterruptedException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
@@ -202,7 +202,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setStencilBits(1);
doTest(reqGLCaps, new Gears(1));
}
-
+
@Test
public void testGL2OffScreenFBODblBufMSAA() throws InterruptedException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
@@ -212,8 +212,8 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setSampleBuffers(true);
reqGLCaps.setNumSamples(4);
doTest(reqGLCaps, new Gears(1));
- }
-
+ }
+
@Test
public void testGL2OffScreenFBODblBufStencilMSAA() throws InterruptedException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
@@ -224,8 +224,8 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setSampleBuffers(true);
reqGLCaps.setNumSamples(4);
doTest(reqGLCaps, new Gears(1));
- }
-
+ }
+
@Test
public void testGL2OffScreenPbufferDblBuf() throws InterruptedException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
@@ -233,8 +233,8 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setOnscreen(false);
reqGLCaps.setPBuffer(true);
doTest(reqGLCaps, new Gears(1));
- }
-
+ }
+
@Test
public void testGL2OffScreenPbufferSglBuf() throws InterruptedException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
@@ -244,8 +244,8 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setDoubleBuffered(false);
doTest(reqGLCaps, new Gears(1));
}
-
- // Might be reduced to !stencil
+
+ // Might be reduced to !stencil
@Test
public void testGL2OffScreenPbufferDblBufStencil() throws InterruptedException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
@@ -255,7 +255,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setStencilBits(1);
doTest(reqGLCaps, new Gears(1));
}
-
+
// Might be reduced to !MSAA
@Test
public void testGL2OffScreenPbufferDblBufMSAA() throws InterruptedException {
@@ -266,8 +266,8 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setSampleBuffers(true);
reqGLCaps.setNumSamples(4);
doTest(reqGLCaps, new Gears(1));
- }
-
+ }
+
// Might be reduced to !stencil && !MSAA
@Test
public void testGL2OffScreenPbufferDblBufStencilMSAA() throws InterruptedException {
@@ -279,9 +279,9 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setSampleBuffers(true);
reqGLCaps.setNumSamples(4);
doTest(reqGLCaps, new Gears(1));
- }
-
-
+ }
+
+
// Might be reduced to !double-buff
@Test
public void testGL2OffScreenBitmapDblBuf() throws InterruptedException {
@@ -291,7 +291,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setBitmap(true);
doTest(reqGLCaps, new Gears(1));
}
-
+
@Test
public void testGL2OffScreenBitmapDblBufRGBA8881() throws InterruptedException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
@@ -304,7 +304,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setBitmap(true);
doTest(reqGLCaps, new Gears(1));
}
-
+
@Test
public void testGL2OffScreenBitmapDblBufRGB555() throws InterruptedException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
@@ -317,7 +317,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setBitmap(true);
doTest(reqGLCaps, new Gears(1));
}
-
+
@Test
public void testGL2OffScreenBitmapDblBufRGBA5551() throws InterruptedException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
@@ -330,7 +330,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setBitmap(true);
doTest(reqGLCaps, new Gears(1));
}
-
+
@Test
public void testGL2OffScreenBitmapSglBuf() throws InterruptedException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2);
@@ -340,7 +340,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setDoubleBuffered(false);
doTest(reqGLCaps, new Gears(1));
}
-
+
// Might be reduced to !stencil
@Test
public void testGL2OffScreenBitmapDblBufStencil() throws InterruptedException {
@@ -351,7 +351,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setStencilBits(1);
doTest(reqGLCaps, new Gears(1));
}
-
+
// Might be reduced to !MSAA
@Test
public void testGL2OffScreenBitmapDblBufMSAA() throws InterruptedException {
@@ -362,8 +362,8 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setSampleBuffers(true);
reqGLCaps.setNumSamples(4);
doTest(reqGLCaps, new Gears(1));
- }
-
+ }
+
// Might be reduced to !stencil && !MSAA
@Test
public void testGL2OffScreenBitmapDblBufStencilMSAA() throws InterruptedException {
@@ -375,8 +375,8 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase {
reqGLCaps.setSampleBuffers(true);
reqGLCaps.setNumSamples(4);
doTest(reqGLCaps, new Gears(1));
- }
-
+ }
+
public static void main(String args[]) throws IOException {
org.junit.runner.JUnitCore.main(TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT.class.getName());
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGLnBitmapCapsNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGLnBitmapCapsNEWT.java
index 75609224e..f35f8c8b0 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGLnBitmapCapsNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGLnBitmapCapsNEWT.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,12 +20,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.opengl.test.junit.jogl.acore;
import java.io.IOException;
@@ -52,11 +52,11 @@ import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
import com.jogamp.opengl.test.junit.util.UITestCase;
/**
- * Toolkit agnostic {@link GLOffscreenAutoDrawable} tests using the
- * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}.
+ * Toolkit agnostic {@link GLOffscreenAutoDrawable} tests using the
+ * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}.
*
- * The created {@link GLOffscreenAutoDrawable} is being used to run the {@link GLEventListener}.
- *
+ * The created {@link GLOffscreenAutoDrawable} is being used to run the {@link GLEventListener}.
+ *
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestGLAutoDrawableFactoryGLnBitmapCapsNEWT extends UITestCase {
@@ -71,15 +71,15 @@ public class TestGLAutoDrawableFactoryGLnBitmapCapsNEWT extends UITestCase {
System.out.println("Expected GL Caps: "+expGLCaps);
//
- // Create native OpenGL resources .. XGL/WGL/CGL ..
+ // Create native OpenGL resources .. XGL/WGL/CGL ..
// equivalent to GLAutoDrawable methods: setVisible(true)
//
- final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, reqGLCaps, null, widthStep*szStep, heightStep*szStep, null);
-
+ final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, reqGLCaps, null, widthStep*szStep, heightStep*szStep);
+
Assert.assertNotNull(glad);
- System.out.println("Drawable Pre-GL(0): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName());
+ System.out.println("Drawable Pre-GL(0): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName());
Assert.assertTrue(glad.isRealized());
-
+
// Check caps of NativeWindow config w/o GL
final CapabilitiesImmutable chosenCaps = glad.getChosenGLCapabilities();
System.out.println("Drawable Caps Pre_GL : "+chosenCaps);
@@ -87,7 +87,7 @@ public class TestGLAutoDrawableFactoryGLnBitmapCapsNEWT extends UITestCase {
Assert.assertTrue(chosenCaps.getGreenBits()>4);
Assert.assertTrue(chosenCaps.getBlueBits()>4);
Assert.assertTrue(chosenCaps.getRedBits()>4);
-
+
glad.display(); // force native context creation
// Check caps of GLDrawable after realization
@@ -105,45 +105,45 @@ public class TestGLAutoDrawableFactoryGLnBitmapCapsNEWT extends UITestCase {
Assert.assertEquals(expGLCaps.isFBO(), chosenGLCaps.isFBO());
Assert.assertEquals(expGLCaps.isPBuffer(), chosenGLCaps.isPBuffer());
Assert.assertEquals(expGLCaps.isBitmap(), chosenGLCaps.isBitmap());
- /** Single/Double buffer cannot be checked since result may vary ..
+ /** Single/Double buffer cannot be checked since result may vary ..
if(chosenGLCaps.isOnscreen() || chosenGLCaps.isFBO()) {
// dbl buffer may be disabled w/ offscreen pbuffer and bitmap
Assert.assertEquals(expGLCaps.getDoubleBuffered(), chosenGLCaps.getDoubleBuffered());
- } */
+ } */
glad.addGLEventListener(demo);
-
+
final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener();
glad.addGLEventListener(snapshotGLEventListener);
-
+
glad.display(); // initial resize/display
-
+
// 1 - szStep = 2
- Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
+ Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep));
snapshotGLEventListener.setMakeSnapshot();
glad.display();
-
+
// 2, 3 (resize + display)
szStep = 1;
glad.setSize(widthStep*szStep, heightStep*szStep);
- Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
+ Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep));
snapshotGLEventListener.setMakeSnapshot();
glad.display();
-
+
// 4, 5 (resize + display)
szStep = 4;
glad.setSize(widthStep*szStep, heightStep*szStep);
- Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
+ Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(),
AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep));
snapshotGLEventListener.setMakeSnapshot();
glad.display();
-
+
Thread.sleep(50);
-
+
glad.destroy();
- System.out.println("Fin Drawable: "+glad);
+ System.out.println("Fin Drawable: "+glad);
}
@Test
@@ -156,8 +156,8 @@ public class TestGLAutoDrawableFactoryGLnBitmapCapsNEWT extends UITestCase {
if(null != f) {
System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString());
}
- }
-
+ }
+
// Might be reduced to !double-buff
@Test
public void testGL2OffScreenBitmapDblBuf() throws InterruptedException {
@@ -166,7 +166,7 @@ public class TestGLAutoDrawableFactoryGLnBitmapCapsNEWT extends UITestCase {
reqGLCaps.setBitmap(true);
doTest(reqGLCaps, new Gears(1));
}
-
+
// Might be reduced to !MSAA
@Test
public void testGL2OffScreenBitmapDblBufMSAA() throws InterruptedException {
@@ -176,8 +176,8 @@ public class TestGLAutoDrawableFactoryGLnBitmapCapsNEWT extends UITestCase {
reqGLCaps.setSampleBuffers(true);
reqGLCaps.setNumSamples(4);
doTest(reqGLCaps, new Gears(1));
- }
-
+ }
+
public static void main(String args[]) throws IOException {
org.junit.runner.JUnitCore.main(TestGLAutoDrawableFactoryGLnBitmapCapsNEWT.class.getName());
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLExtensionQueryOffscreen.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLExtensionQueryOffscreen.java
index f9ab6c4b3..4bc8e7ee3 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLExtensionQueryOffscreen.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLExtensionQueryOffscreen.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,12 +20,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.opengl.test.junit.jogl.acore;
import java.util.Collections;
@@ -47,14 +47,14 @@ import org.junit.runners.MethodSorters;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestGLExtensionQueryOffscreen {
-
+
public static void main(String[] args) {
TestGLExtensionQueryOffscreen instance = new TestGLExtensionQueryOffscreen();
instance.testJogl2ExtensionCheck1();
instance.testJogl2ExtensionCheck2();
}
- /**
+ /**
* @deprecated This test uses a non public API in jogamp.opengl.* and hence is not recommended
*/
@Test
@@ -74,13 +74,13 @@ public class TestGLExtensionQueryOffscreen {
System.out.println("SharedContext: "+sharedContext);
System.out.println("SharedContext: "+setExtensions);
}
-
+
@Test
public void testJogl2ExtensionCheck2() {
final GLCapabilities caps = new GLCapabilities(GLProfile.getDefault());
- final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile());
- final GLOffscreenAutoDrawable drawable = factory.createOffscreenAutoDrawable(null, caps, null, 256, 256, null);
-
+ final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile());
+ final GLOffscreenAutoDrawable drawable = factory.createOffscreenAutoDrawable(null, caps, null, 256, 256);
+ drawable.display(); // trigger context creation ..
final GLContext context = drawable.getContext();
context.makeCurrent();
String extensions;
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java
index c8cc294a2..83e55b7e0 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java
@@ -30,16 +30,16 @@ public class TestNEWTCloseX11DisplayBug565 {
try {
for ( int j = 0; j < 10; j++ ) {
final int open0;
- if(NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false)) {
+ if(NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false)) {
open0 = X11Util.getOpenDisplayConnectionNumber();
} else {
open0 = 0;
}
-
+
GLCapabilitiesImmutable caps = new GLCapabilities( GLProfile.getDefault( ) );
-
+
GLWindow window = GLWindow.create(caps);
- window.setTitle("NEWT Resource X11 Leak - #" + j );
+ window.setTitle("NEWT Resource X11 Leak - #" + j );
window.setSize( 128, 128 );
window.setVisible(true);
window.display();
@@ -69,7 +69,7 @@ public class TestNEWTCloseX11DisplayBug565 {
try {
for ( int j = 0; j < 10; j++ ) {
final int open0;
- if(NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false)) {
+ if(NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false)) {
open0 = X11Util.getOpenDisplayConnectionNumber();
} else {
open0 = 0;
@@ -111,7 +111,7 @@ public class TestNEWTCloseX11DisplayBug565 {
try {
for ( int j = 0; j < 10; j++ ) {
final int open0;
- if(NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false)) {
+ if(NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false)) {
open0 = X11Util.getOpenDisplayConnectionNumber();
} else {
open0 = 0;
@@ -121,13 +121,7 @@ public class TestNEWTCloseX11DisplayBug565 {
GLOffscreenAutoDrawable buffer = GLDrawableFactory.getFactory( glp ).createOffscreenAutoDrawable(
- null,
- caps,
- new DefaultGLCapabilitiesChooser(),
- 256,
- 256,
- null
- );
+ null, caps, new DefaultGLCapabilitiesChooser(), 256, 256);
buffer.display();
buffer.destroy();
@@ -146,10 +140,10 @@ public class TestNEWTCloseX11DisplayBug565 {
Assert.fail(e.getMessage());
}
}
-
+
public static void main(String args[]) {
org.junit.runner.JUnitCore.main(TestNEWTCloseX11DisplayBug565.class.getName());
}
-
+
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java
index a3eb6db84..77657f6f1 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,12 +20,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.opengl.test.junit.jogl.acore;
import javax.media.opengl.GLCapabilities;
@@ -73,7 +73,7 @@ public class TestSharedContextListAWT extends UITestCase {
}
private void initShared() {
- sharedDrawable = GLDrawableFactory.getFactory(glp).createOffscreenAutoDrawable(null, caps, null, width, height, null);
+ sharedDrawable = GLDrawableFactory.getFactory(glp).createOffscreenAutoDrawable(null, caps, null, width, height);
Assert.assertNotNull(sharedDrawable);
sharedGears = new Gears();
Assert.assertNotNull(sharedGears);
@@ -86,8 +86,8 @@ public class TestSharedContextListAWT extends UITestCase {
Assert.assertNotNull(sharedDrawable);
sharedDrawable.destroy();
}
-
- protected void setFrameTitle(final Frame f, final boolean useShared)
+
+ protected void setFrameTitle(final Frame f, final boolean useShared)
throws InterruptedException, InvocationTargetException {
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
@@ -99,12 +99,13 @@ public class TestSharedContextListAWT extends UITestCase {
protected GLCanvas runTestGL(final Frame frame, final Animator animator, final int x, final int y, final boolean useShared, final boolean vsync)
throws InterruptedException, InvocationTargetException
{
- final GLCanvas glCanvas = new GLCanvas(caps, useShared ? sharedDrawable.getContext() : null);
+ final GLCanvas glCanvas = new GLCanvas(caps);
Assert.assertNotNull(glCanvas);
+ glCanvas.setSharedAutoDrawable(sharedDrawable);
frame.add(glCanvas);
frame.setLocation(x, y);
frame.setSize(width, height);
-
+
Gears gears = new Gears(vsync ? 1 : 0);
if(useShared) {
gears.setGears(sharedGears.getGear1(), sharedGears.getGear2(), sharedGears.getGear3());
@@ -133,22 +134,22 @@ public class TestSharedContextListAWT extends UITestCase {
final GLCanvas glc1 = runTestGL(f1, animator, 0, 0, true, false);
int x0 = f1.getX();
int y0 = f1.getY();
-
- final GLCanvas glc2 = runTestGL(f2, animator,
+
+ final GLCanvas glc2 = runTestGL(f2, animator,
x0+width,
- y0+0,
+ y0+0,
true, false);
-
- final GLCanvas glc3 = runTestGL(f3, animator,
- x0+0,
- y0+height,
+
+ final GLCanvas glc3 = runTestGL(f3, animator,
+ x0+0,
+ y0+height,
false, true);
setFrameTitle(f1, true);
setFrameTitle(f2, true);
setFrameTitle(f3, false);
-
- animator.setUpdateFPSFrames(1, null);
+
+ animator.setUpdateFPSFrames(1, null);
animator.start();
while(animator.isAnimating() && animator.getTotalFPSDuration()
+ * This is achieved by creating a master GLContext to an offscreen invisible GLAutoDrawable,
+ * which is then shared by the 3 GLContext of the three GLWindow instances.
+ *
+ *
+ * The original VBO is created by attaching a GearsES1 instance to
+ * the master GLAutoDrawable and initializing it.
+ *
+ *
+ * Above method allows random creation of all GLWindow instances.
+ *
+ *
+ * One animator is being used, hence the GLWindow, GLDrawable and GLContext
+ * creation of all 3 GLWindows is sequential.
+ *
+ */
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestSharedContextVBOES1NEWT extends UITestCase {
static GLProfile glp;
static GLCapabilities caps;
static int width, height;
- GLOffscreenAutoDrawable sharedDrawable;
+ GLAutoDrawable sharedDrawable;
GearsES1 sharedGears;
@BeforeClass
@@ -69,14 +91,22 @@ public class TestSharedContextVBOES1NEWT extends UITestCase {
}
}
- private void initShared() {
- sharedDrawable = GLDrawableFactory.getFactory(glp).createOffscreenAutoDrawable(null, caps, null, width, height, null);
+ private void initShared() throws InterruptedException {
+ GLDrawable dummyDrawable = GLDrawableFactory.getFactory(glp).createDummyDrawable(null, true /* createNewDevice */, caps.getGLProfile());
+ dummyDrawable.setRealized(true);
+ sharedDrawable = new GLAutoDrawableDelegate(dummyDrawable, null, null, true /*ownDevice*/, null) { };
Assert.assertNotNull(sharedDrawable);
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(sharedDrawable, true));
+
sharedGears = new GearsES1();
Assert.assertNotNull(sharedGears);
sharedDrawable.addGLEventListener(sharedGears);
// init and render one frame, which will setup the Gears display lists
sharedDrawable.display();
+ final GLContext ctxM = sharedDrawable.getContext();
+ Assert.assertTrue("Master ctx not created", AWTRobotUtil.waitForCreated(ctxM, true));
+ Assert.assertTrue("Master Ctx is shared before shared creation", !ctxM.isShared());
+ Assert.assertTrue("Master Gears is shared", !sharedGears.usesSharedGears());
}
private void releaseShared() {
@@ -87,6 +117,7 @@ public class TestSharedContextVBOES1NEWT extends UITestCase {
protected GLWindow runTestGL(Animator animator, int x, int y, boolean useShared, boolean vsync) throws InterruptedException {
GLWindow glWindow = GLWindow.create(caps);
Assert.assertNotNull(glWindow);
+ glWindow.setPosition(x, y);
glWindow.setTitle("Shared Gears NEWT Test: "+x+"/"+y+" shared "+useShared);
if(useShared) {
glWindow.setSharedContext(sharedDrawable.getContext());
@@ -96,7 +127,7 @@ public class TestSharedContextVBOES1NEWT extends UITestCase {
GearsES1 gears = new GearsES1(vsync ? 1 : 0);
if(useShared) {
- gears.setGears(sharedGears.getGear1(), sharedGears.getGear2(), sharedGears.getGear3());
+ gears.setSharedGearsObjects(sharedGears.getGear1(), sharedGears.getGear2(), sharedGears.getGear3());
}
glWindow.addGLEventListener(gears);
@@ -105,9 +136,17 @@ public class TestSharedContextVBOES1NEWT extends UITestCase {
glWindow.setVisible(true);
Assert.assertTrue(AWTRobotUtil.waitForRealized(glWindow, true));
Assert.assertTrue(AWTRobotUtil.waitForVisible(glWindow, true));
-
- glWindow.setPosition(x, y);
-
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(glWindow.getContext(), true));
+
+ System.err.println("Master Context: ");
+ MiscUtils.dumpSharedGLContext(sharedDrawable.getContext());
+ System.err.println("New Context: ");
+ MiscUtils.dumpSharedGLContext(glWindow.getContext());
+ if( useShared ) {
+ Assert.assertEquals("Master Context not shared as expected", true, sharedDrawable.getContext().isShared());
+ }
+ Assert.assertEquals("New Context not shared as expected", useShared, glWindow.getContext().isShared());
+ Assert.assertEquals("Gears is not shared as expected", useShared, gears.usesSharedGears());
return glWindow;
}
@@ -117,11 +156,11 @@ public class TestSharedContextVBOES1NEWT extends UITestCase {
Animator animator = new Animator();
GLWindow f1 = runTestGL(animator, 0, 0, true, false);
InsetsImmutable insets = f1.getInsets();
- GLWindow f2 = runTestGL(animator, f1.getX()+width+insets.getTotalWidth(),
+ GLWindow f2 = runTestGL(animator, f1.getX()+width+insets.getTotalWidth(),
f1.getY()+0, true, false);
- GLWindow f3 = runTestGL(animator, f1.getX()+0,
- f1.getY()+height+insets.getTotalHeight(), false, true);
- animator.setUpdateFPSFrames(1, null);
+ GLWindow f3 = runTestGL(animator, f1.getX()+0,
+ f1.getY()+height+insets.getTotalHeight(), false, true);
+ animator.setUpdateFPSFrames(1, null);
animator.start();
while(animator.isAnimating() && animator.getTotalFPSDuration()
+ * This is achieved by using the 1st GLCanvas as the master
+ * and using the build-in blocking mechanism to postpone creation
+ * of the 2nd and 3rd GLCanvas until the 1st GLCanvas's GLContext becomes created.
+ *
+ *
+ * Above method allows random creation of the 1st GLCanvas, which triggers
+ * creation of the dependent other GLCanvas sharing it's GLContext.
+ *
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestSharedContextVBOES2AWT3 extends UITestCase {
+ static GLProfile glp;
+ static GLCapabilities caps;
+ static int width, height;
+
+ @BeforeClass
+ public static void initClass() {
+ if(GLProfile.isAvailable(GLProfile.GL2ES2)) {
+ glp = GLProfile.get(GLProfile.GL2ES2);
+ Assert.assertNotNull(glp);
+ caps = new GLCapabilities(glp);
+ Assert.assertNotNull(caps);
+ width = 256;
+ height = 256;
+ } else {
+ setTestSupported(false);
+ }
+ }
+
+ protected GLCanvas createGLCanvas(final Frame frame, int x, int y, GearsES2 gears) throws InterruptedException {
+ final GLCanvas glCanvas = new GLCanvas(caps);
+ Assert.assertNotNull(glCanvas);
+ glCanvas.addGLEventListener(gears);
+ frame.add(glCanvas);
+ frame.setLocation(x, y);
+ frame.setSize(width, height);
+ frame.setTitle("Shared Gears NEWT Test: "+x+"/"+y+" shared true");
+ return glCanvas;
+ }
+
+ @Test
+ public void test01SyncedCommonAnimatorSharedOffscreen() throws InterruptedException, InvocationTargetException {
+ final Frame f1 = new Frame();
+ final Animator animator = new Animator();
+ final GearsES2 g1 = new GearsES2(0);
+ final GLCanvas c1 = createGLCanvas(f1, 0, 0, g1);
+ animator.add(c1);
+
+ final Frame f2 = new Frame();
+ final GearsES2 g2 = new GearsES2(0);
+ g2.setSharedGears(g1);
+ final GLCanvas c2 = createGLCanvas(f2, f1.getX()+width,
+ f1.getY()+0, g2);
+ c2.setSharedAutoDrawable(c1);
+ animator.add(c2);
+
+ final Frame f3 = new Frame();
+ final GearsES2 g3 = new GearsES2(0);
+ g3.setSharedGears(g1);
+ final GLCanvas c3 = createGLCanvas(f3, f1.getX()+0,
+ f1.getY()+height, g3);
+ c3.setSharedAutoDrawable(c1);
+ animator.add(c3);
+
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ f2.setVisible(true); // shall wait until f1 is ready
+ f1.setVisible(true); // master ..
+ f3.setVisible(true); // shall wait until f1 is ready
+ } } );
+ animator.start(); // kicks off GLContext .. and hence gears of f2 + f3 completion
+
+ Thread.sleep(1000/60*10); // wait ~10 frames giving a chance to create (blocking until master share is valid)
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(c1, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(c1, true));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(c1.getContext(), true));
+ Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true));
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(c2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(c2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(c2.getContext(), true));
+ Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true));
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(c3, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(c3, true));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(c3.getContext(), true));
+ Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true));
+
+ final GLContext ctx1 = c1.getContext();
+ final GLContext ctx2 = c2.getContext();
+ final GLContext ctx3 = c3.getContext();
+ {
+ final List ctx1Shares = ctx1.getCreatedShares();
+ final List ctx2Shares = ctx2.getCreatedShares();
+ final List ctx3Shares = ctx3.getCreatedShares();
+ System.err.println("XXX-C-3.1:");
+ MiscUtils.dumpSharedGLContext(ctx1);
+ System.err.println("XXX-C-3.2:");
+ MiscUtils.dumpSharedGLContext(ctx2);
+ System.err.println("XXX-C-3.3:");
+ MiscUtils.dumpSharedGLContext(ctx3);
+
+ Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
+ Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
+ Assert.assertTrue("Ctx3 is not shared", ctx3.isShared());
+ Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size());
+ Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size());
+ Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size());
+ }
+
+ Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears());
+ Assert.assertTrue("Gears2 is not shared", g2.usesSharedGears());
+ Assert.assertTrue("Gears3 is not shared", g3.usesSharedGears());
+
+ try {
+ Thread.sleep(duration);
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ animator.stop();
+
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ try {
+ f1.dispose();
+ f2.dispose();
+ f3.dispose();
+ } catch (Throwable t) {
+ throw new RuntimeException(t);
+ }
+ }});
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(c1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(c2, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(c3, false));
+ }
+
+ @Test
+ public void test02AsyncEachWithAnimatorSharedOffscreen() throws InterruptedException, InvocationTargetException {
+ final Frame f1 = new Frame();
+ final Animator a1 = new Animator();
+ final GearsES2 g1 = new GearsES2(0);
+ final GLCanvas c1 = createGLCanvas(f1, 0, 0, g1);
+ a1.add(c1);
+ a1.start();
+ // f1.setVisible(true); // we do this post f2 .. to test pending creation!
+
+ final Frame f2 = new Frame();
+ final Animator a2 = new Animator();
+ final GearsES2 g2 = new GearsES2(0);
+ g2.setSharedGears(g1);
+ final GLCanvas c2 = createGLCanvas(f2, f1.getX()+width, f1.getY()+0, g2);
+ c2.setSharedAutoDrawable(c1);
+ a2.add(c2);
+ a2.start();
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ f2.setVisible(true);
+ } } );
+
+ Thread.sleep(200); // wait a while ..
+
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ f1.setVisible(true); // test pending creation of f2
+ } } );
+
+ final Frame f3 = new Frame();
+ final Animator a3 = new Animator();
+ final GearsES2 g3 = new GearsES2(0);
+ g3.setSharedGears(g1);
+ final GLCanvas c3 = createGLCanvas(f3, f1.getX()+0, f1.getY()+height, g3);
+ c3.setSharedAutoDrawable(c1);
+ a3.add(c3);
+ a3.start();
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ f3.setVisible(true);
+ } } );
+
+ Thread.sleep(1000/60*10); // wait ~10 frames giving a chance to create (blocking until master share is valid)
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(c1, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(c1, true));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(c1.getContext(), true));
+ Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true));
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(c2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(c2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(c2.getContext(), true));
+ Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true));
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(c3, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(c3, true));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(c3.getContext(), true));
+ Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true));
+
+ final GLContext ctx1 = c1.getContext();
+ final GLContext ctx2 = c2.getContext();
+ final GLContext ctx3 = c3.getContext();
+ {
+ final List ctx1Shares = ctx1.getCreatedShares();
+ final List ctx2Shares = ctx2.getCreatedShares();
+ final List ctx3Shares = ctx3.getCreatedShares();
+ System.err.println("XXX-C-3.1:");
+ MiscUtils.dumpSharedGLContext(ctx1);
+ System.err.println("XXX-C-3.2:");
+ MiscUtils.dumpSharedGLContext(ctx2);
+ System.err.println("XXX-C-3.3:");
+ MiscUtils.dumpSharedGLContext(ctx3);
+
+ Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
+ Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
+ Assert.assertTrue("Ctx3 is not shared", ctx3.isShared());
+ Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size());
+ Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size());
+ Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size());
+ }
+
+ Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears());
+ Assert.assertTrue("Gears2 is not shared", g2.usesSharedGears());
+ Assert.assertTrue("Gears3 is not shared", g3.usesSharedGears());
+
+ try {
+ Thread.sleep(duration);
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ a1.stop();
+ a2.stop();
+ a3.stop();
+
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ try {
+ f1.dispose();
+ f2.dispose();
+ f3.dispose();
+ } catch (Throwable t) {
+ throw new RuntimeException(t);
+ }
+ }});
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(c1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(c2, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(c3, false));
+ }
+
+ static long duration = 1000; // ms
+
+ public static void main(String args[]) {
+ for(int i=0; i 0 ) {
- // instable on OSX .. driver/OS bug when multi threading (3 animator)
- System.err.println("Shared context w/ 3 context each running in there own thread is instable here on OSX 10.7.4/NVidia,");
- System.err.println("SIGSEGV @ glDrawArrays / glBindBuffer .. any shared VBO.");
- System.err.println("Seems to run fine on 10.6.8/NVidia.");
- return;
- }
- initShared(false);
- Animator animator1 = new Animator();
- Animator animator2 = new Animator();
- Animator animator3 = new Animator();
- GLWindow f1 = runTestGL(animator1, 0, 0, true, false);
- InsetsImmutable insets = f1.getInsets();
- GLWindow f2 = runTestGL(animator2, f1.getX()+width+insets.getTotalWidth(),
- f1.getY()+0, true, false);
- GLWindow f3 = runTestGL(animator3, f1.getX()+0,
- f1.getY()+height+insets.getTotalHeight(), true, false);
-
- try {
- Thread.sleep(duration);
- } catch(Exception e) {
- e.printStackTrace();
- }
- animator1.stop();
- animator2.stop();
- animator3.stop();
-
- f1.destroy();
- f2.destroy();
- f3.destroy();
- Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false));
- Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false));
- Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false));
- Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false));
- Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false));
- Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false));
-
- releaseShared();
- }
-
- static long duration = 2000; // ms
-
- public static void main(String args[]) {
- for(int i=0; i
+ * This is achieved by relying on the sequential creation
+ * of the 3 GLWindows with their GLDrawable and GLContext.
+ *
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestSharedContextVBOES2NEWT0 extends UITestCase {
+ static GLProfile glp;
+ static GLCapabilities caps;
+ static int width, height;
+
+ @BeforeClass
+ public static void initClass() {
+ if(GLProfile.isAvailable(GLProfile.GL2ES2)) {
+ glp = GLProfile.get(GLProfile.GL2ES2);
+ Assert.assertNotNull(glp);
+ caps = new GLCapabilities(glp);
+ Assert.assertNotNull(caps);
+ width = 256;
+ height = 256;
+ } else {
+ setTestSupported(false);
+ }
+ }
+
+ protected GLWindow runTestGL(Animator animator, int x, int y, GearsES2 gears, GLContext sharedContext) throws InterruptedException {
+ final boolean useShared = null != sharedContext;
+ GLWindow glWindow = GLWindow.create(caps);
+ Assert.assertNotNull(glWindow);
+ glWindow.setPosition(x, y);
+ glWindow.setTitle("Shared Gears NEWT Test: "+x+"/"+y+" shared "+useShared);
+ if(useShared) {
+ glWindow.setSharedContext(sharedContext);
+ }
+ glWindow.setSize(width, height);
+ glWindow.addGLEventListener(gears);
+
+ animator.add(glWindow);
+ glWindow.setVisible(true);
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(glWindow, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(glWindow, true));
+ glWindow.display();
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(glWindow.getContext(), true));
+ Assert.assertTrue("Gears not initialized", gears.waitForInit(true));
+
+ return glWindow;
+ }
+
+ @Test
+ public void testCommonAnimatorShared() throws InterruptedException {
+ final Animator animator = new Animator();
+
+ //
+ // 1st
+ //
+ final GearsES2 g1 = new GearsES2(0);
+ final GLWindow f1 = runTestGL(animator, 0, 0, g1, null);
+ final GLContext ctx1 = f1.getContext();
+ Assert.assertTrue("Ctx is shared before shared creation", !ctx1.isShared());
+ final InsetsImmutable insets = f1.getInsets();
+
+ System.err.println("XXX-C-2.1:");
+ MiscUtils.dumpSharedGLContext(ctx1);
+
+ //
+ // 2nd
+ //
+ final GearsES2 g2 = new GearsES2(0);
+ g2.setSharedGearsObjects(g1.getGear1(), g1.getGear2(), g1.getGear3());
+ final GLWindow f2 = runTestGL(animator, f1.getX()+width+insets.getTotalWidth(),
+ f1.getY()+0, g2, f1.getContext());
+ final GLContext ctx2 = f2.getContext();
+ Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
+ Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
+
+ {
+ final List ctx1Shares = ctx1.getCreatedShares();
+ final List ctx2Shares = ctx2.getCreatedShares();
+ System.err.println("XXX-C-2.1:");
+ MiscUtils.dumpSharedGLContext(ctx1);
+ System.err.println("XXX-C-2.2:");
+ MiscUtils.dumpSharedGLContext(ctx2);
+
+ Assert.assertEquals("Ctx1 has unexpected number of created shares", 1, ctx1Shares.size());
+ Assert.assertEquals("Ctx2 has unexpected number of created shares", 1, ctx2Shares.size());
+ }
+
+ //
+ // 3rd
+ //
+ final GearsES2 g3 = new GearsES2(0);
+ g3.setSharedGearsObjects(g1.getGear1(), g1.getGear2(), g1.getGear3());
+ final GLWindow f3 = runTestGL(animator, f1.getX()+0,
+ f1.getY()+height+insets.getTotalHeight(), g3, f1.getContext());
+
+ final GLContext ctx3 = f3.getContext();
+ Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
+ Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
+ Assert.assertTrue("Ctx3 is not shared", ctx3.isShared());
+
+ {
+ final List ctx1Shares = ctx1.getCreatedShares();
+ final List ctx2Shares = ctx2.getCreatedShares();
+ final List ctx3Shares = ctx3.getCreatedShares();
+ System.err.println("XXX-C-3.1:");
+ MiscUtils.dumpSharedGLContext(ctx1);
+ System.err.println("XXX-C-3.2:");
+ MiscUtils.dumpSharedGLContext(ctx2);
+ System.err.println("XXX-C-3.3:");
+ MiscUtils.dumpSharedGLContext(ctx3);
+
+ Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size());
+ Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size());
+ Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size());
+ }
+
+ Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears());
+ Assert.assertTrue("Gears2 is not shared", g2.usesSharedGears());
+ Assert.assertTrue("Gears3 is not shared", g3.usesSharedGears());
+
+ animator.start();
+
+ try {
+ Thread.sleep(duration);
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ animator.stop();
+
+ f1.destroy();
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), false));
+ {
+ final List ctx1Shares = ctx1.getCreatedShares();
+ final List ctx2Shares = ctx2.getCreatedShares();
+ final List ctx3Shares = ctx3.getCreatedShares();
+ System.err.println("XXX-D-2.1:");
+ MiscUtils.dumpSharedGLContext(ctx1);
+ System.err.println("XXX-D-2.2:");
+ MiscUtils.dumpSharedGLContext(ctx2);
+ System.err.println("XXX-D-2.3:");
+ MiscUtils.dumpSharedGLContext(ctx3);
+
+ Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
+ Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
+ Assert.assertTrue("Ctx3 is not shared", ctx3.isShared());
+ Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size());
+ Assert.assertEquals("Ctx2 has unexpected number of created shares", 1, ctx2Shares.size());
+ Assert.assertEquals("Ctx3 has unexpected number of created shares", 1, ctx3Shares.size());
+ }
+
+ f2.destroy();
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), false));
+ {
+ final List ctx1Shares = ctx1.getCreatedShares();
+ final List ctx2Shares = ctx2.getCreatedShares();
+ final List ctx3Shares = ctx3.getCreatedShares();
+ System.err.println("XXX-D-1.1:");
+ MiscUtils.dumpSharedGLContext(ctx1);
+ System.err.println("XXX-D-1.2:");
+ MiscUtils.dumpSharedGLContext(ctx2);
+ System.err.println("XXX-D-1.3:");
+ MiscUtils.dumpSharedGLContext(ctx3);
+
+ Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
+ Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
+ Assert.assertTrue("Ctx3 is not shared", ctx3.isShared());
+ Assert.assertEquals("Ctx1 has unexpected number of created shares", 1, ctx1Shares.size());
+ Assert.assertEquals("Ctx2 has unexpected number of created shares", 1, ctx2Shares.size());
+ Assert.assertEquals("Ctx3 has unexpected number of created shares", 0, ctx3Shares.size());
+ }
+
+ f3.destroy();
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), false));
+ {
+ final List ctx1Shares = ctx1.getCreatedShares();
+ final List ctx2Shares = ctx2.getCreatedShares();
+ final List ctx3Shares = ctx3.getCreatedShares();
+ System.err.println("XXX-D-0.1:");
+ MiscUtils.dumpSharedGLContext(ctx1);
+ System.err.println("XXX-D-0.2:");
+ MiscUtils.dumpSharedGLContext(ctx2);
+ System.err.println("XXX-D-0.3:");
+ MiscUtils.dumpSharedGLContext(ctx3);
+
+ Assert.assertTrue("Ctx1 is shared", !ctx1.isShared());
+ Assert.assertTrue("Ctx2 is shared", !ctx2.isShared());
+ Assert.assertTrue("Ctx3 is shared", !ctx3.isShared());
+ Assert.assertEquals("Ctx1 has unexpected number of created shares", 0, ctx1Shares.size());
+ Assert.assertEquals("Ctx2 has unexpected number of created shares", 0, ctx2Shares.size());
+ Assert.assertEquals("Ctx3 has unexpected number of created shares", 0, ctx3Shares.size());
+ }
+ }
+
+ static long duration = 1000; // ms
+
+ public static void main(String args[]) {
+ for(int i=0; i
+ * This is achieved by creating a master GLContext to an offscreen invisible GLAutoDrawable,
+ * which is then shared by the 3 GLContext of the three GLWindow instances.
+ *
+ *
+ * The original VBO is created by attaching a GearsES2 instance to
+ * the master GLAutoDrawable and initializing it.
+ *
+ *
+ * Above method allows random creation of all GLWindow instances.
+ *
+ *
+ * One tests uses only one animator, where the GLWindow, GLDrawable and GLContext
+ * creation of all 3 GLWindows is sequential.
+ *
+ *
+ * Another tests uses 3 animator, one for each GLWindow,
+ * where the GLWindow, GLDrawable and GLContext creation
+ * of all 3 GLWindows is random.
+ * This fact benefits from the master GLContext/GLAutoDrawable,
+ * since it is guaranteed it exist and is realized at the time of the shared
+ * GLWindow creation.
+ *
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestSharedContextVBOES2NEWT1 extends UITestCase {
+ static GLProfile glp;
+ static GLCapabilities caps;
+ static int width, height;
+ GLAutoDrawable sharedDrawable;
+ GearsES2 sharedGears;
+
+ @BeforeClass
+ public static void initClass() {
+ if(GLProfile.isAvailable(GLProfile.GL2ES2)) {
+ glp = GLProfile.get(GLProfile.GL2ES2);
+ Assert.assertNotNull(glp);
+ caps = new GLCapabilities(glp);
+ Assert.assertNotNull(caps);
+ width = 256;
+ height = 256;
+ } else {
+ setTestSupported(false);
+ }
+ }
+
+ private void initShared(boolean onscreen) throws InterruptedException {
+ if(onscreen) {
+ GLWindow glWindow = GLWindow.create(caps);
+ Assert.assertNotNull(glWindow);
+ glWindow.setSize(width, height);
+ glWindow.setVisible(true);
+ sharedDrawable = glWindow;
+ } else {
+ GLDrawable dummyDrawable = GLDrawableFactory.getFactory(glp).createDummyDrawable(null, true /* createNewDevice */, caps.getGLProfile());
+ dummyDrawable.setRealized(true);
+ sharedDrawable = new GLAutoDrawableDelegate(dummyDrawable, null, null, true /*ownDevice*/, null) { };
+ }
+ Assert.assertNotNull(sharedDrawable);
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(sharedDrawable, true));
+
+ sharedGears = new GearsES2();
+ Assert.assertNotNull(sharedGears);
+ sharedDrawable.addGLEventListener(sharedGears);
+ // init and render one frame, which will setup the Gears display lists
+ sharedDrawable.display();
+ final GLContext ctxM = sharedDrawable.getContext();
+ Assert.assertTrue("Master ctx not created", AWTRobotUtil.waitForCreated(ctxM, true));
+ Assert.assertTrue("Master Ctx is shared before shared creation", !ctxM.isShared());
+ Assert.assertTrue("Master Gears not initialized", sharedGears.waitForInit(true));
+ Assert.assertTrue("Master Gears is shared", !sharedGears.usesSharedGears());
+ }
+
+ private void releaseShared() {
+ Assert.assertNotNull(sharedDrawable);
+ sharedDrawable.destroy();
+ sharedDrawable = null;
+ }
+
+ protected GLWindow runTestGL(Animator animator, int x, int y, boolean useShared, boolean vsync) throws InterruptedException {
+ GLWindow glWindow = GLWindow.create(caps);
+ Assert.assertNotNull(glWindow);
+ glWindow.setPosition(x, y);
+ glWindow.setTitle("Shared Gears NEWT Test: "+x+"/"+y+" shared "+useShared);
+ if(useShared) {
+ glWindow.setSharedContext(sharedDrawable.getContext());
+ }
+
+ glWindow.setSize(width, height);
+
+ GearsES2 gears = new GearsES2(vsync ? 1 : 0);
+ if(useShared) {
+ gears.setSharedGearsObjects(sharedGears.getGear1(), sharedGears.getGear2(), sharedGears.getGear3());
+ }
+ glWindow.addGLEventListener(gears);
+
+ animator.add(glWindow);
+ animator.start();
+ glWindow.setVisible(true);
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(glWindow, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(glWindow, true));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(glWindow.getContext(), true));
+
+ System.err.println("Master Context: ");
+ MiscUtils.dumpSharedGLContext(sharedDrawable.getContext());
+ System.err.println("New Context: ");
+ MiscUtils.dumpSharedGLContext(glWindow.getContext());
+ if( useShared ) {
+ Assert.assertEquals("Master Context not shared as expected", true, sharedDrawable.getContext().isShared());
+ }
+ Assert.assertEquals("New Context not shared as expected", useShared, glWindow.getContext().isShared());
+
+ Assert.assertTrue("Gears not initialized", sharedGears.waitForInit(true));
+ Assert.assertEquals("Gears is not shared as expected", useShared, gears.usesSharedGears());
+
+ return glWindow;
+ }
+
+ @Test
+ public void test01CommonAnimatorSharedOnscreen() throws InterruptedException {
+ initShared(true);
+ Animator animator = new Animator();
+ GLWindow f1 = runTestGL(animator, 0, 0, true, false);
+ InsetsImmutable insets = f1.getInsets();
+ GLWindow f2 = runTestGL(animator, f1.getX()+width+insets.getTotalWidth(),
+ f1.getY()+0, true, false);
+ GLWindow f3 = runTestGL(animator, f1.getX()+0,
+ f1.getY()+height+insets.getTotalHeight(), true, false);
+ try {
+ Thread.sleep(duration);
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ animator.stop();
+
+ f1.destroy();
+ f2.destroy();
+ f3.destroy();
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), false));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), false));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), false));
+
+ releaseShared();
+ }
+
+ @Test
+ public void test02CommonAnimatorSharedOffscreen() throws InterruptedException {
+ initShared(false);
+ Animator animator = new Animator();
+ GLWindow f1 = runTestGL(animator, 0, 0, true, false);
+ InsetsImmutable insets = f1.getInsets();
+ GLWindow f2 = runTestGL(animator, f1.getX()+width+insets.getTotalWidth(),
+ f1.getY()+0, true, false);
+ GLWindow f3 = runTestGL(animator, f1.getX()+0,
+ f1.getY()+height+insets.getTotalHeight(), true, false);
+ try {
+ Thread.sleep(duration);
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ animator.stop();
+
+ f1.destroy();
+ f2.destroy();
+ f3.destroy();
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), false));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), false));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), false));
+
+ releaseShared();
+ }
+
+ @Test
+ public void test03EachWithAnimatorSharedOffscreen() throws InterruptedException {
+ initShared(false);
+ Animator animator1 = new Animator();
+ Animator animator2 = new Animator();
+ Animator animator3 = new Animator();
+ GLWindow f1 = runTestGL(animator1, 0, 0, true, false);
+ InsetsImmutable insets = f1.getInsets();
+ GLWindow f2 = runTestGL(animator2, f1.getX()+width+insets.getTotalWidth(),
+ f1.getY()+0, true, false);
+ GLWindow f3 = runTestGL(animator3, f1.getX()+0,
+ f1.getY()+height+insets.getTotalHeight(), true, false);
+
+ try {
+ Thread.sleep(duration);
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ animator1.stop();
+ animator2.stop();
+ animator3.stop();
+
+ f1.destroy();
+ f2.destroy();
+ f3.destroy();
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), false));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), false));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), false));
+
+ releaseShared();
+ }
+
+ static long duration = 1000; // ms
+
+ public static void main(String args[]) {
+ for(int i=0; i
+ * This is achieved by using the 1st GLWindow's GLContext as the master
+ * and manually triggering creation of the 2nd and 3rd GLWindow when the 1st GLWindow's
+ * GLContext becomes created. The trigger is performed by simply
+ * inserting a GLRunnable in the 1st GLWindow, which makes the other visible.
+ *
+ *
+ * Above method allows random creation of the 1st GLWindow, which triggers
+ * creation of the dependent other GLWindow sharing it's GLContext.
+ *
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestSharedContextVBOES2NEWT2 extends UITestCase {
+ static GLProfile glp;
+ static GLCapabilities caps;
+ static int width, height;
+
+ @BeforeClass
+ public static void initClass() {
+ if(GLProfile.isAvailable(GLProfile.GL2ES2)) {
+ glp = GLProfile.get(GLProfile.GL2ES2);
+ Assert.assertNotNull(glp);
+ caps = new GLCapabilities(glp);
+ Assert.assertNotNull(caps);
+ width = 256;
+ height = 256;
+ } else {
+ setTestSupported(false);
+ }
+ }
+
+ protected GLWindow createGLWindow(int x, int y, GearsES2 gears) throws InterruptedException {
+ GLWindow glWindow = GLWindow.create(caps);
+ Assert.assertNotNull(glWindow);
+ glWindow.setPosition(x, y);
+ glWindow.setTitle("Shared Gears NEWT Test: "+x+"/"+y+" shared true");
+ glWindow.setSize(width, height);
+ glWindow.addGLEventListener(gears);
+
+ return glWindow;
+ }
+
+ @Test
+ public void test01SyncedCommonAnimatorSharedOffscreen() throws InterruptedException {
+ final Animator animator = new Animator();
+ final GearsES2 g1 = new GearsES2(0);
+ final GLWindow f1 = createGLWindow(0, 0, g1);
+ animator.add(f1);
+ InsetsImmutable insets = f1.getInsets();
+
+ final GearsES2 g2 = new GearsES2(0);
+ g2.setSharedGears(g1);
+ final GLWindow f2 = createGLWindow(f1.getX()+width+insets.getTotalWidth(),
+ f1.getY()+0, g2);
+ animator.add(f2);
+
+ final GearsES2 g3 = new GearsES2(0);
+ g3.setSharedGears(g1);
+ final GLWindow f3 = createGLWindow(f1.getX()+0,
+ f1.getY()+height+insets.getTotalHeight(), g3);
+ animator.add(f3);
+
+ // f1's shared GLContext is ready !
+ f1.invoke(false, new GLRunnable() {
+ @Override
+ public boolean run(GLAutoDrawable drawable) {
+ final GLContext ctx1 = f1.getContext();
+ Assert.assertTrue("Ctx is shared before shared creation", !ctx1.isShared());
+ f2.setSharedContext(ctx1);
+ f2.setVisible(true);
+ f2.display(); // kick off GLContext ..
+ f3.setSharedContext(ctx1);
+ f3.setVisible(true);
+ f3.display(); // kick off GLContext ..
+ return true;
+ }
+ });
+
+ f1.setVisible(true);
+ f1.display(); // kick off GLContext .. and hence f2 + f3 creation
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, true));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), true));
+ Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true));
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), true));
+ Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true));
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, true));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), true));
+ Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true));
+
+ animator.start(); // post start animator, otherwise display will be suppressed
+
+ final GLContext ctx1 = f1.getContext();
+ final GLContext ctx2 = f2.getContext();
+ final GLContext ctx3 = f3.getContext();
+ {
+ final List ctx1Shares = ctx1.getCreatedShares();
+ final List ctx2Shares = ctx2.getCreatedShares();
+ final List ctx3Shares = ctx3.getCreatedShares();
+ System.err.println("XXX-C-3.1:");
+ MiscUtils.dumpSharedGLContext(ctx1);
+ System.err.println("XXX-C-3.2:");
+ MiscUtils.dumpSharedGLContext(ctx2);
+ System.err.println("XXX-C-3.3:");
+ MiscUtils.dumpSharedGLContext(ctx3);
+
+ Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
+ Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
+ Assert.assertTrue("Ctx3 is not shared", ctx3.isShared());
+ Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size());
+ Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size());
+ Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size());
+ }
+
+ Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears());
+ Assert.assertTrue("Gears2 is not shared", g2.usesSharedGears());
+ Assert.assertTrue("Gears3 is not shared", g3.usesSharedGears());
+
+ try {
+ Thread.sleep(duration);
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ animator.stop();
+
+ f1.destroy();
+ f2.destroy();
+ f3.destroy();
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false));
+ }
+
+ @Test
+ public void test02AsyncEachWithAnimatorSharedOffscreen() throws InterruptedException {
+ final Animator a1 = new Animator();
+ final GearsES2 g1 = new GearsES2(0);
+ final GLWindow f1 = createGLWindow(0, 0, g1);
+ a1.add(f1);
+ a1.start();
+ f1.setVisible(true);
+
+ InsetsImmutable insets = f1.getInsets();
+
+ final Animator a2 = new Animator();
+ final GearsES2 g2 = new GearsES2(0);
+ g2.setSharedGears(g1);
+ final GLWindow f2 = createGLWindow(f1.getX()+width+insets.getTotalWidth(),
+ f1.getY()+0, g2);
+ a2.add(f2);
+ a2.start();
+
+ final Animator a3 = new Animator();
+ final GearsES2 g3 = new GearsES2(0);
+ g3.setSharedGears(g1);
+ final GLWindow f3 = createGLWindow(f1.getX()+0,
+ f1.getY()+height+insets.getTotalHeight(), g3);
+ a3.add(f3);
+ a3.start();
+
+ // f1's shared GLContext is ready !
+ f1.invoke(false, new GLRunnable() {
+ @Override
+ public boolean run(GLAutoDrawable drawable) {
+ final GLContext ctx1 = f1.getContext();
+ Assert.assertTrue("Ctx is shared before shared creation", !ctx1.isShared());
+ f2.setSharedContext(ctx1);
+ f2.setVisible(true);
+ f3.setSharedContext(ctx1);
+ f3.setVisible(true);
+ return true;
+ }
+ });
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, true));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), true));
+ Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true));
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), true));
+ Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, true));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), true));
+ Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true));
+
+ final GLContext ctx1 = f1.getContext();
+ final GLContext ctx2 = f2.getContext();
+ final GLContext ctx3 = f3.getContext();
+ {
+ final List ctx1Shares = ctx1.getCreatedShares();
+ final List ctx2Shares = ctx2.getCreatedShares();
+ final List ctx3Shares = ctx3.getCreatedShares();
+ System.err.println("XXX-C-3.1:");
+ MiscUtils.dumpSharedGLContext(ctx1);
+ System.err.println("XXX-C-3.2:");
+ MiscUtils.dumpSharedGLContext(ctx2);
+ System.err.println("XXX-C-3.3:");
+ MiscUtils.dumpSharedGLContext(ctx3);
+
+ Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
+ Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
+ Assert.assertTrue("Ctx3 is not shared", ctx3.isShared());
+ Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size());
+ Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size());
+ Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size());
+ }
+
+ Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears());
+ Assert.assertTrue("Gears2 is not shared", g2.usesSharedGears());
+ Assert.assertTrue("Gears3 is not shared", g3.usesSharedGears());
+
+ try {
+ Thread.sleep(duration);
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ a1.stop();
+ a2.stop();
+ a3.stop();
+
+ f1.destroy();
+ f2.destroy();
+ f3.destroy();
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false));
+ }
+
+ static long duration = 1000; // ms
+
+ public static void main(String args[]) {
+ for(int i=0; i
+ * This is achieved by using the 1st GLWindow as the master
+ * and using the build-in blocking mechanism to postpone creation
+ * of the 2nd and 3rd GLWindow until the 1st GLWindow's GLContext becomes created.
+ *
+ *
+ * Above method allows random creation of the 1st GLWindow, which triggers
+ * creation of the dependent other GLWindow sharing it's GLContext.
+ *
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestSharedContextVBOES2NEWT3 extends UITestCase {
+ static GLProfile glp;
+ static GLCapabilities caps;
+ static int width, height;
+
+ @BeforeClass
+ public static void initClass() {
+ if(GLProfile.isAvailable(GLProfile.GL2ES2)) {
+ glp = GLProfile.get(GLProfile.GL2ES2);
+ Assert.assertNotNull(glp);
+ caps = new GLCapabilities(glp);
+ Assert.assertNotNull(caps);
+ width = 256;
+ height = 256;
+ } else {
+ setTestSupported(false);
+ }
+ }
+
+ protected GLWindow createGLWindow(int x, int y, GearsES2 gears) throws InterruptedException {
+ GLWindow glWindow = GLWindow.create(caps);
+ Assert.assertNotNull(glWindow);
+ glWindow.setPosition(x, y);
+ glWindow.setTitle("Shared Gears NEWT Test: "+x+"/"+y+" shared true");
+ glWindow.setSize(width, height);
+ glWindow.addGLEventListener(gears);
+
+ return glWindow;
+ }
+
+ @Test
+ public void test01SyncedCommonAnimatorSharedOffscreen() throws InterruptedException {
+ final Animator animator = new Animator();
+ final GearsES2 g1 = new GearsES2(0);
+ final GLWindow f1 = createGLWindow(0, 0, g1);
+ animator.add(f1);
+ InsetsImmutable insets = f1.getInsets();
+
+ final GearsES2 g2 = new GearsES2(0);
+ g2.setSharedGears(g1);
+ final GLWindow f2 = createGLWindow(f1.getX()+width+insets.getTotalWidth(),
+ f1.getY()+0, g2);
+ f2.setSharedAutoDrawable(f1);
+ animator.add(f2);
+
+ final GearsES2 g3 = new GearsES2(0);
+ g3.setSharedGears(g1);
+ final GLWindow f3 = createGLWindow(f1.getX()+0,
+ f1.getY()+height+insets.getTotalHeight(), g3);
+ f3.setSharedAutoDrawable(f1);
+ animator.add(f3);
+
+ f2.setVisible(true); // shall wait until f1 is ready
+ f1.setVisible(true); // master ..
+ f3.setVisible(true); // shall wait until f1 is ready
+ animator.start(); // kicks off GLContext .. and hence gears of f2 + f3 completion
+
+ Thread.sleep(1000/60*10); // wait ~10 frames giving a chance to create (blocking until master share is valid)
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, true));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), true));
+ Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true));
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), true));
+ Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true));
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, true));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), true));
+ Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true));
+
+ final GLContext ctx1 = f1.getContext();
+ final GLContext ctx2 = f2.getContext();
+ final GLContext ctx3 = f3.getContext();
+ {
+ final List ctx1Shares = ctx1.getCreatedShares();
+ final List ctx2Shares = ctx2.getCreatedShares();
+ final List ctx3Shares = ctx3.getCreatedShares();
+ System.err.println("XXX-C-3.1:");
+ MiscUtils.dumpSharedGLContext(ctx1);
+ System.err.println("XXX-C-3.2:");
+ MiscUtils.dumpSharedGLContext(ctx2);
+ System.err.println("XXX-C-3.3:");
+ MiscUtils.dumpSharedGLContext(ctx3);
+
+ Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
+ Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
+ Assert.assertTrue("Ctx3 is not shared", ctx3.isShared());
+ Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size());
+ Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size());
+ Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size());
+ }
+
+ Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears());
+ Assert.assertTrue("Gears2 is not shared", g2.usesSharedGears());
+ Assert.assertTrue("Gears3 is not shared", g3.usesSharedGears());
+
+ try {
+ Thread.sleep(duration);
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ animator.stop();
+
+ f1.destroy();
+ f2.destroy();
+ f3.destroy();
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false));
+ }
+
+ @Test
+ public void test02AsyncEachWithAnimatorSharedOffscreen() throws InterruptedException {
+ final Animator a1 = new Animator();
+ final GearsES2 g1 = new GearsES2(0);
+ final GLWindow f1 = createGLWindow(0, 0, g1);
+ a1.add(f1);
+ a1.start();
+ // f1.setVisible(true); // we do this post f2 .. to test pending creation!
+
+ InsetsImmutable insets = f1.getInsets();
+
+ final Animator a2 = new Animator();
+ final GearsES2 g2 = new GearsES2(0);
+ g2.setSharedGears(g1);
+ final GLWindow f2 = createGLWindow(f1.getX()+width+insets.getTotalWidth(),
+ f1.getY()+0, g2);
+ f2.setSharedAutoDrawable(f1);
+ a2.add(f2);
+ a2.start();
+ f2.setVisible(true);
+
+ f1.setVisible(true); // test pending creation of f2
+
+ final Animator a3 = new Animator();
+ final GearsES2 g3 = new GearsES2(0);
+ g3.setSharedGears(g1);
+ final GLWindow f3 = createGLWindow(f1.getX()+0,
+ f1.getY()+height+insets.getTotalHeight(), g3);
+ f3.setSharedAutoDrawable(f1);
+ a3.add(f3);
+ a3.start();
+ f3.setVisible(true);
+
+ Thread.sleep(1000/60*10); // wait ~10 frames giving a chance to create (blocking until master share is valid)
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, true));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), true));
+ Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true));
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), true));
+ Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true));
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, true));
+ Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), true));
+ Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true));
+
+ final GLContext ctx1 = f1.getContext();
+ final GLContext ctx2 = f2.getContext();
+ final GLContext ctx3 = f3.getContext();
+ {
+ final List ctx1Shares = ctx1.getCreatedShares();
+ final List ctx2Shares = ctx2.getCreatedShares();
+ final List ctx3Shares = ctx3.getCreatedShares();
+ System.err.println("XXX-C-3.1:");
+ MiscUtils.dumpSharedGLContext(ctx1);
+ System.err.println("XXX-C-3.2:");
+ MiscUtils.dumpSharedGLContext(ctx2);
+ System.err.println("XXX-C-3.3:");
+ MiscUtils.dumpSharedGLContext(ctx3);
+
+ Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
+ Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
+ Assert.assertTrue("Ctx3 is not shared", ctx3.isShared());
+ Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size());
+ Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size());
+ Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size());
+ }
+
+ Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears());
+ Assert.assertTrue("Gears2 is not shared", g2.usesSharedGears());
+ Assert.assertTrue("Gears3 is not shared", g3.usesSharedGears());
+
+ try {
+ Thread.sleep(duration);
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ a1.stop();
+ a2.stop();
+ a3.stop();
+
+ f1.destroy();
+ f2.destroy();
+ f3.destroy();
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false));
+ }
+
+ static long duration = 1000; // ms
+
+ public static void main(String args[]) {
+ for(int i=0; i0; w-=100) {
+ Thread.sleep(100);
+ }
+ } else {
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ demo.tabbedPanel.setSelectedIndex(0);
+ }});
+ Thread.sleep(durationPerTest/4);
+
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ demo.tabbedPanel.setSelectedIndex(1);
+ }});
+ Thread.sleep(durationPerTest/4);
+
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ demo.tabbedPanel.setSelectedIndex(0);
+ }});
+ Thread.sleep(durationPerTest/4);
+
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ demo.tabbedPanel.setSelectedIndex(1);
+ }});
+ Thread.sleep(durationPerTest/4);
+ }
+
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ System.err.println("XXX SetVisible XXX");
+ f.dispose();
+ } });
+ }
+
+ public static void main(String args[]) {
+ for(int i=0; i
- * Test utilizes {@link GLEventListenerState} for preserving the
- * GLAutoDrawable state, i.e. GLContext, all GLEventListener
+ * Test utilizes {@link GLEventListenerState} for preserving the
+ * GLAutoDrawable state, i.e. GLContext, all GLEventListener
* and the GLAnimatorControl association.
*
*
@@ -70,7 +70,7 @@ import org.junit.BeforeClass;
*/
public abstract class GLContextDrawableSwitchBase extends UITestCase {
static protected enum GLADType { GLCanvasOnscreen, GLCanvasOffscreen, GLWindow, GLOffscreen };
-
+
// default period for 1 GLAD cycle
static long duration = 1000; // ms
@@ -83,7 +83,7 @@ public abstract class GLContextDrawableSwitchBase extends UITestCase {
}
return new GLCapabilities(GLProfile.get(profile));
}
-
+
@BeforeClass
public static void initClass() {
width = 256;
@@ -101,37 +101,37 @@ public abstract class GLContextDrawableSwitchBase extends UITestCase {
} catch( Throwable throwable ) {
throwable.printStackTrace();
Assume.assumeNoException( throwable );
- }
+ }
}
-
+
static void setFrameVisible(final Frame frame) throws InterruptedException {
try {
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
frame.pack();
- frame.setVisible(true);
- }});
+ frame.setVisible(true);
+ }});
} catch( Throwable throwable ) {
throwable.printStackTrace();
Assume.assumeNoException( throwable );
}
}
-
+
static void destroyFrame(final Frame frame) throws InterruptedException {
try {
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
frame.dispose();
- }});
+ }});
} catch( Throwable throwable ) {
throwable.printStackTrace();
Assume.assumeNoException( throwable );
- }
+ }
}
-
+
private GLOffscreenAutoDrawable createGLOffscreenAutoDrawable(GLCapabilities caps, int width, int height) throws InterruptedException {
final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile());
- return factory.createOffscreenAutoDrawable(null, caps, null, width, height, null);
+ return factory.createOffscreenAutoDrawable(null, caps, null, width, height);
}
protected static boolean validateOnOffscreenLayer(GLADType gladType1, GLADType gladType2) {
@@ -150,37 +150,37 @@ public abstract class GLContextDrawableSwitchBase extends UITestCase {
}
return true;
}
-
- protected void testGLADOneLifecycle(Screen screen, GLCapabilities caps, GLADType gladType, int width,
+
+ protected void testGLADOneLifecycle(Screen screen, GLCapabilities caps, GLADType gladType, int width,
int height, GLEventListenerCounter glelTracker,
- SnapshotGLEventListener snapshotGLEventListener, final GLEventListenerState glelsIn, final GLEventListenerState glelsOut[], GLAnimatorControl animator)
+ SnapshotGLEventListener snapshotGLEventListener, final GLEventListenerState glelsIn, final GLEventListenerState glelsOut[], GLAnimatorControl animator)
throws InterruptedException {
-
+
System.err.println("GLAD Lifecycle.0 "+gladType+", restoring "+((null!=glelsIn)?true:false)+", preserving "+((null!=glelsOut)?true:false));
final Frame frame;
final GLAutoDrawable glad;
- if( GLADType.GLCanvasOnscreen == gladType ) {
+ if( GLADType.GLCanvasOnscreen == gladType ) {
if( jogamp.nativewindow.jawt.JAWTUtil.isOffscreenLayerRequired() ) {
throw new InternalError("Platform requires offscreen rendering, but onscreen requested: "+gladType);
}
frame = new Frame("AWT GLCanvas");
-
+
glad = new GLCanvas(caps);
setGLCanvasSize((GLCanvas)glad, new Dimension(width, height));
frame.add((GLCanvas)glad);
- } else if( GLADType.GLCanvasOffscreen == gladType ) {
+ } else if( GLADType.GLCanvasOffscreen == gladType ) {
if( !jogamp.nativewindow.jawt.JAWTUtil.isOffscreenLayerSupported() ) {
throw new InternalError("Platform doesn't support offscreen rendering: "+gladType);
}
frame = new Frame("AWT GLCanvas");
-
+
glad = new GLCanvas(caps);
((GLCanvas)glad).setShallUseOffscreenLayer(true);
setGLCanvasSize((GLCanvas)glad, new Dimension(width, height));
frame.add((GLCanvas)glad);
} else if( GLADType.GLWindow == gladType ) {
frame = null;
-
+
if( null != screen ) {
glad = GLWindow.create(screen, caps);
} else {
@@ -190,60 +190,60 @@ public abstract class GLContextDrawableSwitchBase extends UITestCase {
((GLWindow)glad).setSize(width, height);
} else if( GLADType.GLOffscreen == gladType ) {
frame = null;
-
+
glad = this.createGLOffscreenAutoDrawable(caps, width, height);
} else {
throw new InternalError("Unsupported: "+gladType);
}
-
+
if( null == glelsIn ) {
if( null != animator ) {
animator.add(glad);
}
glad.addGLEventListener(glelTracker);
glad.addGLEventListener(new GearsES2(1));
- glad.addGLEventListener(snapshotGLEventListener);
+ glad.addGLEventListener(snapshotGLEventListener);
}
snapshotGLEventListener.setMakeSnapshot();
-
- if( GLADType.GLCanvasOnscreen == gladType || GLADType.GLCanvasOffscreen == gladType ) {
- setFrameVisible(frame);
+
+ if( GLADType.GLCanvasOnscreen == gladType || GLADType.GLCanvasOffscreen == gladType ) {
+ setFrameVisible(frame);
Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true));
} else if( GLADType.GLWindow == gladType ) {
((GLWindow)glad).setVisible(true);
- }
- Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glad, true));
+ }
+ Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glad, true));
Assert.assertNotNull(glad.getContext());
Assert.assertTrue(glad.isRealized());
-
+
if( null != glelsIn ) {
Assert.assertEquals(0, glad.getGLEventListenerCount());
System.err.println(".. restoring.0");
- glelsIn.moveTo(glad);
+ glelsIn.moveTo(glad);
System.err.println(".. restoring.X");
-
+
Assert.assertEquals(1, glelTracker.initCount);
Assert.assertTrue(1 <= glelTracker.reshapeCount);
Assert.assertTrue(1 <= glelTracker.displayCount);
Assert.assertEquals(0, glelTracker.disposeCount);
Assert.assertEquals(3, glad.getGLEventListenerCount());
-
+
Assert.assertEquals(glelsIn.context, glad.getContext());
Assert.assertEquals(glelsIn.listenerCount(), glad.getGLEventListenerCount());
Assert.assertEquals(glelsIn.context.getGLReadDrawable(), glad.getDelegatedDrawable());
Assert.assertEquals(glelsIn.context.getGLDrawable(), glad.getDelegatedDrawable());
Assert.assertEquals(false, glelsIn.isOwner());
}
-
- for (int wait=0; wait glelTracker.initCount || 1 > glelTracker.reshapeCount || 1 > glelTracker.displayCount );
wait++) {
Thread.sleep(AWTRobotUtil.TIME_SLICE);
}
-
+
final long t0 = System.currentTimeMillis();
long t1 = t0;
-
+
while( ( t1 - t0 ) < duration ) {
Thread.sleep(100);
t1 = System.currentTimeMillis();
@@ -253,13 +253,13 @@ public abstract class GLContextDrawableSwitchBase extends UITestCase {
Assert.assertTrue(1 <= glelTracker.reshapeCount);
Assert.assertTrue(1 <= glelTracker.displayCount);
Assert.assertEquals(0, glelTracker.disposeCount);
-
+
if( null != glelsOut ) {
final GLContext context1 = glad.getContext();
System.err.println(".. preserving.0");
glelsOut[0] = GLEventListenerState.moveFrom(glad);
System.err.println(".. preserving.X");
-
+
Assert.assertEquals(context1, glelsOut[0].context);
Assert.assertNull(context1.getGLReadDrawable());
Assert.assertNull(context1.getGLDrawable());
@@ -276,8 +276,8 @@ public abstract class GLContextDrawableSwitchBase extends UITestCase {
} else if( GLADType.GLOffscreen == gladType ) {
glad.destroy();
}
- Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glad, false));
-
+ Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glad, false));
+
Assert.assertEquals(1, glelTracker.initCount);
Assert.assertTrue(1 <= glelTracker.reshapeCount);
Assert.assertTrue(1 <= glelTracker.displayCount);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch02AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch02AWT.java
index e568f87a1..316199d07 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch02AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch02AWT.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,12 +20,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.opengl.test.junit.jogl.acore.glels;
import java.awt.BorderLayout;
@@ -71,7 +71,7 @@ public class TestGLContextDrawableSwitch02AWT extends UITestCase {
}
return new GLCapabilities(GLProfile.get(profile));
}
-
+
@BeforeClass
public static void initClass() {
width = 256;
@@ -82,13 +82,13 @@ public class TestGLContextDrawableSwitch02AWT extends UITestCase {
final GLAutoDrawable glad;
if( caps.isOnscreen() ) {
GLCanvas glCanvas = new GLCanvas(caps);
- Assert.assertNotNull(glCanvas);
+ Assert.assertNotNull(glCanvas);
Dimension glc_sz = new Dimension(width, height);
glCanvas.setMinimumSize(glc_sz);
glCanvas.setPreferredSize(glc_sz);
glCanvas.setSize(glc_sz);
glad = glCanvas;
-
+
frame.setLayout(new BorderLayout());
frame.add(glCanvas, BorderLayout.CENTER);
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
@@ -96,48 +96,48 @@ public class TestGLContextDrawableSwitch02AWT extends UITestCase {
frame.pack();
frame.setVisible(true);
}});
-
- } else {
+
+ } else {
final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile());
- glad = factory.createOffscreenAutoDrawable(null, caps, null, width, height, null);
+ glad = factory.createOffscreenAutoDrawable(null, caps, null, width, height);
Assert.assertNotNull(glad);
}
return glad;
}
-
+
@Test(timeout=30000)
public void testSwitch2AWTGLCanvas2OffscreenGL2ES2() throws InterruptedException, InvocationTargetException {
final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2);
if(null == reqGLCaps) return;
testSwitch2AWTGLCanvas2OffscreenImpl(reqGLCaps);
}
-
+
private void testSwitch2AWTGLCanvas2OffscreenImpl(GLCapabilities capsOnscreen) throws InterruptedException, InvocationTargetException {
final GLCapabilities capsOffscreen = (GLCapabilities) capsOnscreen.clone();
capsOffscreen.setOnscreen(false);
-
+
final QuitAdapter quitAdapter = new QuitAdapter();
-
+
final Frame frame = new Frame("Gears AWT Test");
Assert.assertNotNull(frame);
new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame);
-
+
GLAutoDrawable glCanvas = createGLAutoDrawable(frame, capsOnscreen, width, height);
-
- final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener();
+
+ final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener();
GearsES2 gears = new GearsES2(1);
glCanvas.addGLEventListener(gears);
glCanvas.addGLEventListener(snapshotGLEventListener);
snapshotGLEventListener.setMakeSnapshot();
-
+
Animator animator = new Animator();
animator.add(glCanvas);
animator.start();
-
+
int s = 0;
long t0 = System.currentTimeMillis();
long t1 = t0;
-
+
GLAutoDrawable glOffscreen = createGLAutoDrawable(null, capsOffscreen, width, height);
while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration ) {
if( ( t1 - t0 ) / period > s) {
@@ -147,8 +147,8 @@ public class TestGLContextDrawableSwitch02AWT extends UITestCase {
// switch context _and_ the demo synchronously
GLDrawableUtil.swapGLContextAndAllGLEventListener(glCanvas, glOffscreen);
snapshotGLEventListener.setMakeSnapshot();
-
- System.err.println(s+" - switch - END "+ ( t1 - t0 ));
+
+ System.err.println(s+" - switch - END "+ ( t1 - t0 ));
}
Thread.sleep(100);
t1 = System.currentTimeMillis();
@@ -157,14 +157,14 @@ public class TestGLContextDrawableSwitch02AWT extends UITestCase {
animator.stop();
// glCanvas.destroy();
glOffscreen.destroy();
-
+
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
final Frame _frame = frame;
_frame.dispose();
}});
}
-
+
// default timing for 2 switches
static long duration = 2900; // ms
static long period = 1000; // ms
@@ -186,7 +186,7 @@ public class TestGLContextDrawableSwitch02AWT extends UITestCase {
/**
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
System.err.println("Press enter to continue");
- System.err.println(stdin.readLine()); */
+ System.err.println(stdin.readLine()); */
org.junit.runner.JUnitCore.main(TestGLContextDrawableSwitch02AWT.class.getName());
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461FBOSupersamplingSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461FBOSupersamplingSwingAWT.java
index 033e55da3..96ec8ab75 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461FBOSupersamplingSwingAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461FBOSupersamplingSwingAWT.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,7 +20,7 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
@@ -31,7 +31,7 @@ package com.jogamp.opengl.test.junit.jogl.awt;
import java.awt.Container;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
-
+
import java.awt.image.BufferedImage;
import java.lang.reflect.InvocationTargetException;
@@ -68,11 +68,11 @@ public class TestBug461FBOSupersamplingSwingAWT extends UITestCase implements GL
JFrame jframe;
GLOffscreenAutoDrawable offScreenBuffer;
AWTGLReadBufferUtil awtGLReadBufferUtil;
-
+
private void render(GLAutoDrawable drawable) {
GL2 gl = drawable.getGL().getGL2();
Assert.assertNotNull(gl);
- gl.glClear(GL.GL_COLOR_BUFFER_BIT);
+ gl.glClear(GL.GL_COLOR_BUFFER_BIT);
// draw a triangle filling the window
gl.glBegin(GL.GL_TRIANGLES);
@@ -84,7 +84,7 @@ public class TestBug461FBOSupersamplingSwingAWT extends UITestCase implements GL
gl.glVertex2d(1, -1);
gl.glEnd();
}
-
+
/* @Override */
public void init(GLAutoDrawable drawable) {
awtGLReadBufferUtil = new AWTGLReadBufferUtil(drawable.getGLProfile(), false);
@@ -92,16 +92,16 @@ public class TestBug461FBOSupersamplingSwingAWT extends UITestCase implements GL
/* @Override */
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
- }
-
+ }
+
/* @Override */
- public void display(GLAutoDrawable drawable) {
+ public void display(GLAutoDrawable drawable) {
render(offScreenBuffer);
// BufferedImage outputImage = com.jogamp.opengl.util.awt.Screenshot.readToBufferedImage(200, 200, false);
BufferedImage outputImage = awtGLReadBufferUtil.readPixelsToBufferedImage(drawable.getGL(), 0, 0, 200, 200, true /* awtOrientation */);
Assert.assertNotNull(outputImage);
ImageIcon imageIcon = new ImageIcon(outputImage);
- final JLabel imageLabel = new JLabel(imageIcon);
+ final JLabel imageLabel = new JLabel(imageIcon);
try {
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
@@ -116,7 +116,7 @@ public class TestBug461FBOSupersamplingSwingAWT extends UITestCase implements GL
}
/* @Override */
- public void dispose(GLAutoDrawable drawable) {
+ public void dispose(GLAutoDrawable drawable) {
try {
awtGLReadBufferUtil.dispose(drawable.getGL());
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
@@ -141,29 +141,29 @@ public class TestBug461FBOSupersamplingSwingAWT extends UITestCase implements GL
GLProfile glp = GLProfile.get(GLProfile.GL2);
Assert.assertNotNull(glp);
-
+
GLDrawableFactory fac = GLDrawableFactory.getFactory(glp);
Assert.assertNotNull(fac);
-
+
Assert.assertTrue( fac.canCreateGLPbuffer(GLProfile.getDefaultDevice(), glp) );
-
+
GLCapabilities glCap = new GLCapabilities(glp);
Assert.assertNotNull(glCap);
-
- // COMMENTING OUT THIS LINE FIXES THE ISSUE.
+
+ // COMMENTING OUT THIS LINE FIXES THE ISSUE.
// Setting this in JOGL1 works. Thus this is a JOGL2 issue.
glCap.setSampleBuffers(true);
-
+
// Without line below, there is an error on Windows.
// glCap.setDoubleBuffered(false); // implicit double buffer -> MSAA + FBO
-
+
// Needed for drop shadows
glCap.setStencilBits(1);
//makes a new buffer
- offScreenBuffer = fac.createOffscreenAutoDrawable(GLProfile.getDefaultDevice(), glCap, null, 200, 200, null);
+ offScreenBuffer = fac.createOffscreenAutoDrawable(GLProfile.getDefaultDevice(), glCap, null, 200, 200);
Assert.assertNotNull(offScreenBuffer);
- offScreenBuffer.addGLEventListener(this);
+ offScreenBuffer.addGLEventListener(this);
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
jframe.setSize( 300, 300);
@@ -171,7 +171,7 @@ public class TestBug461FBOSupersamplingSwingAWT extends UITestCase implements GL
}});
offScreenBuffer.display(); // read from front buffer due to FBO+MSAA -> double-buffer
offScreenBuffer.display(); // now we have prev. image in front buffer to be read out
-
+
Thread.sleep(durationPerTest);
offScreenBuffer.destroy();
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageAWT.java
index 89470a922..e87c34419 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageAWT.java
@@ -132,7 +132,7 @@ public class TestBug605FlippedImageAWT extends UITestCase {
private void test(GLCapabilitiesImmutable caps) {
final GLDrawableFactory glFactory = GLDrawableFactory.getFactory(caps.getGLProfile());
- final GLAutoDrawable glad = glFactory.createOffscreenAutoDrawable(null, caps, null, 256, 256, null);
+ final GLAutoDrawable glad = glFactory.createOffscreenAutoDrawable(null, caps, null, 256, 256);
final FlippedImageTest tglel = new FlippedImageTest();
glad.addGLEventListener(tglel);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageNEWT.java
index 8d4710ad3..28fcb9885 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageNEWT.java
@@ -119,7 +119,7 @@ public class TestBug605FlippedImageNEWT extends UITestCase {
private void test(GLCapabilitiesImmutable caps) {
final GLReadBufferUtil rbu = new GLReadBufferUtil(false, false);
final GLDrawableFactory glFactory = GLDrawableFactory.getFactory(caps.getGLProfile());
- final GLAutoDrawable glad = glFactory.createOffscreenAutoDrawable(null, caps, null, 256, 256, null);
+ final GLAutoDrawable glad = glFactory.createOffscreenAutoDrawable(null, caps, null, 256, 256);
final FlippedImageTest tglel = new FlippedImageTest();
glad.addGLEventListener(tglel);
final SnapshotGLEventListener snap = new SnapshotGLEventListener(rbu);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java
index 521224c01..ba93dcdcd 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java
@@ -1,22 +1,22 @@
/*
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Copyright (c) 2010 JogAmp Community. All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
- *
+ *
* - Redistribution of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* - Redistribution in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* Neither the name of Sun Microsystems, Inc. or the names of
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
- *
+ *
* This software is provided "AS IS," without a warranty of any kind. ALL
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
* INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
@@ -29,11 +29,11 @@
* DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
* SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
+ *
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
- *
+ *
* Sun gratefully acknowledges that this software was originally authored
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
@@ -104,7 +104,7 @@ public class TestMultisampleES1AWT extends UITestCase {
caps.setNumSamples(reqSamples);
}
- canvas = new GLCanvas(caps, chooser, null, null);
+ canvas = new GLCanvas(caps, chooser, null);
canvas.addGLEventListener(new MultisampleDemoES1(reqSamples>0?true:false));
canvas.addGLEventListener(new GLEventListener() {
int displayCount = 0;
@@ -115,7 +115,7 @@ public class TestMultisampleES1AWT extends UITestCase {
}
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { }
});
-
+
final Frame frame = new Frame("Multi Samples "+reqSamples);
frame.setLayout(new BorderLayout());
canvas.setSize(512, 512);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java
index 63e89952f..db1f217ba 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java
@@ -7,10 +7,10 @@
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
- *
+ *
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
@@ -55,16 +55,18 @@ public class GearsES1 implements GLEventListener {
private boolean forceFFPEmu = false;
private boolean debug = false ;
private boolean trace = false ;
-
+
private final float pos[] = { 5.0f, 5.0f, 10.0f, 0.0f };
- private float view_rotx = 20.0f, view_roty = 30.0f, view_rotz = 0.0f;
+ private float view_rotx = 20.0f, view_roty = 30.0f;
+ private final float view_rotz = 0.0f;
private GearsObject gear1=null, gear2=null, gear3=null;
private FloatBuffer gear1Color=GearsObject.red, gear2Color=GearsObject.green, gear3Color=GearsObject.blue;
+ private volatile boolean usesSharedGears = false;
private float angle = 0.0f;
- private int swapInterval;
- private MouseListener gearsMouse = new GearsMouseAdapter();
- private KeyListener gearsKeys = new GearsKeyAdapter();
+ private final int swapInterval;
+ private final MouseListener gearsMouse = new GearsMouseAdapter();
+ private final KeyListener gearsKeys = new GearsKeyAdapter();
private int prevMouseX, prevMouseY;
@@ -76,21 +78,21 @@ public class GearsES1 implements GLEventListener {
public GearsES1() {
this.swapInterval = 1;
}
-
+
public void setForceFFPEmu(boolean forceFFPEmu, boolean verboseFFPEmu, boolean debugFFPEmu, boolean traceFFPEmu) {
this.forceFFPEmu = forceFFPEmu;
this.verboseFFPEmu = verboseFFPEmu;
this.debugFFPEmu = debugFFPEmu;
this.traceFFPEmu = traceFFPEmu;
}
-
+
public void setGearsColors(FloatBuffer gear1Color, FloatBuffer gear2Color, FloatBuffer gear3Color) {
this.gear1Color = gear1Color;
this.gear2Color = gear2Color;
this.gear3Color = gear3Color;
}
-
- public void setGears(GearsObject g1, GearsObject g2, GearsObject g3) {
+
+ public void setSharedGearsObjects(GearsObject g1, GearsObject g2, GearsObject g3) {
gear1 = g1;
gear2 = g2;
gear3 = g3;
@@ -110,15 +112,17 @@ public class GearsES1 implements GLEventListener {
* @return gear3
*/
public GearsObject getGear3() { return gear3; }
-
+
+ public boolean usesSharedGears() { return usesSharedGears; }
+
public void init(GLAutoDrawable drawable) {
System.err.println(Thread.currentThread()+" GearsES1.init ...");
-
+
// Use debug pipeline
// drawable.setGL(new DebugGL(drawable.getGL()));
GL _gl = drawable.getGL();
-
+
if(debugFFPEmu) {
// Debug ..
_gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", GL2ES2.class, _gl, null) );
@@ -130,12 +134,12 @@ public class GearsES1 implements GLEventListener {
trace = false;
}
GL2ES1 gl = FixedFuncUtil.wrapFixedFuncEmul(_gl, ShaderSelectionMode.AUTO, null, forceFFPEmu, verboseFFPEmu);
-
+
if(debug) {
try {
// Debug ..
gl = (GL2ES1) gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", GL2ES1.class, gl, null) );
- } catch (Exception e) {e.printStackTrace();}
+ } catch (Exception e) {e.printStackTrace();}
}
if(trace) {
try {
@@ -143,7 +147,7 @@ public class GearsES1 implements GLEventListener {
gl = (GL2ES1) gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", GL2ES1.class, gl, new Object[] { System.err } ) );
} catch (Exception e) {e.printStackTrace();}
}
-
+
System.err.println("GearsES1 init on "+Thread.currentThread());
System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities());
System.err.println("INIT GL IS: " + gl.getClass().getName());
@@ -154,33 +158,36 @@ public class GearsES1 implements GLEventListener {
gl.glEnable(GL2ES1.GL_LIGHTING);
gl.glEnable(GL2ES1.GL_LIGHT0);
gl.glEnable(GL2ES1.GL_DEPTH_TEST);
-
+
/* make the gears */
if(null == gear1) {
gear1 = new GearsObjectES1(gear1Color, 1.0f, 4.0f, 1.0f, 20, 0.7f);
System.err.println("gear1 created: "+gear1);
} else {
+ usesSharedGears = true;
System.err.println("gear1 reused: "+gear1);
}
-
+
if(null == gear2) {
gear2 = new GearsObjectES1(gear2Color, 0.5f, 2.0f, 2.0f, 10, 0.7f);
System.err.println("gear2 created: "+gear2);
} else {
+ usesSharedGears = true;
System.err.println("gear2 reused: "+gear2);
}
-
+
if(null == gear3) {
gear3 = new GearsObjectES1(gear3Color, 1.3f, 2.0f, 0.5f, 10, 0.7f);
System.err.println("gear3 created: "+gear3);
} else {
+ usesSharedGears = true;
System.err.println("gear3 reused: "+gear3);
}
-
+
gl.glEnable(GL2ES1.GL_NORMALIZE);
-
+
final Object upstreamWidget = drawable.getUpstreamWidget();
- if (upstreamWidget instanceof Window) {
+ if (upstreamWidget instanceof Window) {
final Window window = (Window) upstreamWidget;
window.addMouseListener(gearsMouse);
window.addKeyListener(gearsKeys);
@@ -191,7 +198,7 @@ public class GearsES1 implements GLEventListener {
}
System.err.println(Thread.currentThread()+" GearsES1.init FIN");
}
-
+
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
System.err.println(Thread.currentThread()+" GearsES1.reshape "+x+"/"+y+" "+width+"x"+height+", swapInterval "+swapInterval);
GL2ES1 gl = drawable.getGL().getGL2ES1();
@@ -217,7 +224,7 @@ public class GearsES1 implements GLEventListener {
public void dispose(GLAutoDrawable drawable) {
System.err.println(Thread.currentThread()+" GearsES1.dispose ... ");
final Object upstreamWidget = drawable.getUpstreamWidget();
- if (upstreamWidget instanceof Window) {
+ if (upstreamWidget instanceof Window) {
final Window window = (Window) upstreamWidget;
window.removeMouseListener(gearsMouse);
window.removeKeyListener(gearsKeys);
@@ -232,7 +239,7 @@ public class GearsES1 implements GLEventListener {
System.err.println(Thread.currentThread()+" GearsES1.dispose FIN");
}
- public void display(GLAutoDrawable drawable) {
+ public void display(GLAutoDrawable drawable) {
// Turn the gears' teeth
angle += 2.0f;
@@ -251,10 +258,10 @@ public class GearsES1 implements GLEventListener {
} else {
gl.glClearColor(0.2f, 0.2f, 0.2f, 0.0f);
}
-
+
// Special handling for the case where the GLJPanel is translucent
// and wants to be composited with other Java 2D content
- if (GLProfile.isAWTAvailable() &&
+ if (GLProfile.isAWTAvailable() &&
(drawable instanceof javax.media.opengl.awt.GLJPanel) &&
!((javax.media.opengl.awt.GLJPanel) drawable).isOpaque() &&
((javax.media.opengl.awt.GLJPanel) drawable).shouldPreserveColorBufferIfTranslucent()) {
@@ -264,25 +271,25 @@ public class GearsES1 implements GLEventListener {
}
gl.glNormal3f(0.0f, 0.0f, 1.0f);
-
+
// Rotate the entire assembly of gears based on how the user
// dragged the mouse around
gl.glPushMatrix();
gl.glRotatef(view_rotx, 1.0f, 0.0f, 0.0f);
gl.glRotatef(view_roty, 0.0f, 1.0f, 0.0f);
gl.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f);
-
- gear1.draw(gl, -3.0f, -2.0f, angle);
- gear2.draw(gl, 3.1f, -2.0f, -2.0f * angle - 9.0f);
+
+ gear1.draw(gl, -3.0f, -2.0f, angle);
+ gear2.draw(gl, 3.1f, -2.0f, -2.0f * angle - 9.0f);
gear3.draw(gl, -3.1f, 4.2f, -2.0f * angle - 25.0f);
-
+
// Remember that every push needs a pop; this one is paired with
// rotating the entire gear assembly
gl.glPopMatrix();
}
-
- class GearsKeyAdapter extends KeyAdapter {
+
+ class GearsKeyAdapter extends KeyAdapter {
public void keyPressed(KeyEvent e) {
int kc = e.getKeyCode();
if(KeyEvent.VK_LEFT == kc) {
@@ -296,16 +303,16 @@ public class GearsES1 implements GLEventListener {
}
}
}
-
+
class GearsMouseAdapter extends MouseAdapter {
public void mousePressed(MouseEvent e) {
prevMouseX = e.getX();
prevMouseY = e.getY();
}
-
+
public void mouseReleased(MouseEvent e) {
}
-
+
public void mouseDragged(MouseEvent e) {
int x = e.getX();
int y = e.getY();
@@ -324,7 +331,7 @@ public class GearsES1 implements GLEventListener {
}
float thetaY = 360.0f * ( (float)(x-prevMouseX)/(float)width);
float thetaX = 360.0f * ( (float)(prevMouseY-y)/(float)height);
-
+
prevMouseX = x;
prevMouseY = y;
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java
index 9817ea57f..60242d604 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java
@@ -45,6 +45,7 @@ import javax.media.opengl.GL;
import javax.media.opengl.GL2ES2;
import javax.media.opengl.GLAnimatorControl;
import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLContext;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLProfile;
import javax.media.opengl.GLUniformData;
@@ -64,7 +65,9 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL
private final float view_rotz = 0.0f;
private float panX = 0.0f, panY = 0.0f, panZ=0.0f;
- private GearsObjectES2 gear1=null, gear2=null, gear3=null;
+ private volatile GearsObjectES2 gear1=null, gear2=null, gear3=null;
+ private GearsES2 sharedGears = null;
+ private volatile boolean usesSharedGears = false;
private FloatBuffer gear1Color=GearsObject.red, gear2Color=GearsObject.green, gear3Color=GearsObject.blue;
private float angle = 0.0f;
private int swapInterval = 0;
@@ -80,6 +83,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL
private float[] clearColor = null;
private boolean clearBuffers = true;
private boolean verbose = true;
+ private volatile boolean isInit = false;
private PinchToZoomGesture pinchToZoomGesture = null;
@@ -132,12 +136,16 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL
this.gear3Color = gear3Color;
}
- public void setGears(GearsObjectES2 g1, GearsObjectES2 g2, GearsObjectES2 g3) {
+ public void setSharedGearsObjects(GearsObjectES2 g1, GearsObjectES2 g2, GearsObjectES2 g3) {
gear1 = g1;
gear2 = g2;
gear3 = g3;
}
+ public void setSharedGears(GearsES2 shared) {
+ sharedGears = shared;
+ }
+
/**
* @return gear1
*/
@@ -153,12 +161,33 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL
*/
public GearsObjectES2 getGear3() { return gear3; }
+ public boolean usesSharedGears() { return usesSharedGears; }
+
+ private static final int TIME_OUT = 2000; // 2s
+ private static final int POLL_DIVIDER = 20; // TO/20
+ private static final int TIME_SLICE = TIME_OUT / POLL_DIVIDER ;
+
+ /**
+ * @return True if this GLEventListener became initialized within TIME_OUT 2s
+ */
+ public boolean waitForInit(boolean initialized) throws InterruptedException {
+ int wait;
+ for (wait=0; wait "+gear1);
+ System.err.println("gear2 created w/ share: "+sharedGears.getGear2()+" -> "+gear2);
+ System.err.println("gear3 created w/ share: "+sharedGears.getGear3()+" -> "+gear3);
+ }
} else {
- gear1 = new GearsObjectES2(gear1, st, pmvMatrix, pmvMatrixUniform, colorU);
- if(verbose) {
- System.err.println("gear1 reused: "+gear1);
+ if(null == gear1) {
+ gear1 = new GearsObjectES2(st, gear1Color, 1.0f, 4.0f, 1.0f, 20, 0.7f, pmvMatrix, pmvMatrixUniform, colorU);
+ if(verbose) {
+ System.err.println("gear1 created: "+gear1);
+ }
+ } else {
+ final GearsObjectES2 _gear1 = gear1;
+ gear1 = new GearsObjectES2(_gear1, st, pmvMatrix, pmvMatrixUniform, colorU);
+ usesSharedGears = true;
+ if(verbose) {
+ System.err.println("gear1 created w/ share: "+_gear1+" -> "+gear1);
+ }
}
- }
- if(null == gear2) {
- gear2 = new GearsObjectES2(st, gear2Color, 0.5f, 2.0f, 2.0f, 10, 0.7f, pmvMatrix, pmvMatrixUniform, colorU);
- if(verbose) {
- System.err.println("gear2 created: "+gear2);
- }
- } else {
- gear2 = new GearsObjectES2(gear2, st, pmvMatrix, pmvMatrixUniform, colorU);
- if(verbose) {
- System.err.println("gear2 reused: "+gear2);
+ if(null == gear2) {
+ gear2 = new GearsObjectES2(st, gear2Color, 0.5f, 2.0f, 2.0f, 10, 0.7f, pmvMatrix, pmvMatrixUniform, colorU);
+ if(verbose) {
+ System.err.println("gear2 created: "+gear2);
+ }
+ } else {
+ final GearsObjectES2 _gear2 = gear2;
+ gear2 = new GearsObjectES2(_gear2, st, pmvMatrix, pmvMatrixUniform, colorU);
+ usesSharedGears = true;
+ if(verbose) {
+ System.err.println("gear2 created w/ share: "+_gear2+" -> "+gear2);
+ }
}
- }
- if(null == gear3) {
- gear3 = new GearsObjectES2(st, gear3Color, 1.3f, 2.0f, 0.5f, 10, 0.7f, pmvMatrix, pmvMatrixUniform, colorU);
- if(verbose) {
- System.err.println("gear3 created: "+gear3);
- }
- } else {
- gear3 = new GearsObjectES2(gear3, st, pmvMatrix, pmvMatrixUniform, colorU);
- if(verbose) {
- System.err.println("gear3 reused: "+gear3);
+ if(null == gear3) {
+ gear3 = new GearsObjectES2(st, gear3Color, 1.3f, 2.0f, 0.5f, 10, 0.7f, pmvMatrix, pmvMatrixUniform, colorU);
+ if(verbose) {
+ }
+ } else {
+ final GearsObjectES2 _gear3 = gear3;
+ gear3 = new GearsObjectES2(_gear3, st, pmvMatrix, pmvMatrixUniform, colorU);
+ usesSharedGears = true;
+ if(verbose) {
+ System.err.println("gear3 created w/ share: "+_gear3+" -> "+gear3);
+ }
}
}
@@ -254,6 +300,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL
st.useProgram(gl, false);
System.err.println(Thread.currentThread()+" GearsES2.init FIN");
+ isInit = true;
}
private final GestureHandler.GestureListener pinchToZoomListener = new GestureHandler.GestureListener() {
@@ -267,6 +314,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL
@Override
public void reshape(GLAutoDrawable glad, int x, int y, int width, int height) {
+ if( !isInit ) { return; }
final GL2ES2 gl = glad.getGL().getGL2ES2();
if(-1 != swapInterval) {
gl.setSwapInterval(swapInterval);
@@ -278,6 +326,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL
public void reshapeTile(TileRendererBase tr,
int tileX, int tileY, int tileWidth, int tileHeight,
int imageWidth, int imageHeight) {
+ if( !isInit ) { return; }
final GL2ES2 gl = tr.getAttachedDrawable().getGL().getGL2ES2();
gl.setSwapInterval(0);
reshapeImpl(gl, tileX, tileY, tileWidth, tileHeight, imageWidth, imageHeight);
@@ -339,6 +388,8 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL
@Override
public void dispose(GLAutoDrawable drawable) {
+ if( !isInit ) { return; }
+ isInit = false;
System.err.println(Thread.currentThread()+" GearsES2.dispose: tileRendererInUse "+tileRendererInUse);
final Object upstreamWidget = drawable.getUpstreamWidget();
if (upstreamWidget instanceof Window) {
@@ -370,6 +421,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL
@Override
public void display(GLAutoDrawable drawable) {
+ if( !isInit ) { return; }
GLAnimatorControl anim = drawable.getAnimator();
if( verbose && ( null == anim || !anim.isAnimating() ) ) {
System.err.println(Thread.currentThread()+" GearsES2.display "+drawable.getWidth()+"x"+drawable.getHeight()+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(drawable.getHandle()));
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestBug365TextureGenerateMipMaps.java b/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestBug365TextureGenerateMipMaps.java
index 4d9b750c4..b9e64e1da 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestBug365TextureGenerateMipMaps.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestBug365TextureGenerateMipMaps.java
@@ -31,7 +31,7 @@ import com.jogamp.opengl.util.texture.TextureIO;
*
* Bug Reference: https://jogamp.org/bugzilla/show_bug.cgi?id=365
*
- * The bug pertains to mipmap generation from a Texture and exists in {@link ScaleInternal}
+ * The bug pertains to mipmap generation from a Texture and exists in {@link ScaleInternal}
* where a {@link java.nio.BufferUnderflowException} is thrown.
*
* This suite of test cases test:
@@ -43,14 +43,14 @@ import com.jogamp.opengl.util.texture.TextureIO;
* - {@link ScaleInternal#scale_internal_int(int, int, int, ByteBuffer, int, int, java.nio.IntBuffer, int, int, int, boolean)}
* - {@link ScaleInternal#scale_internal_float(int, int, int, ByteBuffer, int, int, java.nio.FloatBuffer, int, int, int, boolean)}
*
- *
+ *
* @author Michael Esemplare, et.al.
*
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestBug365TextureGenerateMipMaps extends UITestCase {
static GLOffscreenAutoDrawable drawable;
-
+
@BeforeClass
public static void setup() throws Throwable {
// disableNPOT
@@ -61,23 +61,21 @@ public class TestBug365TextureGenerateMipMaps extends UITestCase {
throw t;
}
}
-
+
@AfterClass
public static void teardown() {
tearDownOffscreenAutoDrawable();
}
-
+
private static void setUpOffscreenAutoDrawable() throws Throwable {
GLProfile glp = GLProfile.getDefault();
GLCapabilities caps = new GLCapabilities(glp);
-
+
GLDrawableFactory factory = GLDrawableFactory.getFactory(glp);
-
- // Make a drawable to get an offscreen context
- drawable = factory.createOffscreenAutoDrawable(null, caps, null, 2, 2, null);
-
- drawable.setRealized(true);
+ // Make a drawable to get an offscreen context
+ drawable = factory.createOffscreenAutoDrawable(null, caps, null, 2, 2);
+ drawable.display(); // trigger context creation
GLContext glContext = drawable.getContext();
try {
Assert.assertTrue("Could not make context current", GLContext.CONTEXT_NOT_CURRENT < glContext.makeCurrent());
@@ -86,7 +84,7 @@ public class TestBug365TextureGenerateMipMaps extends UITestCase {
throw t;
}
}
-
+
private static void tearDownOffscreenAutoDrawable() {
if(drawable != null) {
drawable.getContext().release();
@@ -94,30 +92,30 @@ public class TestBug365TextureGenerateMipMaps extends UITestCase {
drawable = null;
}
}
-
+
private static void testTextureMipMapGeneration(int width, int height, int pixelFormat, int pixelType) {
int internalFormat = pixelFormat;
int border = 0;
boolean mipmap = true;
boolean dataIsCompressed = false;
boolean mustFlipVertically = false;
-
+
int memReq = Mipmap.image_size( width, height, pixelFormat, pixelType );
ByteBuffer buffer = Buffers.newDirectByteBuffer( memReq );
-
- TextureData data = new TextureData(drawable.getGLProfile(),
- internalFormat,
- width,
- height,
- border,
- pixelFormat,
- pixelType,
- mipmap,
- dataIsCompressed,
- mustFlipVertically,
- buffer,
+
+ TextureData data = new TextureData(drawable.getGLProfile(),
+ internalFormat,
+ width,
+ height,
+ border,
+ pixelFormat,
+ pixelType,
+ mipmap,
+ dataIsCompressed,
+ mustFlipVertically,
+ buffer,
null);
-
+
Texture texture = TextureIO.newTexture(drawable.getGL(), data);
// Cleanup
texture.destroy(drawable.getGL());
@@ -125,144 +123,144 @@ public class TestBug365TextureGenerateMipMaps extends UITestCase {
buffer.clear();
buffer = null;
}
-
+
@Test
public void test00_MipMap_ScaleInternal_RGB_UBYTE () {
int width = 1;
int height = 7;
int pixelFormat = GL2.GL_RGB;
int pixelType = GL2.GL_UNSIGNED_BYTE;
-
+
testTextureMipMapGeneration(width, height, pixelFormat, pixelType);
}
-
+
@Test
public void test01_MipMap_ScaleInternal_RGBA_UBYTE () {
int width = 1;
int height = 7;
int pixelFormat = GL2.GL_RGBA;
int pixelType = GL2.GL_UNSIGNED_BYTE;
-
+
testTextureMipMapGeneration(width, height, pixelFormat, pixelType);
}
-
+
@Test
public void test02_MipMap_ScaleInternal_RGB_BYTE () {
int width = 1;
int height = 7;
int pixelFormat = GL2.GL_RGB;
int pixelType = GL2.GL_BYTE;
-
+
testTextureMipMapGeneration(width, height, pixelFormat, pixelType);
}
-
+
@Test
public void test03_MipMap_ScaleInternal_RGBA_BYTE () {
int width = 1;
int height = 7;
int pixelFormat = GL2.GL_RGBA;
int pixelType = GL2.GL_BYTE;
-
+
testTextureMipMapGeneration(width, height, pixelFormat, pixelType);
}
-
+
@Test
public void test04_MipMap_ScaleInternal_RGB_USHORT () {
int width = 1;
int height = 7;
int pixelFormat = GL2.GL_RGB;
int pixelType = GL2.GL_UNSIGNED_SHORT;
-
+
testTextureMipMapGeneration(width, height, pixelFormat, pixelType);
}
-
+
@Test
public void test05_MipMap_ScaleInternal_RGBA_USHORT () {
int width = 1;
int height = 7;
int pixelFormat = GL2.GL_RGBA;
int pixelType = GL2.GL_UNSIGNED_SHORT;
-
+
testTextureMipMapGeneration(width, height, pixelFormat, pixelType);
}
-
+
@Test
public void test06_MipMap_ScaleInternal_RGB_SHORT () {
int width = 1;
int height = 7;
int pixelFormat = GL2.GL_RGB;
int pixelType = GL2.GL_SHORT;
-
+
testTextureMipMapGeneration(width, height, pixelFormat, pixelType);
}
-
+
@Test
public void test07_MipMap_ScaleInternal_RGBA_SHORT () {
int width = 1;
int height = 7;
int pixelFormat = GL2.GL_RGBA;
int pixelType = GL2.GL_SHORT;
-
+
testTextureMipMapGeneration(width, height, pixelFormat, pixelType);
}
-
+
@Test
public void test08_MipMap_ScaleInternal_RGB_UINT () {
int width = 1;
int height = 7;
int pixelFormat = GL2.GL_RGB;
int pixelType = GL2.GL_UNSIGNED_INT;
-
+
testTextureMipMapGeneration(width, height, pixelFormat, pixelType);
}
-
+
@Test
public void test09_MipMap_ScaleInternal_RGBA_UINT () {
int width = 1;
int height = 7;
int pixelFormat = GL2.GL_RGBA;
int pixelType = GL2.GL_UNSIGNED_INT;
-
+
testTextureMipMapGeneration(width, height, pixelFormat, pixelType);
}
-
+
@Test
public void test10_MipMap_ScaleInternal_RGB_INT () {
int width = 1;
int height = 7;
int pixelFormat = GL2.GL_RGB;
int pixelType = GL2.GL_INT;
-
+
testTextureMipMapGeneration(width, height, pixelFormat, pixelType);
}
-
+
@Test
public void test11_MipMap_ScaleInternal_RGBA_INT () {
int width = 1;
int height = 7;
int pixelFormat = GL2.GL_RGBA;
int pixelType = GL2.GL_INT;
-
+
testTextureMipMapGeneration(width, height, pixelFormat, pixelType);
}
-
+
@Test
public void test12_MipMap_ScaleInternal_RGB_FLOAT () {
int width = 1;
int height = 7;
int pixelFormat = GL2.GL_RGB;
int pixelType = GL2.GL_FLOAT;
-
+
testTextureMipMapGeneration(width, height, pixelFormat, pixelType);
}
-
+
@Test
public void test13_MipMap_ScaleInternal_RGBA_FLOAT () {
int width = 1;
int height = 7;
int pixelFormat = GL2.GL_RGBA;
int pixelType = GL2.GL_FLOAT;
-
+
testTextureMipMapGeneration(width, height, pixelFormat, pixelType);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering2GL2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering2GL2NEWT.java
index d539b5e55..16c1b33f4 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering2GL2NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering2GL2NEWT.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,7 +20,7 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
@@ -60,14 +60,14 @@ import org.junit.runners.MethodSorters;
*
*
* {@link RandomTileRenderer} buffer allocation is performed
- * within the pre {@link GLEventListener}
+ * within the pre {@link GLEventListener}
* set via {@link TileRendererBase#setGLEventListener(GLEventListener, GLEventListener)}
- * on the main thread.
+ * on the main thread.
*
*
* At tile rendering finish, the viewport and
* and the original {@link GLEventListener}'s PMV matrix as well.
- * The latter is done by calling it's {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape} method.
+ * The latter is done by calling it's {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape} method.
*
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@@ -83,7 +83,7 @@ public class TestRandomTiledRendering2GL2NEWT extends UITestCase {
doTest(8);
}
- void doTest(int msaaCount) throws IOException, InterruptedException, InvocationTargetException {
+ void doTest(int msaaCount) throws IOException, InterruptedException, InvocationTargetException {
final GLCapabilities caps = new GLCapabilities(null);
caps.setDoubleBuffered(true);
if( msaaCount > 0 ) {
@@ -93,7 +93,7 @@ public class TestRandomTiledRendering2GL2NEWT extends UITestCase {
final int maxTileSize = 64;
final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile());
- final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, caps, null, maxTileSize, maxTileSize, null);
+ final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, caps, null, maxTileSize, maxTileSize);
final Gears gears = new Gears();
glad.addGLEventListener( gears );
@@ -156,7 +156,7 @@ public class TestRandomTiledRendering2GL2NEWT extends UITestCase {
drawable.getGL().glViewport(0, 0, drawable.getWidth(), drawable.getHeight());
gears.reshape(drawable, 0, 0, drawable.getWidth(), drawable.getHeight());
return false;
- }
+ }
});
glad.destroy();
@@ -168,9 +168,9 @@ public class TestRandomTiledRendering2GL2NEWT extends UITestCase {
caps.getGLProfile(),
0 /* internalFormat */,
imageWidth, imageHeight,
- 0,
+ 0,
imageBuffer.pixelAttributes,
- false, false,
+ false, false,
flipVertically[0],
imageBuffer.buffer,
null /* Flusher */);
@@ -189,5 +189,5 @@ public class TestRandomTiledRendering2GL2NEWT extends UITestCase {
}
}
org.junit.runner.JUnitCore.main(TestRandomTiledRendering2GL2NEWT.class.getName());
- }
+ }
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2NEWT.java
index 74909dc8c..2220c1fb3 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2NEWT.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,7 +20,7 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
@@ -60,14 +60,14 @@ import org.junit.runners.MethodSorters;
*
*
* {@link TileRenderer} buffer allocation is performed
- * within the pre {@link GLEventListener}
+ * within the pre {@link GLEventListener}
* set via {@link TileRendererBase#setGLEventListener(GLEventListener, GLEventListener)}
- * on the main thread.
+ * on the main thread.
*
*
* At tile rendering finish, the viewport and
* and the original {@link GLEventListener}'s PMV matrix as well.
- * The latter is done by calling it's {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape} method.
+ * The latter is done by calling it's {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape} method.
*
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@@ -88,8 +88,8 @@ public class TestTiledRendering2NEWT extends UITestCase {
return null;
}
return glp;
- }
-
+ }
+
@Test
public void test001_off_gl2___aa0() throws IOException {
GLProfile glp = getGLProfile(GLProfile.GL2);
@@ -155,8 +155,8 @@ public class TestTiledRendering2NEWT extends UITestCase {
doTest(true, new GearsES2(), glp, 8);
}
- void doTest(boolean onscreen, final GLEventListener demo, GLProfile glp, final int msaaCount) throws IOException {
- GLCapabilities caps = new GLCapabilities(glp);
+ void doTest(boolean onscreen, final GLEventListener demo, GLProfile glp, final int msaaCount) throws IOException {
+ GLCapabilities caps = new GLCapabilities(glp);
caps.setDoubleBuffered(onscreen);
if( msaaCount > 0 ) {
caps.setSampleBuffers(true);
@@ -172,7 +172,7 @@ public class TestTiledRendering2NEWT extends UITestCase {
glad = glWin;
} else {
final GLDrawableFactory factory = GLDrawableFactory.getFactory(glp);
- glad = factory.createOffscreenAutoDrawable(null, caps, null, maxTileSize, maxTileSize, null);
+ glad = factory.createOffscreenAutoDrawable(null, caps, null, maxTileSize, maxTileSize);
}
glad.addGLEventListener( demo );
@@ -220,7 +220,7 @@ public class TestTiledRendering2NEWT extends UITestCase {
}
renderer.detachAutoDrawable();
-
+
// Restore viewport and Gear's PMV matrix
// .. even though we close the demo, this is for documentation!
glad.invoke(true, new GLRunnable() {
@@ -229,7 +229,7 @@ public class TestTiledRendering2NEWT extends UITestCase {
drawable.getGL().glViewport(0, 0, drawable.getWidth(), drawable.getHeight());
demo.reshape(drawable, 0, 0, drawable.getWidth(), drawable.getHeight());
return false;
- }
+ }
});
final GLPixelBuffer imageBuffer = renderer.getImageBuffer();
@@ -237,15 +237,15 @@ public class TestTiledRendering2NEWT extends UITestCase {
caps.getGLProfile(),
0 /* internalFormat */,
imageWidth, imageHeight,
- 0,
+ 0,
imageBuffer.pixelAttributes,
- false, false,
+ false, false,
flipVertically[0],
imageBuffer.buffer,
null /* Flusher */);
TextureIO.write(textureData, file);
-
+
glad.destroy();
}
@@ -259,5 +259,5 @@ public class TestTiledRendering2NEWT extends UITestCase {
}
}
org.junit.runner.JUnitCore.main(TestTiledRendering2NEWT.class.getName());
- }
+ }
}
diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java
index e85052d08..b1e9f477e 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,12 +20,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.opengl.test.junit.util;
import jogamp.newt.WindowImplAccess;
@@ -40,6 +40,7 @@ import java.awt.Robot;
import javax.media.nativewindow.NativeWindow;
import javax.media.nativewindow.NativeWindowFactory;
import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLContext;
import javax.media.opengl.GLDrawable;
import org.junit.Assert;
@@ -50,17 +51,17 @@ import com.jogamp.newt.event.WindowEvent;
public class AWTRobotUtil {
static final boolean DEBUG = false;
-
+
public static final int RETRY_NUMBER = 5;
public static final int ROBOT_DELAY = 100; // ms
public static final int TIME_OUT = 2000; // 2s
public static final int POLL_DIVIDER = 20; // TO/20
public static final int TIME_SLICE = TIME_OUT / POLL_DIVIDER ;
- public static Integer AWT_CLICK_TO = null;
-
+ public static Integer AWT_CLICK_TO = null;
+
static Object awtEDTAliveSync = new Object();
- static volatile boolean awtEDTAliveFlag = false;
-
+ static volatile boolean awtEDTAliveFlag = false;
+
static class OurUncaughtExceptionHandler implements UncaughtExceptionHandler {
@Override
public void uncaughtException(Thread t, Throwable e) {
@@ -68,16 +69,16 @@ public class AWTRobotUtil {
e.printStackTrace();
}
}
-
+
static {
Thread.setDefaultUncaughtExceptionHandler( new OurUncaughtExceptionHandler() );
// System.err.println("AWT EDT alive: "+isAWTEDTAlive());
}
-
+
/** Probes whether AWT's EDT is alive or not. */
public static boolean isAWTEDTAlive() {
if( EventQueue.isDispatchThread() ) {
- return true;
+ return true;
}
synchronized ( awtEDTAliveSync ) {
awtEDTAliveFlag = false;
@@ -85,7 +86,7 @@ public class AWTRobotUtil {
@Override
public void run() {
awtEDTAliveFlag = true;
- }
+ }
});
for (int wait=0; wait tc && j tc && j delta ) {
throw new AssertionError(msg+"; Expected @ ["+a0+"+"+i+"] has "+ai+", but actual @ ["+b0+"+"+i+"] has "+bi+", it's delta "+daibi+" > "+delta);
}
}
}
-
+
public static void assertFloatBufferNotEqual(String errmsg, FloatBuffer expected, FloatBuffer actual, float delta) {
if(null == expected || null == actual) {
return;
}
if(expected.remaining() != actual.remaining()) {
- return;
+ return;
}
String msg = null != errmsg ? errmsg + " " : "";
final int a0 = expected.position();
@@ -131,14 +135,14 @@ public class MiscUtils {
for(int i=0; i delta ) {
return;
}
}
throw new AssertionError(msg+"; Expected and actual are equal.");
}
-
+
public static boolean setFieldIfExists(Object instance, String fieldName, Object value) {
try {
Field f = instance.getClass().getField(fieldName);
@@ -155,14 +159,14 @@ public class MiscUtils {
}
return false;
}
-
+
public static class StreamDump extends Thread {
final InputStream is;
final StringBuilder outString;
final OutputStream outStream;
final String prefix;
final Object sync;
- volatile boolean eos = false;
+ volatile boolean eos = false;
public StreamDump(OutputStream out, String prefix, InputStream is, Object sync) {
this.is = is;
@@ -178,7 +182,7 @@ public class MiscUtils {
this.prefix = null;
this.sync = sync;
}
-
+
public final boolean eos() { return eos; }
@Override
@@ -208,7 +212,28 @@ public class MiscUtils {
}
}
}
- }
+ }
+
+ public static void dumpSharedGLContext(GLContext self) {
+ int i = 0, j = 0;
+ System.err.println("Myself: hash 0x"+Integer.toHexString(self.hashCode())+", \t(isShared "+self.isShared()+", created "+self.isCreated()+")");
+ {
+ final List set = self.getCreatedShares();
+ for (final Iterator iter = set.iterator(); iter.hasNext(); ) {
+ final GLContext c = iter.next();
+ System.err.println("Ctx #"+(i++)+": hash 0x"+Integer.toHexString(c.hashCode())+", \t(created "+c.isCreated()+")");
+ }
+ }
+ {
+ final List set = self.getDestroyedShares();
+ for (final Iterator iter = set.iterator(); iter.hasNext(); ) {
+ final GLContext c = iter.next();
+ System.err.println("Ctx #"+(j++)+": hash 0x"+Integer.toHexString(c.hashCode())+", \t(created "+c.isCreated()+")");
+ }
+ }
+ System.err.println("\t Total created "+i+" + destroyed "+j+" = "+(i+j));
+ System.err.println();
+ }
}
--
cgit v1.2.3