aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xsrc/net/java/games/jogl/impl/GLContextImpl.java2
-rw-r--r--src/net/java/games/jogl/impl/GLDrawableHelper.java4
-rw-r--r--src/net/java/games/jogl/impl/GLPbufferImpl.java19
-rwxr-xr-xsrc/net/java/games/jogl/impl/SingleThreadedWorkaround.java18
-rwxr-xr-xsrc/net/java/games/jogl/impl/macosx/MacOSXGLDrawableFactory.java11
-rw-r--r--src/net/java/games/jogl/impl/windows/WindowsGLContext.java5
-rwxr-xr-xsrc/net/java/games/jogl/impl/windows/WindowsGLDrawableFactory.java12
-rw-r--r--src/net/java/games/jogl/impl/x11/X11GLContext.java2
-rwxr-xr-xsrc/net/java/games/jogl/impl/x11/X11GLDrawableFactory.java13
-rw-r--r--src/net/java/games/jogl/impl/x11/X11PbufferGLDrawable.java6
10 files changed, 42 insertions, 50 deletions
diff --git a/src/net/java/games/jogl/impl/GLContextImpl.java b/src/net/java/games/jogl/impl/GLContextImpl.java
index 1729cbbd2..7be7a81af 100755
--- a/src/net/java/games/jogl/impl/GLContextImpl.java
+++ b/src/net/java/games/jogl/impl/GLContextImpl.java
@@ -224,7 +224,7 @@ public abstract class GLContextImpl extends GLContext {
functionAvailability.flush();
if (DEBUG) {
- System.err.println(getThreadName() + ": !!! Initializing OpenGL extension address table");
+ System.err.println(getThreadName() + ": !!! Initializing OpenGL extension address table for " + this);
}
resetProcAddressTable(getGLProcAddressTable());
if (!haveResetGLUProcAddressTable) {
diff --git a/src/net/java/games/jogl/impl/GLDrawableHelper.java b/src/net/java/games/jogl/impl/GLDrawableHelper.java
index 0542b4db8..317372cf2 100644
--- a/src/net/java/games/jogl/impl/GLDrawableHelper.java
+++ b/src/net/java/games/jogl/impl/GLDrawableHelper.java
@@ -127,7 +127,9 @@ public class GLDrawableHelper {
}
runnable.run();
if (autoSwapBufferMode) {
- drawable.swapBuffers();
+ if (drawable != null) {
+ drawable.swapBuffers();
+ }
}
}
} finally {
diff --git a/src/net/java/games/jogl/impl/GLPbufferImpl.java b/src/net/java/games/jogl/impl/GLPbufferImpl.java
index fbbf6c519..35a8ac79f 100644
--- a/src/net/java/games/jogl/impl/GLPbufferImpl.java
+++ b/src/net/java/games/jogl/impl/GLPbufferImpl.java
@@ -198,22 +198,9 @@ public class GLPbufferImpl implements GLPbuffer {
private void maybeDoSingleThreadedWorkaround(Runnable eventDispatchThreadAction,
Runnable invokeGLAction,
boolean isReshape) {
- if (SingleThreadedWorkaround.doWorkaround() && !EventQueue.isDispatchThread()) {
- try {
- // Reshape events must not block on the event queue due to the
- // possibility of deadlocks during initial component creation.
- // This solution is not optimal, because it changes the
- // semantics of reshape() to have some of the processing being
- // done asynchronously, but at least it preserves the
- // semantics of the single-threaded workaround.
- if (!isReshape) {
- EventQueue.invokeAndWait(eventDispatchThreadAction);
- } else {
- EventQueue.invokeLater(eventDispatchThreadAction);
- }
- } catch (Exception e) {
- throw new GLException(e);
- }
+ if (SingleThreadedWorkaround.doWorkaround() &&
+ !SingleThreadedWorkaround.isOpenGLThread()) {
+ SingleThreadedWorkaround.invokeOnOpenGLThread(eventDispatchThreadAction);
} else {
drawableHelper.invokeGL(pbufferDrawable, context, invokeGLAction, initAction);
}
diff --git a/src/net/java/games/jogl/impl/SingleThreadedWorkaround.java b/src/net/java/games/jogl/impl/SingleThreadedWorkaround.java
index f19c1fb67..6019cea9c 100755
--- a/src/net/java/games/jogl/impl/SingleThreadedWorkaround.java
+++ b/src/net/java/games/jogl/impl/SingleThreadedWorkaround.java
@@ -39,9 +39,13 @@
package net.java.games.jogl.impl;
+import java.awt.EventQueue;
+import java.lang.reflect.InvocationTargetException;
import java.security.AccessController;
import java.security.PrivilegedAction;
+import net.java.games.jogl.*;
+
/** Encapsulates the workaround of running all display operations on
the AWT event queue thread for the purposes of working around
problems seen primarily on ATI cards when rendering into a surface
@@ -107,6 +111,20 @@ public class SingleThreadedWorkaround {
return singleThreadedWorkaround;
}
+ public static boolean isOpenGLThread() {
+ return EventQueue.isDispatchThread();
+ }
+
+ public static void invokeOnOpenGLThread(Runnable r) throws GLException {
+ try {
+ EventQueue.invokeAndWait(r);
+ } catch (InvocationTargetException e) {
+ throw new GLException(e.getTargetException());
+ } catch (InterruptedException e) {
+ throw new GLException(e);
+ }
+ }
+
private static void printWorkaroundNotice() {
if (singleThreadedWorkaround && Debug.verbose()) {
System.err.println("Using single-threaded workaround of dispatching display() on event thread");
diff --git a/src/net/java/games/jogl/impl/macosx/MacOSXGLDrawableFactory.java b/src/net/java/games/jogl/impl/macosx/MacOSXGLDrawableFactory.java
index 019e0c30d..1c649e279 100755
--- a/src/net/java/games/jogl/impl/macosx/MacOSXGLDrawableFactory.java
+++ b/src/net/java/games/jogl/impl/macosx/MacOSXGLDrawableFactory.java
@@ -121,14 +121,9 @@ public class MacOSXGLDrawableFactory extends GLDrawableFactoryImpl {
}
private void maybeDoSingleThreadedWorkaround(Runnable action) {
- if (SingleThreadedWorkaround.doWorkaround() && !EventQueue.isDispatchThread()) {
- try {
- EventQueue.invokeAndWait(action);
- } catch (InvocationTargetException e) {
- throw new GLException(e.getTargetException());
- } catch (InterruptedException e) {
- throw new GLException(e);
- }
+ if (SingleThreadedWorkaround.doWorkaround() &&
+ !SingleThreadedWorkaround.isOpenGLThread()) {
+ SingleThreadedWorkaround.invokeOnOpenGLThread(action);
} else {
action.run();
}
diff --git a/src/net/java/games/jogl/impl/windows/WindowsGLContext.java b/src/net/java/games/jogl/impl/windows/WindowsGLContext.java
index c1bde5193..1a8e3b7a1 100644
--- a/src/net/java/games/jogl/impl/windows/WindowsGLContext.java
+++ b/src/net/java/games/jogl/impl/windows/WindowsGLContext.java
@@ -117,8 +117,9 @@ public class WindowsGLContext extends GLContextImpl {
}
// Windows can set up sharing of display lists after creation time
WindowsGLContext other = (WindowsGLContext) GLContextShareSet.getShareContext(this);
+ long hglrc2 = 0;
if (other != null) {
- long hglrc2 = other.getHGLRC();
+ hglrc2 = other.getHGLRC();
if (hglrc2 == 0) {
throw new GLException("GLContextShareSet returned an invalid OpenGL context");
}
@@ -130,7 +131,7 @@ public class WindowsGLContext extends GLContextImpl {
}
GLContextShareSet.contextCreated(this);
if (DEBUG) {
- System.err.println(getThreadName() + ": !!! Created OpenGL context " + toHexString(hglrc) + " for " + this + ", device context " + toHexString(drawable.getHDC()));
+ System.err.println(getThreadName() + ": !!! Created OpenGL context " + toHexString(hglrc) + " for " + this + ", device context " + toHexString(drawable.getHDC()) + ", sharing with " + toHexString(hglrc2));
}
}
diff --git a/src/net/java/games/jogl/impl/windows/WindowsGLDrawableFactory.java b/src/net/java/games/jogl/impl/windows/WindowsGLDrawableFactory.java
index 8e97d5e0c..b43971ca1 100755
--- a/src/net/java/games/jogl/impl/windows/WindowsGLDrawableFactory.java
+++ b/src/net/java/games/jogl/impl/windows/WindowsGLDrawableFactory.java
@@ -40,7 +40,6 @@
package net.java.games.jogl.impl.windows;
import java.awt.Component;
-import java.awt.EventQueue;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.Rectangle;
@@ -259,14 +258,9 @@ public class WindowsGLDrawableFactory extends GLDrawableFactoryImpl {
}
private void maybeDoSingleThreadedWorkaround(Runnable action) {
- if (SingleThreadedWorkaround.doWorkaround() && !EventQueue.isDispatchThread()) {
- try {
- EventQueue.invokeAndWait(action);
- } catch (InvocationTargetException e) {
- throw new GLException(e.getTargetException());
- } catch (InterruptedException e) {
- throw new GLException(e);
- }
+ if (SingleThreadedWorkaround.doWorkaround() &&
+ !SingleThreadedWorkaround.isOpenGLThread()) {
+ SingleThreadedWorkaround.invokeOnOpenGLThread(action);
} else {
action.run();
}
diff --git a/src/net/java/games/jogl/impl/x11/X11GLContext.java b/src/net/java/games/jogl/impl/x11/X11GLContext.java
index 112f8a709..44233188b 100644
--- a/src/net/java/games/jogl/impl/x11/X11GLContext.java
+++ b/src/net/java/games/jogl/impl/x11/X11GLContext.java
@@ -128,6 +128,8 @@ public abstract class X11GLContext extends GLContextImpl {
}
protected int makeCurrentImpl() throws GLException {
+ // FIXME: in offscreen (non-pbuffer) case this is run without the
+ // AWT lock held
boolean created = false;
if (context == 0) {
create();
diff --git a/src/net/java/games/jogl/impl/x11/X11GLDrawableFactory.java b/src/net/java/games/jogl/impl/x11/X11GLDrawableFactory.java
index 01050468d..f7c472c6b 100755
--- a/src/net/java/games/jogl/impl/x11/X11GLDrawableFactory.java
+++ b/src/net/java/games/jogl/impl/x11/X11GLDrawableFactory.java
@@ -40,10 +40,8 @@
package net.java.games.jogl.impl.x11;
import java.awt.Component;
-import java.awt.EventQueue;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
-import java.lang.reflect.InvocationTargetException;
import java.security.*;
import java.util.ArrayList;
import java.util.List;
@@ -411,14 +409,9 @@ public class X11GLDrawableFactory extends GLDrawableFactoryImpl {
}
private void maybeDoSingleThreadedWorkaround(Runnable action) {
- if (SingleThreadedWorkaround.doWorkaround() && !EventQueue.isDispatchThread()) {
- try {
- EventQueue.invokeAndWait(action);
- } catch (InvocationTargetException e) {
- throw new GLException(e.getTargetException());
- } catch (InterruptedException e) {
- throw new GLException(e);
- }
+ if (SingleThreadedWorkaround.doWorkaround() &&
+ !SingleThreadedWorkaround.isOpenGLThread()) {
+ SingleThreadedWorkaround.invokeOnOpenGLThread(action);
} else {
action.run();
}
diff --git a/src/net/java/games/jogl/impl/x11/X11PbufferGLDrawable.java b/src/net/java/games/jogl/impl/x11/X11PbufferGLDrawable.java
index 9294d3954..e934b8bd1 100644
--- a/src/net/java/games/jogl/impl/x11/X11PbufferGLDrawable.java
+++ b/src/net/java/games/jogl/impl/x11/X11PbufferGLDrawable.java
@@ -188,13 +188,13 @@ public class X11PbufferGLDrawable extends X11GLDrawable {
if (fbConfigs == null || fbConfigs.length == 0 || fbConfigs[0] == null) {
throw new GLException("pbuffer creation error: glXChooseFBConfig() failed");
}
- // Note that we currently don't allow selection of anything but
- // the first GLXFBConfig in the returned list
- GLXFBConfig fbConfig = fbConfigs[0];
int nelements = nelementsTmp[0];
if (nelements <= 0) {
throw new GLException("pbuffer creation error: couldn't find a suitable frame buffer configuration");
}
+ // Note that we currently don't allow selection of anything but
+ // the first GLXFBConfig in the returned list
+ GLXFBConfig fbConfig = fbConfigs[0];
if (DEBUG) {
System.err.println("Found " + fbConfigs.length + " matching GLXFBConfigs");