diff options
author | Sven Gothel <[email protected]> | 2013-10-28 03:58:01 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-10-28 03:58:01 +0100 |
commit | bcfaa149b9803ce33c5a356cbcb45f7dfd3e4361 (patch) | |
tree | 296947e2b5a04874b3ce42ab711e8abc0d588e92 | |
parent | f73c10f71be979d214537679f85f1897c5642e11 (diff) |
Bug 776 GLContext Sharing: Add note about driver stability (destruction order) ; Fix unit tests (Shared Gears, wait for created context and destruction order)
- Add note about driver stability (destruction order)
- See GLSharedContextSetter: Don't destroy master context before slaves!
- Fix spec-overview.html#SHARED links, add link to GLSharedContextSetter in SHARED subsection.
- Fix unit tests (Shared Gears, wait for created context and destruction order)
- The GearsObject sharing was completly bogus!
It simply used the _same_ GLArrayDataServer instance for sharing,
but it should use a _copy_ of the shared GLArrayDataServer while
only preserving the VBO object!
Fixed, while adding required methods to GLArrayDataServer.
- Waiting for the created GLContext of a GLAutoDrawable required us
to pass the latter _and_ check whether it's GLContext exists and is natively created.
- Accomodated the destruction order - see above!
20 files changed, 511 insertions, 167 deletions
diff --git a/make/build-test.xml b/make/build-test.xml index 066d41401..b7220aed6 100644 --- a/make/build-test.xml +++ b/make/build-test.xml @@ -449,7 +449,45 @@ </junit> </target> - <target name="junit.run.newt.event" depends="test.compile"> + <target name="junit.run.sharedctx" depends="test.compile, junit.run.settings"> + <!-- Test*AWT* --> + <junit jvm="${jvmJava.exe}" forkmode="perTest" showoutput="true" fork="true" haltonerror="off" timeout="${batchtest.timeout}"> + <env key="${system.env.library.path}" path="${obj.all.paths}"/> + <jvmarg value="${junit.run.arg0}"/> + <jvmarg value="${junit.run.arg1}"/> + <jvmarg value="${jvmDataModel.arg}"/> + <jvmarg value="-Djava.library.path=${obj.all.paths}"/> + + <!-- + <jvmarg value="-Dnewt.debug.EDT"/> + <jvmarg value="-Djogl.debug=all"/> + <jvmarg value="-Dgluegen.debug.NativeLibrary=true"/> + <jvmarg value="-Dgluegen.debug.ProcAddressHelper=true"/> + <jvmarg value="-Djogl.debug.GLSLState"/> + <jvmarg value="-Dnativewindow.debug=all"/> + <jvmarg value="-Dnewt.debug=all"/> + <jvmarg value="-verbose:jni"/> + <jvmarg value="-client"/> + <jvmarg value="-d32"/> + --> + + <formatter usefile="false" type="plain"/> + <formatter usefile="true" type="xml"/> + <!--classpath refid="junit_jogl_awt.run.classpath"/--> + <classpath refid="junit_jogl_swt.run.classpath"/> + + <batchtest todir="${results.test}"> + <fileset dir="${classes}"> + <include name="${java.dir.junit}/**/acore/TestSharedContextVBO**"/> + <exclude name="**/*$$*"/> + </fileset> + <formatter usefile="false" type="brief"/> + <formatter usefile="true" type="xml"/> + </batchtest> + </junit> + </target> + + <target name="junit.run.newt.event" depends="test.compile, junit.run.settings"> <!-- Test*AWT* --> <junit jvm="${jvmJava.exe}" forkmode="perTest" showoutput="true" fork="true" haltonerror="off" timeout="${batchtest.timeout}"> <env key="${system.env.library.path}" path="${obj.all.paths}"/> @@ -487,7 +525,7 @@ </junit> </target> - <target name="junit.run.newt.monitormode" depends="test.compile"> + <target name="junit.run.newt.monitormode" depends="test.compile, junit.run.settings"> <!-- Test*AWT* --> <junit jvm="${jvmJava.exe}" forkmode="perTest" showoutput="true" fork="true" haltonerror="off" timeout="${batchtest.timeout}"> <env key="${system.env.library.path}" path="${obj.all.paths}"/> diff --git a/make/doc/jogl/spec-overview.html b/make/doc/jogl/spec-overview.html index 952e8f8e0..1a63fb7dd 100644 --- a/make/doc/jogl/spec-overview.html +++ b/make/doc/jogl/spec-overview.html @@ -332,6 +332,11 @@ to the underlying native engine.</p> Sharing of server-side OpenGL objects such as buffer objects, e.g. VBOs, and textures among OpenGL contexts is supported in this specification. +<p> +See {@link javax.media.opengl.GLSharedContextSetter GLSharedContextSetter} interface +for details. +</p> + <h3>Criteria Used for Inclusion of APIs into the Java Bindings</h3> <h4><a name="GLAPIInclusionCriteria">OpenGL API Inclusion Criteria</a></h4> diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index 90226c28d..71ac8c43d 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -6,10 +6,35 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCom REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT -time 5000 -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListAWT -time 5000 -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT -time 5000 + +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES1NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT0 %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT1 %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT2 %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT3 %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3 %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3b %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextWithJTabbedPaneAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2SWT3 %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextNewtAWTBug523 %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListAWT %* + +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOOffThreadSharedContextMix2DemosES2NEWT $* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOOnThreadSharedContext1DemoES2NEWT $* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT $* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOMRTNEWT01 $* + +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryGLnBitmapCapsNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryES2OffscrnCapsNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT %* + REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile02NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch01NEWT %* @@ -29,18 +54,6 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusi REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext11VSyncAnimNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext12FPSAnimNEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryGLnBitmapCapsNEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryES2OffscrnCapsNEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableOffThreadSharedContextES2NEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOMRTNEWT01 %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT %* - REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestSwingAWT01GLn REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock00AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock02AWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 4d87136c3..0f3388fb3 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -84,6 +84,7 @@ function jrun() { #D_ARGS="-Dnativewindow.debug.X11Util.ATI_HAS_NO_XCLOSEDISPLAY_BUG" #D_ARGS="-Dnativewindow.debug.X11Util.ATI_HAS_NO_MULTITHREADING_BUG" #D_ARGS="-Djogl.disable.opengles" + #D_ARGS="-Djogl.debug.DebugGL" #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.FBObject" #D_ARGS="-Djogl.debug.FBObject -Djogl.debug.TraceGL -Djogl.debug.GLBufferStateTracker" #D_ARGS="-Djogl.debug.FBObject" @@ -375,9 +376,11 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT0 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT1 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT2 $* -#testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3 $* -testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3b $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT3 $* +testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3 $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3b $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextWithJTabbedPaneAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2SWT3 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextNewtAWTBug523 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListAWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java index e30fea2f4..96643ae72 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java @@ -231,6 +231,28 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE } /** + * Create a VBO for fixed function interleaved array data + * starting with a given Buffer object incl it's stride + * <p>User needs to <i>configure</i> the interleaved segments via {@link #addFixedSubArray(int, int, int)}.</p> + * + * @param comps The total number of all interleaved components. + * @param dataType The array index GL data type + * @param normalized Whether the data shall be normalized + * @param initialElementCount + * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW} + */ + public static GLArrayDataServer createFixedInterleaved(int comps, int dataType, boolean normalized, int stride, Buffer buffer, + int vboUsage) + throws GLException + { + GLArrayDataServer ads = new GLArrayDataServer(); + GLArrayHandler glArrayHandler = new GLArrayHandlerInterleaved(ads); + ads.init(GLPointerFuncUtil.mgl_InterleaveArray, -1, comps, dataType, normalized, stride, buffer, buffer.limit(), false, glArrayHandler, + 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, false); + return ads; + } + + /** * Configure a segment of this fixed function interleaved array (see {@link #createFixedInterleaved(int, int, boolean, int, int)}). * <p> * This method may be called several times as long the sum of interleaved components does not @@ -287,6 +309,29 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE } /** + * Create a VBO for GLSL interleaved array data + * starting with a given Buffer object incl it's stride + * <p>User needs to <i>configure</i> the interleaved segments via {@link #addGLSLSubArray(int, int, int)}.</p> + * + * @param comps The total number of all interleaved components. + * @param dataType The array index GL data type + * @param normalized Whether the data shall be normalized + * @param stride + * @param buffer the user define data + * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW} + */ + public static GLArrayDataServer createGLSLInterleaved(int comps, int dataType, boolean normalized, int stride, Buffer buffer, + int vboUsage) + throws GLException + { + GLArrayDataServer ads = new GLArrayDataServer(); + GLArrayHandler glArrayHandler = new GLSLArrayHandlerInterleaved(ads); + ads.init(GLPointerFuncUtil.mgl_InterleaveArray, -1, comps, dataType, normalized, stride, buffer, buffer.limit(), false, glArrayHandler, + 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, true); + return ads; + } + + /** * Configure a segment of this GLSL interleaved array (see {@link #createGLSLInterleaved(int, int, boolean, int, int)}). * <p> * This method may be called several times as long the sum of interleaved components does not diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java index 817dff8ad..98eb9bdde 100644 --- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java +++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java @@ -675,8 +675,8 @@ public abstract class GLDrawableFactory { * The GLPbuffer drawable is realized and initialized eagerly. * </p> * - * See the note in the overview documentation on - * <a href="../../../spec-summary.html#SHARING">context sharing</a>. + * See the note in the overview documentation in {@link GLSharedContextSetter} and on + * <a href="../../../spec-overview.html#SHARING">context sharing</a>. * * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be <code>null</code> for the platform's default device. * @param capabilities the requested capabilities diff --git a/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java b/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java index d5a10931e..8c2311329 100644 --- a/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java +++ b/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java @@ -31,7 +31,29 @@ package javax.media.opengl; /** * Adds capabilities to set a shared {@link GLContext} directly or via an {@link GLAutoDrawable}. * <p> - * Warning: Don't reference this interface directly, since it may end up in {@link GLAutoDrawable} + * Sharing of server-side OpenGL objects such as buffer objects, e.g. VBOs, + * and textures among OpenGL contexts is supported with this interface. + * </p> + * <p> + * A <i>master</i> {@link GLContext} is the {@link GLContext} which is created first, + * shared {@link GLContext} w/ this master are referred as slave {@link GLContext}. + * </p> + * <h5><a name="driverstabilityconstraints">Driver stability constraints</a></h5> + * <p> + * Be aware that the <i>master</i> {@link GLContext} and related resources, i.e. the {@link GLAutoDrawable}, + * <i>shall not</i> be destroyed before it's <i>slave</i> {@link GLContext} instances.<br> + * Otherwise the OpenGL driver implementation may crash w/ SIGSEGV if shared resources are still used!<br> + * Note that this is not specified within OpenGL and <i>should work</i>, however, some drivers + * do not seem to handle this situation well, i.e. they do not postpone resource destruction + * until the last reference is removed.<br> + * Since pending destruction of {@link GLContext} and it's {@link GLDrawable} is complex and nearly impossible + * for us at the top level, considering the different windowing systems and {@link GLAutoDrawable} types, + * the user shall take care of proper destruction order. + * </p> + * <p> + * Users may use a {@link GLDrawableFactory#createDummyDrawable(javax.media.nativewindow.AbstractGraphicsDevice, boolean, GLProfile) dummy} + * {@link GLDrawable} and it's {@link GLContext} as the <i>master</i> of all shared <i>slave</i> {@link GLContext}. + * Same constraints as above apply, i.e. it shall be destroyed <i>after</i> all shared slaves. * </p> */ public interface GLSharedContextSetter extends GLAutoDrawable { @@ -46,6 +68,9 @@ public interface GLSharedContextSetter extends GLAutoDrawable { * A set <i>sharedContext</i> will block context creation, i.e. {@link GLAutoDrawable#initialization GLAutoDrawable initialization}, * as long it is not {@link GLContext#isCreated() created natively}. * </p> + * <p> + * See <a href="#driverstabilityconstraints">driver stability constraints</a>. + * </p> * * @param sharedContext The OpenGL context to be shared by this {@link GLAutoDrawable}'s {@link GLContext}. * @throws IllegalStateException if a {@link #setSharedContext(GLContext) shared GLContext} @@ -67,6 +92,9 @@ public interface GLSharedContextSetter extends GLAutoDrawable { * as long it's {@link GLContext} is <code>null</code> * or has not been {@link GLContext#isCreated() created natively}. * </p> + * <p> + * See <a href="#driverstabilityconstraints">driver stability constraints</a>. + * </p> * * @param sharedContext The GLAutoDrawable, which OpenGL context shall be shared by this {@link GLAutoDrawable}'s {@link GLContext}. * @throws IllegalStateException if a {@link #setSharedContext(GLContext) shared GLContext} diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index c2d8e0535..439a5bd30 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -246,7 +246,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing textures, display lists and other OpenGL state, and may be null if sharing is not desired. See the note in the overview documentation on <a - href="../../../spec-summary.html#SHARING">context + href="../../../spec-overview.html#SHARING">context sharing</a>. The passed GraphicsDevice indicates the screen on which to create the GLCanvas; the GLDrawableFactory uses the default screen device of the local GraphicsEnvironment if null diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index faf00c19a..8b1467268 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -286,14 +286,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing default set of capabilities is used. The GLCapabilitiesChooser specifies the algorithm for selecting one of the available GLCapabilities for the component; a DefaultGLCapabilitesChooser - is used if null is passed for this argument. The passed - 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 - <a href="../../../spec-summary.html#SHARING">context sharing</a>. - <P> - Note: Sharing cannot be enabled using J2D OpenGL FBO sharing, - since J2D GL Context must be shared and we can only share one context. + is used if null is passed for this argument. * @throws GLException if no GLCapabilities are given and no default profile is available for the default desktop device. */ public GLJPanel(GLCapabilitiesImmutable userCapsRequest, GLCapabilitiesChooser chooser) @@ -311,7 +304,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 - <a href="../../../spec-summary.html#SHARING">context sharing</a>. + <a href="../../../spec-overview.html#SHARING">context sharing</a>. <P> Note: Sharing cannot be enabled using J2D OpenGL FBO sharing, since J2D GL Context must be shared and we can only share one context. diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES1NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES1NEWT.java index 05d060f0b..59bb13c87 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES1NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES1NEWT.java @@ -104,7 +104,7 @@ public class TestSharedContextVBOES1NEWT extends UITestCase { // 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 not created", AWTRobotUtil.waitForContextCreated(sharedDrawable, true)); Assert.assertTrue("Master Ctx is shared before shared creation", !ctxM.isShared()); Assert.assertTrue("Master Gears is shared", !sharedGears.usesSharedGears()); } @@ -136,7 +136,7 @@ public class TestSharedContextVBOES1NEWT extends UITestCase { glWindow.setVisible(true); Assert.assertTrue(AWTRobotUtil.waitForRealized(glWindow, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(glWindow, true)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(glWindow.getContext(), true)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(glWindow, true)); System.err.println("Master Context: "); MiscUtils.dumpSharedGLContext(sharedDrawable.getContext()); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java index b2d88f8e0..5cf2e4b24 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java @@ -93,7 +93,17 @@ public class TestSharedContextVBOES2AWT3 extends UITestCase { } @Test - public void test01SyncedCommonAnimatorSharedOffscreen() throws InterruptedException, InvocationTargetException { + public void test01SyncedOneAnimatorCleanDtorOrder() throws InterruptedException, InvocationTargetException { + syncedOneAnimator(true); + } + + // Don't test erroneous test case ! + // @Test + public void test02SyncedOneAnimatorDirtyDtorOrder() throws InterruptedException, InvocationTargetException { + syncedOneAnimator(false); + } + + public void syncedOneAnimator(final boolean destroyCleanOrder) throws InterruptedException, InvocationTargetException { final Frame f1 = new Frame(); final Animator animator = new Animator(); final GearsES2 g1 = new GearsES2(0); @@ -128,17 +138,17 @@ public class TestSharedContextVBOES2AWT3 extends UITestCase { Assert.assertTrue(AWTRobotUtil.waitForRealized(c1, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(c1, true)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(c1.getContext(), true)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(c1, 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(AWTRobotUtil.waitForContextCreated(c2, 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(AWTRobotUtil.waitForContextCreated(c3, true)); Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true)); final GLContext ctx1 = c1.getContext(); @@ -174,12 +184,45 @@ public class TestSharedContextVBOES2AWT3 extends UITestCase { } animator.stop(); + if( destroyCleanOrder ) { + System.err.println("XXX Destroy in clean order NOW"); + } else { + System.err.println("XXX Destroy in creation order NOW - Driver Impl. Ma trigger driver Bug i.e. not postponing GL ctx destruction after releasing all refs."); + } + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + try { + if( destroyCleanOrder ) { + f3.dispose(); + } else { + f1.dispose(); + } + } catch (Throwable t) { + throw new RuntimeException(t); + } + }}); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + try { + if( destroyCleanOrder ) { + f2.dispose(); + } else { + f2.dispose(); + } + } catch (Throwable t) { + throw new RuntimeException(t); + } + }}); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { try { - f1.dispose(); - f2.dispose(); - f3.dispose(); + if( destroyCleanOrder ) { + f1.dispose(); + } else { + f3.dispose(); + } } catch (Throwable t) { throw new RuntimeException(t); } @@ -191,7 +234,17 @@ public class TestSharedContextVBOES2AWT3 extends UITestCase { } @Test - public void test02AsyncEachWithAnimatorSharedOffscreen() throws InterruptedException, InvocationTargetException { + public void test11SyncEachAnimatorCleanDtorOrder() throws InterruptedException, InvocationTargetException { + syncedOneAnimator(true); + } + + // Don't test erroneous test case ! + // @Test + public void test12SyncEachAnimatorDirtyDtorOrder() throws InterruptedException, InvocationTargetException { + asyncEachOneAnimator(false); + } + + public void asyncEachOneAnimator(final boolean destroyCleanOrder) throws InterruptedException, InvocationTargetException { final Frame f1 = new Frame(); final Animator a1 = new Animator(); final GearsES2 g1 = new GearsES2(0); @@ -237,17 +290,17 @@ public class TestSharedContextVBOES2AWT3 extends UITestCase { Assert.assertTrue(AWTRobotUtil.waitForRealized(c1, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(c1, true)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(c1.getContext(), true)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(c1, 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(AWTRobotUtil.waitForContextCreated(c2, 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(AWTRobotUtil.waitForContextCreated(c3, true)); Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true)); final GLContext ctx1 = c1.getContext(); @@ -285,12 +338,45 @@ public class TestSharedContextVBOES2AWT3 extends UITestCase { a2.stop(); a3.stop(); + if( destroyCleanOrder ) { + System.err.println("XXX Destroy in clean order NOW"); + } else { + System.err.println("XXX Destroy in creation order NOW - Driver Impl. Ma trigger driver Bug i.e. not postponing GL ctx destruction after releasing all refs."); + } + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + try { + if( destroyCleanOrder ) { + f3.dispose(); + } else { + f1.dispose(); + } + } catch (Throwable t) { + throw new RuntimeException(t); + } + }}); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + try { + if( destroyCleanOrder ) { + f2.dispose(); + } else { + f2.dispose(); + } + } catch (Throwable t) { + throw new RuntimeException(t); + } + }}); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { try { - f1.dispose(); - f2.dispose(); - f3.dispose(); + if( destroyCleanOrder ) { + f1.dispose(); + } else { + f3.dispose(); + } } catch (Throwable t) { throw new RuntimeException(t); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3b.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3b.java index fcfe4d512..07b9fd4eb 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3b.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3b.java @@ -93,7 +93,7 @@ public class TestSharedContextVBOES2AWT3b extends UITestCase { } @Test - public void test01SyncedCommonAnimatorSharedOffscreen() throws InterruptedException, InvocationTargetException { + public void test01SyncedOneAnimator() throws InterruptedException, InvocationTargetException { final Frame f1 = new Frame(); final Animator animator = new Animator(); final GearsES2 g1 = new GearsES2(0); @@ -128,17 +128,17 @@ public class TestSharedContextVBOES2AWT3b extends UITestCase { Assert.assertTrue(AWTRobotUtil.waitForRealized(c1, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(c1, true)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(c1.getContext(), true)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(c1, 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(AWTRobotUtil.waitForContextCreated(c2, 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(AWTRobotUtil.waitForContextCreated(c3, true)); Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true)); final GLContext ctx1 = c1.getContext(); @@ -177,9 +177,9 @@ public class TestSharedContextVBOES2AWT3b extends UITestCase { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { try { - f1.dispose(); - f2.dispose(); f3.dispose(); + f2.dispose(); + f1.dispose(); } catch (Throwable t) { throw new RuntimeException(t); } @@ -191,7 +191,7 @@ public class TestSharedContextVBOES2AWT3b extends UITestCase { } @Test - public void test02AsyncEachWithAnimatorSharedOffscreen() throws InterruptedException, InvocationTargetException { + public void test02AsyncEachAnimator() throws InterruptedException, InvocationTargetException { final Frame f1 = new Frame(); final Animator a1 = new Animator(); final GearsES2 g1 = new GearsES2(0); @@ -237,17 +237,17 @@ public class TestSharedContextVBOES2AWT3b extends UITestCase { Assert.assertTrue(AWTRobotUtil.waitForRealized(c1, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(c1, true)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(c1.getContext(), true)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(c1, 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(AWTRobotUtil.waitForContextCreated(c2, 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(AWTRobotUtil.waitForContextCreated(c3, true)); Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true)); final GLContext ctx1 = c1.getContext(); @@ -288,9 +288,9 @@ public class TestSharedContextVBOES2AWT3b extends UITestCase { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { try { - f1.dispose(); - f2.dispose(); f3.dispose(); + f2.dispose(); + f1.dispose(); } catch (Throwable t) { throw new RuntimeException(t); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT0.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT0.java index 76ae5c69d..a8c069f36 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT0.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT0.java @@ -93,7 +93,7 @@ public class TestSharedContextVBOES2NEWT0 extends UITestCase { Assert.assertTrue(AWTRobotUtil.waitForRealized(glWindow, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(glWindow, true)); glWindow.display(); - Assert.assertTrue(AWTRobotUtil.waitForCreated(glWindow.getContext(), true)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(glWindow, true)); Assert.assertTrue("Gears not initialized", gears.waitForInit(true)); return glWindow; @@ -183,7 +183,7 @@ public class TestSharedContextVBOES2NEWT0 extends UITestCase { f1.destroy(); Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false)); Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), false)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f1, false)); { final List<GLContext> ctx1Shares = ctx1.getCreatedShares(); final List<GLContext> ctx2Shares = ctx2.getCreatedShares(); @@ -206,7 +206,7 @@ public class TestSharedContextVBOES2NEWT0 extends UITestCase { f2.destroy(); Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false)); Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), false)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f2, false)); { final List<GLContext> ctx1Shares = ctx1.getCreatedShares(); final List<GLContext> ctx2Shares = ctx2.getCreatedShares(); @@ -229,7 +229,7 @@ public class TestSharedContextVBOES2NEWT0 extends UITestCase { f3.destroy(); Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false)); Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), false)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f3, false)); { final List<GLContext> ctx1Shares = ctx1.getCreatedShares(); final List<GLContext> ctx2Shares = ctx2.getCreatedShares(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT1.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT1.java index e3b1fe396..827601869 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT1.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT1.java @@ -120,7 +120,7 @@ public class TestSharedContextVBOES2NEWT1 extends UITestCase { // 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 not created", AWTRobotUtil.waitForContextCreated(sharedDrawable, 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()); @@ -154,7 +154,7 @@ public class TestSharedContextVBOES2NEWT1 extends UITestCase { glWindow.setVisible(true); Assert.assertTrue(AWTRobotUtil.waitForRealized(glWindow, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(glWindow, true)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(glWindow.getContext(), true)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(glWindow, true)); System.err.println("Master Context: "); MiscUtils.dumpSharedGLContext(sharedDrawable.getContext()); @@ -193,13 +193,13 @@ public class TestSharedContextVBOES2NEWT1 extends UITestCase { f3.destroy(); Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false)); Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), false)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f1, false)); Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false)); Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), false)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f2, false)); Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false)); Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), false)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f3, false)); releaseShared(); } @@ -226,13 +226,13 @@ public class TestSharedContextVBOES2NEWT1 extends UITestCase { f3.destroy(); Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false)); Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), false)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f1, false)); Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false)); Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), false)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f2, false)); Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false)); Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), false)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f3, false)); releaseShared(); } @@ -264,13 +264,13 @@ public class TestSharedContextVBOES2NEWT1 extends UITestCase { f3.destroy(); Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false)); Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), false)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f1, false)); Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false)); Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), false)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f2, false)); Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false)); Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), false)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f3, false)); releaseShared(); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java index 9b283d6cd..d9fe2a949 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java @@ -96,7 +96,17 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase { } @Test - public void test01SyncedCommonAnimatorSharedOffscreen() throws InterruptedException { + public void test01SyncedOneAnimatorCleanDtorOrder() throws InterruptedException { + syncedOneAnimator(true); + } + + // Don't test erroneous test case ! + // @Test + public void test02SyncedOneAnimatorDirtyDtorOrder() throws InterruptedException { + syncedOneAnimator(false); + } + + public void syncedOneAnimator(boolean destroyCleanOrder) throws InterruptedException { final Animator animator = new Animator(); final GearsES2 g1 = new GearsES2(0); final GLWindow f1 = createGLWindow(0, 0, g1); @@ -133,19 +143,20 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase { 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(AWTRobotUtil.waitForContextCreated(f1, 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(AWTRobotUtil.waitForContextCreated(f2, 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(AWTRobotUtil.waitForContextCreated(f3, true)); Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true)); animator.start(); // post start animator, otherwise display will be suppressed @@ -182,10 +193,19 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase { e.printStackTrace(); } animator.stop(); + Assert.assertEquals(false, animator.isAnimating()); - f1.destroy(); - f2.destroy(); - f3.destroy(); + if( destroyCleanOrder ) { + System.err.println("XXX Destroy in clean order NOW"); + f3.destroy(); + f2.destroy(); + f1.destroy(); + } else { + System.err.println("XXX Destroy in creation order NOW - Driver Impl. May trigger driver Bug i.e. not postponing GL ctx destruction after releasing all refs."); + f1.destroy(); + f2.destroy(); + f3.destroy(); + } Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false)); Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false)); Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false)); @@ -195,7 +215,17 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase { } @Test - public void test02AsyncEachWithAnimatorSharedOffscreen() throws InterruptedException { + public void test11ASyncEachAnimatorCleanDtorOrder() throws InterruptedException { + asyncEachAnimator(true); + } + + // Don't test erroneous test case ! + // @Test + public void test12AsyncEachAnimatorDirtyDtorOrder() throws InterruptedException { + asyncEachAnimator(false); + } + + public void asyncEachAnimator(boolean destroyCleanOrder) throws InterruptedException { final Animator a1 = new Animator(); final GearsES2 g1 = new GearsES2(0); final GLWindow f1 = createGLWindow(0, 0, g1); @@ -237,16 +267,16 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase { Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, true)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), true)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f1, 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(AWTRobotUtil.waitForContextCreated(f2, 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(AWTRobotUtil.waitForContextCreated(f3, true)); Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true)); final GLContext ctx1 = f1.getContext(); @@ -281,12 +311,23 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase { e.printStackTrace(); } a1.stop(); + Assert.assertEquals(false, a1.isAnimating()); a2.stop(); + Assert.assertEquals(false, a2.isAnimating()); a3.stop(); + Assert.assertEquals(false, a3.isAnimating()); - f1.destroy(); - f2.destroy(); - f3.destroy(); + if( destroyCleanOrder ) { + System.err.println("XXX Destroy in clean order NOW"); + f3.destroy(); + f2.destroy(); + f1.destroy(); + } else { + System.err.println("XXX Destroy in creation order NOW - Driver Impl. May trigger driver Bug i.e. not postponing GL ctx destruction after releasing all refs."); + f1.destroy(); + f2.destroy(); + f3.destroy(); + } Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false)); Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false)); Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false)); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT3.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT3.java index e2928855c..adadf85e3 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT3.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT3.java @@ -93,7 +93,17 @@ public class TestSharedContextVBOES2NEWT3 extends UITestCase { } @Test - public void test01SyncedCommonAnimatorSharedOffscreen() throws InterruptedException { + public void test01SyncedOneAnimatorCleanDtorOrder() throws InterruptedException { + syncedOneAnimator(true); + } + + // Don't test erroneous test case ! + // @Test + public void test02SyncedOneAnimatorDirtyDtorOrder() throws InterruptedException { + syncedOneAnimator(false); + } + + public void syncedOneAnimator(boolean destroyCleanOrder) throws InterruptedException { final Animator animator = new Animator(); final GearsES2 g1 = new GearsES2(0); final GLWindow f1 = createGLWindow(0, 0, g1); @@ -123,17 +133,17 @@ public class TestSharedContextVBOES2NEWT3 extends UITestCase { Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, true)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), true)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f1, 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(AWTRobotUtil.waitForContextCreated(f2, 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(AWTRobotUtil.waitForContextCreated(f3, true)); Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true)); final GLContext ctx1 = f1.getContext(); @@ -169,9 +179,17 @@ public class TestSharedContextVBOES2NEWT3 extends UITestCase { } animator.stop(); - f1.destroy(); - f2.destroy(); - f3.destroy(); + if( destroyCleanOrder ) { + System.err.println("XXX Destroy in clean order NOW"); + f3.destroy(); + f2.destroy(); + f1.destroy(); + } else { + System.err.println("XXX Destroy in creation order NOW - Driver Impl. Ma trigger driver Bug i.e. not postponing GL ctx destruction after releasing all refs."); + f1.destroy(); + f2.destroy(); + f3.destroy(); + } Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false)); Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false)); Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false)); @@ -181,7 +199,17 @@ public class TestSharedContextVBOES2NEWT3 extends UITestCase { } @Test - public void test02AsyncEachWithAnimatorSharedOffscreen() throws InterruptedException { + public void test11ASyncEachAnimatorCleanDtorOrder() throws InterruptedException { + asyncEachAnimator(true); + } + + // Don't test erroneous test case ! + // @Test + public void test12AsyncEachAnimatorDirtyDtorOrder() throws InterruptedException { + asyncEachAnimator(false); + } + + public void asyncEachAnimator(boolean destroyCleanOrder) throws InterruptedException { final Animator a1 = new Animator(); final GearsES2 g1 = new GearsES2(0); final GLWindow f1 = createGLWindow(0, 0, g1); @@ -217,17 +245,17 @@ public class TestSharedContextVBOES2NEWT3 extends UITestCase { Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, true)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), true)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f1, 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(AWTRobotUtil.waitForContextCreated(f2, 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(AWTRobotUtil.waitForContextCreated(f3, true)); Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true)); final GLContext ctx1 = f1.getContext(); @@ -265,9 +293,17 @@ public class TestSharedContextVBOES2NEWT3 extends UITestCase { a2.stop(); a3.stop(); - f1.destroy(); - f2.destroy(); - f3.destroy(); + if( destroyCleanOrder ) { + System.err.println("XXX Destroy in clean order NOW"); + f3.destroy(); + f2.destroy(); + f1.destroy(); + } else { + System.err.println("XXX Destroy in creation order NOW - Driver Impl. May trigger driver Bug i.e. not postponing GL ctx destruction after releasing all refs."); + f1.destroy(); + f2.destroy(); + f3.destroy(); + } Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false)); Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false)); Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false)); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/GearsObject.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/GearsObject.java index 82dd7071f..7adcce2ae 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/GearsObject.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/GearsObject.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 @@ -37,7 +37,7 @@ public abstract class GearsObject { public static final FloatBuffer blue = Buffers.newDirectFloatBuffer( new float[] { 0.2f, 0.2f, 1.0f, 0.7f } ); public static final float M_PI = (float)Math.PI; - public final FloatBuffer gearColor; + public final FloatBuffer gearColor; public GLArrayDataServer frontFace; public GLArrayDataServer frontSide; public GLArrayDataServer backFace; @@ -46,10 +46,11 @@ public abstract class GearsObject { public GLArrayDataServer insideRadiusCyl; public boolean isShared; + public abstract GLArrayDataServer createInterleaveClone(GLArrayDataServer ads); public abstract GLArrayDataServer createInterleaved(int comps, int dataType, boolean normalized, int initialSize, int vboUsage); public abstract void addInterleavedVertexAndNormalArrays(GLArrayDataServer array, int components); public abstract void draw(GL gl, float x, float y, float angle); - + public void destroy(GL gl) { if(!isShared) { // could be already destroyed by shared configuration @@ -77,21 +78,27 @@ public abstract class GearsObject { backFace=null; backSide=null; outwardFace=null; - insideRadiusCyl=null; + insideRadiusCyl=null; isShared = false; } - + public GearsObject ( GearsObject shared ) { isShared = true; - frontFace = shared.frontFace; - frontSide = shared.frontSide; - backFace = shared.backFace; - backSide = shared.backSide; - outwardFace = shared.outwardFace; - insideRadiusCyl = shared.insideRadiusCyl; + frontFace = createInterleaveClone(shared.frontFace); + addInterleavedVertexAndNormalArrays(frontFace, 3); + backFace = createInterleaveClone(shared.backFace); + addInterleavedVertexAndNormalArrays(backFace, 3); + frontSide = createInterleaveClone(shared.frontSide); + addInterleavedVertexAndNormalArrays(frontSide, 3); + backSide= createInterleaveClone(shared.backSide); + addInterleavedVertexAndNormalArrays(backSide, 3); + outwardFace = createInterleaveClone(shared.outwardFace); + addInterleavedVertexAndNormalArrays(outwardFace, 3); + insideRadiusCyl = createInterleaveClone(shared.insideRadiusCyl); + addInterleavedVertexAndNormalArrays(insideRadiusCyl, 3); gearColor = shared.gearColor; } - + public GearsObject ( FloatBuffer gearColor, float inner_radius, @@ -100,7 +107,7 @@ public abstract class GearsObject { int teeth, float tooth_depth) { - final float dz = width * 0.5f; + final float dz = width * 0.5f; int i; float r0, r1, r2; float angle, da; @@ -112,7 +119,7 @@ public abstract class GearsObject { this.isShared = false; this.gearColor = gearColor; - + r0 = inner_radius; r1 = outer_radius - tooth_depth / 2.0f; r2 = outer_radius + tooth_depth / 2.0f; @@ -121,7 +128,7 @@ public abstract class GearsObject { s[4] = 0; // sin(0f) c[4] = 1; // cos(0f) - + final int vboUsage = GL.GL_STATIC_DRAW; frontFace = createInterleaved(6, GL.GL_FLOAT, false, 4*teeth+2, vboUsage); @@ -143,45 +150,45 @@ public abstract class GearsObject { sincos(angle + da * 1f, s, 1, c, 1); sincos(angle + da * 2f, s, 2, c, 2); sincos(angle + da * 3f, s, 3, c, 3); - + /* front */ normal[0] = 0.0f; normal[1] = 0.0f; normal[2] = 1.0f; - + /* front face - GL.GL_TRIANGLE_STRIP */ vert(frontFace, r0 * c[0], r0 * s[0], dz, normal); vert(frontFace, r1 * c[0], r1 * s[0], dz, normal); vert(frontFace, r0 * c[0], r0 * s[0], dz, normal); vert(frontFace, r1 * c[3], r1 * s[3], dz, normal); - + /* front sides of teeth - GL.GL_TRIANGLES */ vert(frontSide, r1 * c[0], r1 * s[0], dz, normal); - vert(frontSide, r2 * c[1], r2 * s[1], dz, normal); + vert(frontSide, r2 * c[1], r2 * s[1], dz, normal); vert(frontSide, r2 * c[2], r2 * s[2], dz, normal); vert(frontSide, r1 * c[0], r1 * s[0], dz, normal); - vert(frontSide, r2 * c[2], r2 * s[2], dz, normal); + vert(frontSide, r2 * c[2], r2 * s[2], dz, normal); vert(frontSide, r1 * c[3], r1 * s[3], dz, normal); - + /* back */ normal[0] = 0.0f; normal[1] = 0.0f; normal[2] = -1.0f; - + /* back face - GL.GL_TRIANGLE_STRIP */ vert(backFace, r1 * c[0], r1 * s[0], -dz, normal); vert(backFace, r0 * c[0], r0 * s[0], -dz, normal); vert(backFace, r1 * c[3], r1 * s[3], -dz, normal); vert(backFace, r0 * c[0], r0 * s[0], -dz, normal); - + /* back sides of teeth - GL.GL_TRIANGLES*/ vert(backSide, r1 * c[3], r1 * s[3], -dz, normal); vert(backSide, r2 * c[2], r2 * s[2], -dz, normal); vert(backSide, r2 * c[1], r2 * s[1], -dz, normal); vert(backSide, r1 * c[3], r1 * s[3], -dz, normal); - vert(backSide, r2 * c[1], r2 * s[1], -dz, normal); + vert(backSide, r2 * c[1], r2 * s[1], -dz, normal); vert(backSide, r1 * c[0], r1 * s[0], -dz, normal); - + /* outward faces of teeth */ u = r2 * c[1] - r1 * c[0]; v = r2 * s[1] - r1 * s[0]; @@ -207,7 +214,7 @@ public abstract class GearsObject { normal[0] = ( r1 * s[3] - r2 * s[2] ); normal[1] = ( r1 * c[3] - r2 * c[2] ) * -1.0f ; vert(outwardFace, r2 * c[2], r2 * s[2], dz, normal); - vert(outwardFace, r2 * c[2], r2 * s[2], -dz, normal); + vert(outwardFace, r2 * c[2], r2 * s[2], -dz, normal); vert(outwardFace, r1 * c[3], r1 * s[3], dz, normal); vert(outwardFace, r1 * c[3], r1 * s[3], -dz, normal); @@ -217,7 +224,7 @@ public abstract class GearsObject { vert(outwardFace, r1 * c[3], r1 * s[3], -dz, normal); vert(outwardFace, r1 * c[0], r1 * s[0], dz, normal); vert(outwardFace, r1 * c[0], r1 * s[0], -dz, normal); - + /* inside radius cylinder */ normal[0] = c[0] * -1.0f; normal[1] = s[0] * -1.0f; @@ -232,16 +239,16 @@ public abstract class GearsObject { vert(frontFace, r0 * c[4], r0 * s[4], dz, normal); vert(frontFace, r1 * c[4], r1 * s[4], dz, normal); frontFace.seal(true); - + /* finish back face */ - normal[2] = -1.0f; + normal[2] = -1.0f; vert(backFace, r1 * c[4], r1 * s[4], -dz, normal); vert(backFace, r0 * c[4], r0 * s[4], -dz, normal); backFace.seal(true); - + backSide.seal(true); frontSide.seal(true); - + /* finish outward face */ sincos(da * 1f, s, 1, c, 1); u = r2 * c[1] - r1 * c[4]; @@ -253,7 +260,7 @@ public abstract class GearsObject { normal[1] = -u; normal[2] = 0.0f; vert(outwardFace, r1 * c[4], r1 * s[4], dz, normal); - vert(outwardFace, r1 * c[4], r1 * s[4], -dz, normal); + vert(outwardFace, r1 * c[4], r1 * s[4], -dz, normal); outwardFace.seal(true); /* finish inside radius cylinder */ @@ -265,6 +272,15 @@ public abstract class GearsObject { insideRadiusCyl.seal(true); } + @Override + public String toString() { + final int ffVBO = null != frontFace ? frontFace.getVBOName() : 0; + final int fsVBO = null != frontSide ? frontSide.getVBOName() : 0; + final int bfVBO = null != backFace ? backFace.getVBOName() : 0; + final int bsVBO = null != backSide ? backSide.getVBOName() : 0; + return "GearsObj[0x"+Integer.toHexString(hashCode())+", vbo ff "+ffVBO+", fs "+fsVBO+", bf "+bfVBO+", bs "+bsVBO+"]"; + } + static void vert(GLArrayDataServer array, float x, float y, float z, float n[]) { array.putf(x); array.putf(y); @@ -273,7 +289,7 @@ public abstract class GearsObject { array.putf(n[1]); array.putf(n[2]); } - + static void sincos(float x, float sin[], int sinIdx, float cos[], int cosIdx) { sin[sinIdx] = (float) Math.sin(x); cos[cosIdx] = (float) Math.cos(x); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsObjectES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsObjectES1.java index 89e469799..6c9587931 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsObjectES1.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsObjectES1.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 @@ -26,7 +26,6 @@ import javax.media.opengl.GL; import javax.media.opengl.GL2ES1; import javax.media.opengl.fixedfunc.GLPointerFunc; - import com.jogamp.opengl.test.junit.jogl.demos.GearsObject; import com.jogamp.opengl.util.GLArrayDataServer; @@ -42,10 +41,25 @@ public class GearsObjectES1 extends GearsObject { } @Override + public GLArrayDataServer createInterleaveClone(GLArrayDataServer ads) { + final FloatBuffer fb0 = (FloatBuffer) ads.getBuffer(); + final FloatBuffer fb1 = fb0.slice(); + // manual 'unseal' + fb1.position(fb1.limit()); + fb1.limit(fb1.capacity()); + + final GLArrayDataServer adsClone = GLArrayDataServer.createFixedInterleaved(ads.getComponentCount(), ads.getComponentType(), ads.getNormalized(), + ads.getStride(), fb1, ads.getVBOUsage()); + adsClone.setVBOName(ads.getVBOName()); + adsClone.seal(true); + return adsClone; + } + + @Override public GLArrayDataServer createInterleaved(int comps, int dataType, boolean normalized, int initialSize, int vboUsage) { return GLArrayDataServer.createFixedInterleaved(comps, dataType, normalized, initialSize, vboUsage); } - + @Override public void addInterleavedVertexAndNormalArrays(GLArrayDataServer array, int components) { array.addFixedSubArray(GLPointerFunc.GL_VERTEX_ARRAY, components, GL.GL_ARRAY_BUFFER); @@ -60,20 +74,20 @@ public class GearsObjectES1 extends GearsObject { @Override public void draw(GL _gl, float x, float y, float angle) { - GL2ES1 gl = _gl.getGL2ES1(); + GL2ES1 gl = _gl.getGL2ES1(); gl.glPushMatrix(); gl.glTranslatef(x, y, 0f); gl.glRotatef(angle, 0f, 0f, 1f); gl.glMaterialfv(GL2ES1.GL_FRONT_AND_BACK, GL2ES1.GL_AMBIENT_AND_DIFFUSE, gearColor); - + gl.glShadeModel(GL2ES1.GL_FLAT); draw(gl, frontFace, GL.GL_TRIANGLE_STRIP); draw(gl, frontSide, GL.GL_TRIANGLES); draw(gl, backFace, GL.GL_TRIANGLE_STRIP); draw(gl, backSide, GL.GL_TRIANGLES); draw(gl, outwardFace, GL.GL_TRIANGLE_STRIP); - gl.glShadeModel(GL2ES1.GL_SMOOTH); + gl.glShadeModel(GL2ES1.GL_SMOOTH); draw(gl, insideRadiusCyl, GL.GL_TRIANGLE_STRIP); gl.glPopMatrix(); - } + } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.java index c5f5f7a44..89006d28c 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.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 @@ -40,12 +40,12 @@ public class GearsObjectES2 extends GearsObject { final GLUniformData pmvMatrixUniform; final GLUniformData colorUniform; final ShaderState st; - + public GearsObjectES2(ShaderState st, FloatBuffer gearColor, float inner_radius, float outer_radius, float width, int teeth, - float tooth_depth, + float tooth_depth, PMVMatrix pmvMatrix, - GLUniformData pmvMatrixUniform, GLUniformData colorUniform) + GLUniformData pmvMatrixUniform, GLUniformData colorUniform) { super(gearColor, inner_radius, outer_radius, width, teeth, tooth_depth); this.pmvMatrix = pmvMatrix; @@ -56,9 +56,9 @@ public class GearsObjectES2 extends GearsObject { } public GearsObjectES2(GearsObjectES2 shared, - ShaderState st, + ShaderState st, PMVMatrix pmvMatrix, - GLUniformData pmvMatrixUniform, GLUniformData colorUniform) + GLUniformData pmvMatrixUniform, GLUniformData colorUniform) { super(shared); this.pmvMatrix = pmvMatrix; @@ -67,29 +67,45 @@ public class GearsObjectES2 extends GearsObject { this.st = st; associate(st); } - + private void associate(ShaderState st) { frontFace.associate(st, true); frontSide.associate(st, true); backFace.associate(st, true); backSide.associate(st, true); outwardFace.associate(st, true); - insideRadiusCyl.associate(st, true); + insideRadiusCyl.associate(st, true); + } + + @Override + public GLArrayDataServer createInterleaveClone(GLArrayDataServer ads) { + final FloatBuffer fb0 = (FloatBuffer) ads.getBuffer(); + final FloatBuffer fb1 = fb0.slice(); + // manual 'unseal' + fb1.position(fb1.limit()); + fb1.limit(fb1.capacity()); + + final GLArrayDataServer adsClone = GLArrayDataServer.createGLSLInterleaved(ads.getComponentCount(), ads.getComponentType(), ads.getNormalized(), + ads.getStride(), fb1, ads.getVBOUsage()); + adsClone.setVBOName(ads.getVBOName()); + adsClone.seal(true); + return adsClone; } @Override public GLArrayDataServer createInterleaved(int comps, int dataType, boolean normalized, int initialSize, int vboUsage) { return GLArrayDataServer.createGLSLInterleaved(comps, dataType, normalized, initialSize, vboUsage); } - + @Override public void addInterleavedVertexAndNormalArrays(GLArrayDataServer array, int components) { array.addGLSLSubArray("vertices", components, GL.GL_ARRAY_BUFFER); array.addGLSLSubArray("normals", components, GL.GL_ARRAY_BUFFER); } - private void draw(GL2ES2 gl, GLArrayDataServer array, int mode) { + private void draw(GL2ES2 gl, GLArrayDataServer array, int mode, int face) { array.enableBuffer(gl, true); + // System.err.println("XXX Draw face "+face+" of "+this); gl.glDrawArrays(mode, 0, array.getElementCount()); array.enableBuffer(gl, false); } @@ -109,13 +125,13 @@ public class GearsObjectES2 extends GearsObject { colorUniform.setData(gearColor); st.uniform(gl, colorUniform); - draw(gl, frontFace, GL.GL_TRIANGLE_STRIP); - draw(gl, frontSide, GL.GL_TRIANGLES); - draw(gl, backFace, GL.GL_TRIANGLE_STRIP); - draw(gl, backSide, GL.GL_TRIANGLES); - draw(gl, outwardFace, GL.GL_TRIANGLE_STRIP); - draw(gl, insideRadiusCyl, GL.GL_TRIANGLE_STRIP); - + draw(gl, frontFace, GL.GL_TRIANGLE_STRIP, 0); + draw(gl, frontSide, GL.GL_TRIANGLES, 1); + draw(gl, backFace, GL.GL_TRIANGLE_STRIP, 2); + draw(gl, backSide, GL.GL_TRIANGLES, 3); + draw(gl, outwardFace, GL.GL_TRIANGLE_STRIP, 4); + draw(gl, insideRadiusCyl, GL.GL_TRIANGLE_STRIP, 5); + pmvMatrix.glPopMatrix(); - } + } } 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 b1e9f477e..cd14835bb 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java @@ -735,12 +735,22 @@ public class AWTRobotUtil { * * @return True if the GLContext becomes created or not within TIME_OUT */ - public static boolean waitForCreated(GLContext context, boolean created) throws InterruptedException { - if( null == context ) { + public static boolean waitForContextCreated(GLAutoDrawable autoDrawable, boolean created) throws InterruptedException { + if( null == autoDrawable ) { return !created; } int wait; - for (wait=0; wait<POLL_DIVIDER && created != context.isCreated() ; wait++) { + for (wait=0; wait<POLL_DIVIDER ; wait++) { + final GLContext ctx = autoDrawable.getContext(); + if( created ) { + if( null != ctx && ctx.isCreated() ) { + break; + } + } else { + if( null == ctx || !ctx.isCreated() ) { + break; + } + } Thread.sleep(TIME_SLICE); } return wait<POLL_DIVIDER; |