aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-01-21 18:56:32 +0100
committerSven Gothel <[email protected]>2014-01-21 18:56:32 +0100
commit97f4ef2763596993bcb8a6b84150c9ec906dde08 (patch)
treecef35d35f7890564508a59ecbde26cfd953cddd1 /src/jogl/classes/jogamp
parent343deff48d81b0abf58c275d9e0aced12a911802 (diff)
Better shared GLAutoDrawable synchronization: Block slave instances to also block until all master's GLEventListener.init(..) methods have been called
Better shared GLAutoDrawable synchronization. Block slave instances to also block until all master's GLEventListener.init(..) methods have been called - GLSharedContextSetter: Add areAllGLEventListenerInitialized() - GLCanvas (SWT, AWT) - GLJPanel - GLAutoDrawableBase (GLWindow, ..) - GLDrawableHelper's isSharedGLContextPending(..) takes 'areAllGLEventListenerInitialized()' into consideration allowing to block the slave creation until master is completed. This solves teh use case, where the master creates resources in it's GLEventListener initialization (buffers), which are shared with it's slaves.
Diffstat (limited to 'src/jogl/classes/jogamp')
-rw-r--r--src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java5
-rw-r--r--src/jogl/classes/jogamp/opengl/GLDrawableHelper.java15
2 files changed, 19 insertions, 1 deletions
diff --git a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java
index 42d0a2ec4..7cd685d5a 100644
--- a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java
+++ b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java
@@ -510,6 +510,11 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe
}
@Override
+ public boolean areAllGLEventListenerInitialized() {
+ return helper.areAllGLEventListenerInitialized();
+ }
+
+ @Override
public boolean getGLEventListenerInitState(GLEventListener listener) {
return helper.getGLEventListenerInitState(listener);
}
diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java
index b498748fd..0e135d5e0 100644
--- a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java
+++ b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java
@@ -58,6 +58,7 @@ import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLException;
import javax.media.opengl.GLFBODrawable;
import javax.media.opengl.GLRunnable;
+import javax.media.opengl.GLSharedContextSetter;
/** Encapsulates the implementation of most of the GLAutoDrawable's
methods to be able to share it between GLAutoDrawable implementations like GLAutoDrawableBase, GLCanvas and GLJPanel. */
@@ -149,8 +150,14 @@ public class GLDrawableHelper {
final GLContext shareWith;
final boolean pending;
if ( null != sharedAutoDrawable ) {
+ final boolean allGLELInitialized;
+ if( sharedAutoDrawable instanceof GLSharedContextSetter ) {
+ allGLELInitialized = ((GLSharedContextSetter)sharedAutoDrawable).areAllGLEventListenerInitialized();
+ } else {
+ allGLELInitialized = true; // we have to assume 'yes'
+ }
shareWith = sharedAutoDrawable.getContext();
- pending = null == shareWith || !shareWith.isCreated();
+ pending = null == shareWith || !shareWith.isCreated() || !allGLELInitialized;
} else {
shareWith = sharedContext;
pending = null != shareWith && !shareWith.isCreated();
@@ -434,6 +441,12 @@ public class GLDrawableHelper {
}
}
+ public final boolean areAllGLEventListenerInitialized() {
+ synchronized(listenersLock) {
+ return 0 == listenersToBeInit.size();
+ }
+ }
+
public final boolean getGLEventListenerInitState(GLEventListener listener) {
synchronized(listenersLock) {
return !listenersToBeInit.contains(listener);