From bfb10d309d97c19a33f9b6758f647186f8e0ddd6 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 17 Jul 2013 06:32:52 +0200 Subject: JOGL API Doc: Remove 'JSR 231' identifier - we are no more bound to a JSR, for a long time! --- make/doc/jogl/spec-overview.html | 472 ++++++++++++++++++--------------------- 1 file changed, 215 insertions(+), 257 deletions(-) (limited to 'make/doc') diff --git a/make/doc/jogl/spec-overview.html b/make/doc/jogl/spec-overview.html index 8c9f45f8b..637b39a2e 100644 --- a/make/doc/jogl/spec-overview.html +++ b/make/doc/jogl/spec-overview.html @@ -1,25 +1,23 @@ - JSR 231 Draft Public Review Specification + JOGL Specification Overview -

JSR 231 Specification Overview

+

JOGL Specification Overview

Preface

This specification, an optional set of packages, describes the Java(TM) bindings to the native OpenGL(R) 3D graphics library profiles:
- See Inclusion Criteria explaining the OpenGL profile seperation.
+ See Inclusion Criteria explaining the OpenGL profile separation.
See OpenGL Runtime Requirements.

- A sample implementation is available as + An implementation is available as JOGL, a JogAmp module.

Other API bindings are available as JogAmp modules: @@ -31,137 +29,146 @@ bindings to the native OpenGL(R) 3D graphics library profiles:

Dependencies

This binding has dependencies to the following:


OpenGL Profile Model

- OpenGL today is not just a single set of functionality, it offers many profiles for different - purposes, e.g. ES1 and ES2 for mobile, etc.
- JOGL reflects these profiles with an OO abstraction model, + OpenGL today is not just a single set of functions, it offers many profiles for different + purposes, e.g. ES1, ES2 and ES3 for mobile, GL [ 3.1 .. 4.3 ] core for a programmable shader application, etc.
+ JOGL reflects these profiles with an OO abstraction model, specifying interfaces encapsulating common subsets.

Package Structure

The packages defined by this specification include:
-
+which are not exposed.

+

API Binding Conventions

The Java language bindings to the pre-existing C APIs in these packages have been created using a consistent set of rules. Vendor-defined extensions should make use of the same rules in order to provide a consistent developer -experience.
-
+experience. +

The rules for creating the Java language binding are described in the following sections. These rules should be followed as closely as possible for all future -APIs that share the javax.media.opengl namespace.
+APIs that share the javax.media.opengl namespace.

Function Naming

Functions are named in the same way as in the C binding. That is, an OpenGL @@ -169,25 +176,25 @@ API function glClear is bound to Java method GL.glClear. Although it would be possible to drop the gl prefix (since it is redundant with the interface name GL), the resulting code was deemed to look too foreign to experienced OpenGL developers. For the same reason, we have also carried over all type -suffixes like 3f and 3fv from methods such as glColor3f and glColor3fv, respectively.
-
+suffixes like 3f and 3fv from methods such as glColor3f and glColor3fv, respectively. +

Extension suffixes, such as EXT, ARB, and vendor-specific suffixes, are -retained so as to match C conventions.
+retained so as to match C conventions.

Mapping of Constants

Constants are named in the same way as in the C binding. For instance, -the OpenGL constant GL_RGB is bound to Java constant GL.GL_RGB.
+the OpenGL constant GL_RGB is bound to Java constant GL.GL_RGB.

Mapping of Primitive Types

All 8-bit integral types become byte, all 16-bit integral types become short, and all 32-bit integral types become int. All 32-bit floating-point -types become float and all 64-bit floating-point types become double.
-
+types become float and all 64-bit floating-point types become double. +

Integer return values that can only be GL_TRUE or GL_FALSE are mapped to -boolean.
+boolean.

Mapping of Pointer Arguments

- OpenGL functions that take pointer arguments fall into several categories:
+

OpenGL functions that take pointer arguments fall into several categories:

+

Inclusion Criteria explains the OpenGL profile separation.

+

See OpenGL Runtime Requirements.

An implementation is available as JOGL, a JogAmp module.

@@ -49,9 +49,9 @@ bindings to the native OpenGL(R) 3D graphics library profiles:

OpenGL Profile Model

OpenGL today is not just a single set of functions, it offers many profiles for different - purposes, e.g. ES1, ES2 and ES3 for mobile, GL [ 3.1 .. 4.3 ] core for a programmable shader application, etc.
- JOGL reflects these profiles with an OO abstraction model, - specifying interfaces encapsulating common subsets.
+ purposes, e.g. ES1, ES2 and ES3 for mobile, GL [ 3.1 .. 4.3 ] core for a programmable shader application, etc. +

JOGL reflects these profiles with an OO abstraction model, + specifying interfaces encapsulating common subsets.

Package Structure

The packages defined by this specification include:
-- cgit v1.2.3 From ff3832bf24f02fc44a7494be49d210cacce43977 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 27 Oct 2013 10:16:25 +0100 Subject: spec-overview.html: Shared OpenGL context must be supported .. (GL spec) --- make/doc/jogl/spec-overview.html | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'make/doc') diff --git a/make/doc/jogl/spec-overview.html b/make/doc/jogl/spec-overview.html index 6284cde63..952e8f8e0 100644 --- a/make/doc/jogl/spec-overview.html +++ b/make/doc/jogl/spec-overview.html @@ -329,17 +329,8 @@ to the underlying native engine.

Sharing of Server-Side OpenGL Objects between GLContexts

