aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/javax/media/opengl/awt/GLJPanel.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/classes/javax/media/opengl/awt/GLJPanel.java')
-rw-r--r--src/classes/javax/media/opengl/awt/GLJPanel.java57
1 files changed, 55 insertions, 2 deletions
diff --git a/src/classes/javax/media/opengl/awt/GLJPanel.java b/src/classes/javax/media/opengl/awt/GLJPanel.java
index 6711a5ed2..2efae7e96 100644
--- a/src/classes/javax/media/opengl/awt/GLJPanel.java
+++ b/src/classes/javax/media/opengl/awt/GLJPanel.java
@@ -204,6 +204,13 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
}
}
+ /**
+ * Just an alias for removeNotify
+ */
+ public void destroy() {
+ removeNotify();
+ }
+
/** Overridden to cause OpenGL rendering to be performed during
repaint cycles. Subclasses which override this method must call
super.paintComponent() in their paintComponent() method in order
@@ -275,15 +282,20 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
<B>Overrides:</B>
<DL><DD><CODE>removeNotify</CODE> in class <CODE>java.awt.Component</CODE></DD></DL> */
public void removeNotify() {
- if (DEBUG) {
- System.err.println("GLJPanel.removeNotify()");
+ if(DEBUG) {
+ Exception ex1 = new Exception("removeNotify - start");
+ ex1.printStackTrace();
}
if (backend != null) {
+ drawableHelper.invokeGL(backend.getDrawable(), backend.getContext(), disposeAction, null);
backend.destroy();
backend = null;
}
isInitialized = false;
super.removeNotify();
+ if(DEBUG) {
+ System.out.println("removeNotify - end");
+ }
}
/** Overridden to cause {@link GLDrawableHelper#reshape} to be
@@ -448,7 +460,18 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
// The backend might set itself to null, indicating it punted to
// a different implementation -- try again
} while (backend == null);
+
+ if(null==closingListener) {
+ synchronized(closingListenerLock) {
+ if(null==closingListener) {
+ closingListener=GLCanvas.addClosingListener(this, new GLCanvas.DestroyMethod() {
+ public void destroyMethod() { destroy(); } });
+ }
+ }
+ }
}
+ private Object closingListener = null;
+ private Object closingListenerLock = new Object();
private void handleReshape() {
panelWidth = reshapeWidth;
@@ -481,6 +504,10 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
backend.postGL(g, false);
}
+ public void dispose(GLAutoDrawable drawable) {
+ drawableHelper.dispose(GLJPanel.this);
+ }
+
public void display(GLAutoDrawable drawable) {
if (!backend.preGL(g)) {
return;
@@ -506,6 +533,17 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
}
}
+ public String toString() {
+ return "AWT-GLJPanel[ "+((null!=backend)?backend.getDrawable().getClass().getName():"null-drawable")+", "+drawableHelper+"]";
+ }
+
+ class DisposeAction implements Runnable {
+ public void run() {
+ updater.dispose(GLJPanel.this);
+ }
+ }
+ private DisposeAction disposeAction = new DisposeAction();
+
class InitAction implements Runnable {
public void run() {
updater.init(GLJPanel.this);
@@ -579,6 +617,9 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
// Called to get the current backend's GLContext
public GLContext getContext();
+ // Called to get the current backend's GLDrawable
+ public GLDrawable getDrawable();
+
// Called to fetch the "real" chosen NWCapabilities for the backend
public NWCapabilities getChosenNWCapabilities();
@@ -816,6 +857,10 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
return offscreenContext;
}
+ public GLDrawable getDrawable() {
+ return offscreenDrawable;
+ }
+
public NWCapabilities getChosenNWCapabilities() {
if (offscreenDrawable == null) {
return null;
@@ -903,6 +948,10 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
return pbuffer.getContext();
}
+ public GLDrawable getDrawable() {
+ return pbuffer;
+ }
+
public NWCapabilities getChosenNWCapabilities() {
if (pbuffer == null) {
return null;
@@ -1070,6 +1119,10 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
return joglContext;
}
+ public GLDrawable getDrawable() {
+ return joglDrawable;
+ }
+
public NWCapabilities getChosenNWCapabilities() {
// FIXME: should do better than this; is it possible to using only platform-independent code?
return new NWCapabilities();