summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java16
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java6
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLCanvas.java58
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLJPanel.java40
4 files changed, 73 insertions, 47 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java
index 82f57f33e..3d213c54b 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java
@@ -236,23 +236,9 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
System.err.println("!!! Screen : "+sharedScreen);
}
- // may cause JVM SIGSEGV ?
- // X11Util.closePendingDisplayConnections();
-
sharedResourcesRunner.releaseAndWait();
- if(X11Util.getOpenDisplayConnectionNumber() > 0) {
- System.err.println("X11GLXDrawableFactory.shutdown(): Open (no close attempt) X11 Display Connection");
- X11Util.dumpOpenDisplayConnections();
- }
-
- if(X11Util.getPendingDisplayConnectionNumber()>0) {
- System.err.println("X11GLXDrawableFactory.shutdown(): Pending X11 Display Connection");
- X11Util.dumpPendingDisplayConnections();
- }
-
- // don't close pending XDisplay, since this might be a different thread as the opener
- X11Util.shutdown( false, DEBUG );
+ X11Util.shutdown( true, DEBUG );
}
protected GLDrawableImpl createOnscreenDrawableImpl(NativeSurface target) {
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java
index 225dc25a4..4b5b72cc6 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java
@@ -83,7 +83,7 @@ public class X11AWTGLXGraphicsConfigurationFactory extends GraphicsConfiguration
long displayHandle = X11SunJDKReflection.graphicsDeviceGetDisplay(device);
if(0==displayHandle) {
- displayHandle = X11Util.createThreadLocalDisplay(null);
+ displayHandle = X11Util.createDisplay(null);
if(DEBUG) {
System.err.println("X11AWTGLXGraphicsConfigurationFactory: using a thread local X11 display");
}
@@ -91,10 +91,12 @@ public class X11AWTGLXGraphicsConfigurationFactory extends GraphicsConfiguration
if(DEBUG) {
System.err.println("X11AWTGLXGraphicsConfigurationFactory: using AWT X11 display 0x"+Long.toHexString(displayHandle));
}
+ String name = X11Util.XDisplayString(displayHandle);
+ displayHandle = X11Util.createDisplay(name);
}
((AWTGraphicsDevice)awtScreen.getDevice()).setSubType(NativeWindowFactory.TYPE_X11, displayHandle);
X11GraphicsDevice x11Device = new X11GraphicsDevice(displayHandle);
-
+ x11Device.setCloseDisplay(true);
X11GraphicsScreen x11Screen = new X11GraphicsScreen(x11Device, awtScreen.getIndex());
if(DEBUG) {
System.err.println("X11AWTGLXGraphicsConfigurationFactory: made "+x11Screen);
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
index c165a4833..d2a20f467 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
@@ -49,6 +49,7 @@ import com.jogamp.opengl.impl.*;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Component;
+import java.awt.EventQueue;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.GraphicsConfiguration;
@@ -328,6 +329,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
// Workaround for termination issues with applets --
// sun.applet.AppletPanel should probably be performing the
// remove() call on the EDT rather than on its own thread
+ // Hint: User should run remove from EDT.
if (ThreadingImpl.isAWTMode() &&
Thread.holdsLock(getTreeLock())) {
// The user really should not be invoking remove() from this
@@ -347,6 +349,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
animator.resume();
}
}
+ if(!regenerate) {
+ disposeAbstractGraphicsDeviceAction.run();
+ }
if(DEBUG) {
System.err.println("dispose("+regenerate+") - stop");
@@ -401,6 +406,10 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
<B>Overrides:</B>
<DL><DD><CODE>addNotify</CODE> in class <CODE>java.awt.Component</CODE></DD></DL> */
public void addNotify() {
+ if(DEBUG) {
+ Exception ex1 = new Exception(Thread.currentThread().getName()+" - Info: addNotify - start");
+ ex1.printStackTrace();
+ }
super.addNotify();
if (!Beans.isDesignTime()) {
disableBackgroundErase();
@@ -419,8 +428,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
try {
awtConfig = chooseGraphicsConfiguration(capabilities, chooser, device);
if(DEBUG) {
- Exception e = new Exception("Info: Created Config: "+awtConfig);
- e.printStackTrace();
+ System.err.println(Thread.currentThread().getName()+" - Created Config: "+awtConfig);
}
if(null!=awtConfig) {
// update ..
@@ -444,21 +452,25 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
}
if(DEBUG) {
- System.err.println("Created Drawable: "+drawable);
+ System.err.println(Thread.currentThread().getName()+" - Created Drawable: "+drawable);
}
}
+ if(DEBUG) {
+ System.err.println(Thread.currentThread().getName()+" - Info: addNotify - end");
+ }
}
- /** Overridden to track when this component is removed from a
+ /** <p>Overridden to track when this component is removed from a
container. Subclasses which override this method must call
super.removeNotify() in their removeNotify() method in order to
- function properly. <P>
-
+ function properly. </p>
+ <p>User shall not call this method outside of EDT, read the AWT/Swing specs
+ about this.</p>
<B>Overrides:</B>
<DL><DD><CODE>removeNotify</CODE> in class <CODE>java.awt.Component</CODE></DD></DL> */
public void removeNotify() {
if(DEBUG) {
- Exception ex1 = new Exception("Info: removeNotify - start");
+ Exception ex1 = new Exception(Thread.currentThread().getName()+" - Info: removeNotify - start");
ex1.printStackTrace();
}
@@ -473,7 +485,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
}
}
if(DEBUG) {
- System.err.println("Info: removeNotify - end");
+ System.err.println(Thread.currentThread().getName()+" - Info: removeNotify - end");
}
}
@@ -609,14 +621,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
}
}
- private boolean disposeRegenerate;
- private DisposeAction disposeAction = new DisposeAction(this);
-
class DisposeAction implements Runnable {
- private GLCanvas canvas;
- public DisposeAction(GLCanvas canvas) {
- this.canvas = canvas;
- }
public void run() {
drawableHelper.dispose(GLCanvas.this);
@@ -632,7 +637,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
if(disposeRegenerate) {
// recreate GLDrawable to reflect it's new graphics configuration
- drawable = GLDrawableFactory.getFactory(glProfile).createGLDrawable(NativeWindowFactory.getNativeWindow(canvas, awtConfig));
+ drawable = GLDrawableFactory.getFactory(glProfile).createGLDrawable(NativeWindowFactory.getNativeWindow(GLCanvas.this, awtConfig));
if(DEBUG) {
System.err.println("GLCanvas.dispose(true): new drawable: "+drawable);
}
@@ -643,6 +648,8 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
}
}
}
+ private boolean disposeRegenerate;
+ private DisposeAction disposeAction = new DisposeAction();
private DisposeOnEventDispatchThreadAction disposeOnEventDispatchThreadAction =
new DisposeOnEventDispatchThreadAction();
@@ -653,6 +660,25 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
}
}
+ class DisposeAbstractGraphicsDeviceAction implements Runnable {
+ public void run() {
+ AbstractGraphicsConfiguration aconfig = (null!=awtConfig) ? awtConfig.getNativeGraphicsConfiguration() : null;
+ AbstractGraphicsScreen ascreen = (null!=aconfig) ? aconfig.getScreen() : null;
+ AbstractGraphicsDevice adevice = (null!=ascreen) ? ascreen.getDevice() : null;
+ if(null!=adevice) {
+ String adeviceMsg=null;
+ if(DEBUG) {
+ adeviceMsg = adevice.toString();
+ }
+ boolean closed = adevice.close();
+ if(DEBUG) {
+ System.err.println("GLCanvas.dispose(false): closed GraphicsDevice: "+adeviceMsg+", result: "+closed);
+ }
+ }
+ }
+ }
+ DisposeAbstractGraphicsDeviceAction disposeAbstractGraphicsDeviceAction = new DisposeAbstractGraphicsDeviceAction();
+
class InitAction implements Runnable {
public void run() {
drawableHelper.init(GLCanvas.this);
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
index 10aeefaf5..b9bbf71c2 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
@@ -631,22 +631,34 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
private DisposeAction disposeAction = new DisposeAction();
class DisposeAction implements Runnable {
- public void run() {
- updater.dispose(GLJPanel.this);
+ public void run() {
+ updater.dispose(GLJPanel.this);
- if(null!=disposeContext) {
- disposeContext.destroy();
- disposeContext=null;
- }
- if(null!=disposeDrawable) {
- disposeDrawable.setRealized(false);
- }
- if(disposeRegenerate && null!=disposeDrawable) {
- disposeDrawable.setRealized(true);
- disposeContext = (GLContextImpl) disposeDrawable.createContext(shareWith);
- disposeContext.setSynchronized(true);
+ if (null != disposeContext) {
+ disposeContext.destroy();
+ disposeContext = null;
+ }
+ if (null != disposeDrawable) {
+ disposeDrawable.setRealized(false);
+ }
+ if (null != disposeDrawable) {
+ if (disposeRegenerate) {
+ disposeDrawable.setRealized(true);
+ disposeContext = (GLContextImpl) disposeDrawable.createContext(shareWith);
+ disposeContext.setSynchronized(true);
+ } else {
+ AbstractGraphicsDevice adevice = disposeDrawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration().getScreen().getDevice();
+ String adeviceMsg=null;
+ if(DEBUG) {
+ adeviceMsg = adevice.toString();
+ }
+ boolean closed = adevice.close();
+ if (DEBUG) {
+ System.err.println("GLJPanel.dispose(false): closed GraphicsDevice: " + adeviceMsg + ", result: " + closed);
+ }
+ }
+ }
}
- }
}
private DisposeOnEventDispatchThreadAction disposeOnEventDispatchThreadAction =