-Sharing of server-side OpenGL objects such as textures and display -lists among OpenGL contexts is supported in this specification. -However, the specification does not guarantee that a request to share -objects between two contexts will succeed. Certain OpenGL -implementations restrict sharing in certain ways. Applications should -assume that sharing is a request more than an assertion. -Implementations of this specification should, but are not required to, -provide timely notification of a failure of a request to share objects -between two GLContexts, perhaps in the form of a GLException. The -situation in which sharing is most likely to work on all platforms is -between two GLContexts associated with the same GLDrawable. +Sharing of server-side OpenGL objects such as buffer objects, e.g. VBOs, +and textures among OpenGL contexts is supported in this specification.

Criteria Used for Inclusion of APIs into the Java Bindings

-- cgit v1.2.3 From bcfaa149b9803ce33c5a356cbcb45f7dfd3e4361 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 28 Oct 2013 03:58:01 +0100 Subject: 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! --- make/build-test.xml | 42 +++++++- make/doc/jogl/spec-overview.html | 5 + make/scripts/tests-win.bat | 43 +++++--- make/scripts/tests.sh | 7 +- .../com/jogamp/opengl/util/GLArrayDataServer.java | 45 ++++++++ .../javax/media/opengl/GLDrawableFactory.java | 4 +- .../javax/media/opengl/GLSharedContextSetter.java | 30 +++++- .../classes/javax/media/opengl/awt/GLCanvas.java | 2 +- .../classes/javax/media/opengl/awt/GLJPanel.java | 11 +- .../jogl/acore/TestSharedContextVBOES1NEWT.java | 4 +- .../jogl/acore/TestSharedContextVBOES2AWT3.java | 114 ++++++++++++++++++--- .../jogl/acore/TestSharedContextVBOES2AWT3b.java | 24 ++--- .../jogl/acore/TestSharedContextVBOES2NEWT0.java | 8 +- .../jogl/acore/TestSharedContextVBOES2NEWT1.java | 22 ++-- .../jogl/acore/TestSharedContextVBOES2NEWT2.java | 69 ++++++++++--- .../jogl/acore/TestSharedContextVBOES2NEWT3.java | 64 +++++++++--- .../opengl/test/junit/jogl/demos/GearsObject.java | 84 +++++++++------ .../test/junit/jogl/demos/es1/GearsObjectES1.java | 30 ++++-- .../test/junit/jogl/demos/es2/GearsObjectES2.java | 54 ++++++---- .../opengl/test/junit/util/AWTRobotUtil.java | 16 ++- 20 files changed, 511 insertions(+), 167 deletions(-) (limited to 'make/doc') 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 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -487,7 +525,7 @@ - + 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.

Sharing of server-side OpenGL objects such as buffer objects, e.g. VBOs, and textures among OpenGL contexts is supported in this specification. +

+See {@link javax.media.opengl.GLSharedContextSetter GLSharedContextSetter} interface +for details. +

+

Criteria Used for Inclusion of APIs into the Java Bindings

OpenGL API Inclusion Criteria

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 @@ -230,6 +230,28 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE return ads; } + /** + * Create a VBO for fixed function interleaved array data + * starting with a given Buffer object incl it's stride + *

User needs to configure the interleaved segments via {@link #addFixedSubArray(int, int, int)}.

+ * + * @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)}). *

@@ -286,6 +308,29 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE return ads; } + /** + * Create a VBO for GLSL interleaved array data + * starting with a given Buffer object incl it's stride + *

User needs to configure the interleaved segments via {@link #addGLSLSubArray(int, int, int)}.

+ * + * @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)}). *

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. *

* - * See the note in the overview documentation on - * context sharing. + * See the note in the overview documentation in {@link GLSharedContextSetter} and on + * context sharing. * * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null 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}. *

- * 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. + *

+ *

+ * A master {@link GLContext} is the {@link GLContext} which is created first, + * shared {@link GLContext} w/ this master are referred as slave {@link GLContext}. + *

+ *
Driver stability constraints
+ *

+ * Be aware that the master {@link GLContext} and related resources, i.e. the {@link GLAutoDrawable}, + * shall not be destroyed before it's slave {@link GLContext} instances.
+ * Otherwise the OpenGL driver implementation may crash w/ SIGSEGV if shared resources are still used!
+ * Note that this is not specified within OpenGL and should work, 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.
+ * 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. + *

+ *

+ * Users may use a {@link GLDrawableFactory#createDummyDrawable(javax.media.nativewindow.AbstractGraphicsDevice, boolean, GLProfile) dummy} + * {@link GLDrawable} and it's {@link GLContext} as the master of all shared slave {@link GLContext}. + * Same constraints as above apply, i.e. it shall be destroyed after all shared slaves. *

*/ public interface GLSharedContextSetter extends GLAutoDrawable { @@ -46,6 +68,9 @@ public interface GLSharedContextSetter extends GLAutoDrawable { * A set sharedContext will block context creation, i.e. {@link GLAutoDrawable#initialization GLAutoDrawable initialization}, * as long it is not {@link GLContext#isCreated() created natively}. *

+ *

+ * See driver stability constraints. + *

* * @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 null * or has not been {@link GLContext#isCreated() created natively}. *

+ *

+ * See driver stability constraints. + *

* * @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 context + href="../../../spec-overview.html#SHARING">context sharing. 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 - 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. + 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 - 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. 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 ctx1Shares = ctx1.getCreatedShares(); final List 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 ctx1Shares = ctx1.getCreatedShares(); final List 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 ctx1Shares = ctx1.getCreatedShares(); final List 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; @@ -41,11 +40,26 @@ public class GearsObjectES1 extends GearsObject { super(gearColor, inner_radius, outer_radius, width, teeth, tooth_depth); } + @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