diff options
Diffstat (limited to 'src/classes')
12 files changed, 75 insertions, 84 deletions
diff --git a/src/classes/com/sun/javafx/newt/GLWindow.java b/src/classes/com/sun/javafx/newt/GLWindow.java index f7aedcf2a..c8c707e98 100644 --- a/src/classes/com/sun/javafx/newt/GLWindow.java +++ b/src/classes/com/sun/javafx/newt/GLWindow.java @@ -142,7 +142,7 @@ public class GLWindow extends Window implements GLAutoDrawable { context.destroy(); } if (drawable != null) { - drawable.destroy(); + drawable.setRealized(false); } window.close(); @@ -461,10 +461,6 @@ public class GLWindow extends Window implements GLAutoDrawable { public void setRealized(boolean realized) { } - public void destroy() { - close(); - } - public GLCapabilities getChosenGLCapabilities() { if (drawable == null) return null; diff --git a/src/classes/com/sun/opengl/impl/GLDrawableImpl.java b/src/classes/com/sun/opengl/impl/GLDrawableImpl.java index 0c60d6d09..0818ac1c4 100644 --- a/src/classes/com/sun/opengl/impl/GLDrawableImpl.java +++ b/src/classes/com/sun/opengl/impl/GLDrawableImpl.java @@ -61,8 +61,8 @@ public abstract class GLDrawableImpl implements GLDrawable { /** For offscreen GLDrawables (pbuffers and "pixmap" drawables), indicates that native resources should be reclaimed. */ - public void destroy() throws GLException { - setRealized(false); + public void destroy() { + throw new GLException("Should not call this (should only be called for offscreen GLDrawables)"); } public void swapBuffers() throws GLException { diff --git a/src/classes/com/sun/opengl/impl/egl/EGLDrawable.java b/src/classes/com/sun/opengl/impl/egl/EGLDrawable.java index cc80a9957..215c6ed28 100755 --- a/src/classes/com/sun/opengl/impl/egl/EGLDrawable.java +++ b/src/classes/com/sun/opengl/impl/egl/EGLDrawable.java @@ -56,48 +56,12 @@ public class EGLDrawable extends GLDrawableImpl { surface=EGL.EGL_NO_SURFACE; display=0; config=null; - - if( GLReflection.instanceOf(component, "com.sun.javafx.newt.kd.KDWindow") ) { - // KDWindows holds already determined EGL values - display = component.getDisplayHandle(); - if(display==0) { - throw new GLException("KDWindow has null display"); - } - if (display == EGL.EGL_NO_DISPLAY) { - throw new GLException("KDWindow has EGL_NO_DISPLAY"); - } - Long setConfigID = new Long(component.getVisualID()); - if( 0 <= setConfigID.longValue() && setConfigID.longValue() <= Integer.MAX_VALUE ) { - config = new EGLConfig(display, setConfigID.intValue()); - } else { - throw new GLException("KDWindow has invalid visualID/configID"); - } - } else { - display = EGL.eglGetDisplay((0!=component.getDisplayHandle())?component.getDisplayHandle():EGL.EGL_DEFAULT_DISPLAY); - if (display == EGL.EGL_NO_DISPLAY) { - throw new GLException("eglGetDisplay failed"); - } - if (!EGL.eglInitialize(display, null, null)) { - throw new GLException("eglInitialize failed"); - } - config = new EGLConfig(display, requestedCapabilities); - } - setChosenGLCapabilities(config.getCapabilities()); } public long getDisplay() { return display; } - public void destroy() { - setRealized(false); - if(EGL.EGL_NO_DISPLAY!=display) { - EGL.eglTerminate(display); - display=EGL.EGL_NO_DISPLAY; - } - super.destroy(); - } - public EGLConfig getEGLConfig() { return config; } @@ -127,17 +91,42 @@ public class EGLDrawable extends GLDrawableImpl { public void setRealized(boolean realized) { if (realized) { - // setSurface(); - } else if( surface != EGL.EGL_NO_SURFACE ) { + if (GLReflection.instanceOf(component, "com.sun.javafx.newt.kd.KDWindow")) { + // KDWindows holds already determined EGL values + display = component.getDisplayHandle(); + if (display==0) { + throw new GLException("KDWindow has null display"); + } + if (display == EGL.EGL_NO_DISPLAY) { + throw new GLException("KDWindow has EGL_NO_DISPLAY"); + } + Long setConfigID = new Long(component.getVisualID()); + if ( 0 <= setConfigID.longValue() && setConfigID.longValue() <= Integer.MAX_VALUE ) { + config = new EGLConfig(display, setConfigID.intValue()); + } else { + throw new GLException("KDWindow has invalid visualID/configID"); + } + } else { + display = EGL.eglGetDisplay((0!=component.getDisplayHandle())?component.getDisplayHandle():EGL.EGL_DEFAULT_DISPLAY); + if (display == EGL.EGL_NO_DISPLAY) { + throw new GLException("eglGetDisplay failed"); + } + if (!EGL.eglInitialize(display, null, null)) { + throw new GLException("eglInitialize failed"); + } + config = new EGLConfig(display, getRequestedGLCapabilities()); + } + setChosenGLCapabilities(config.getCapabilities()); + } else if (surface != EGL.EGL_NO_SURFACE) { // Destroy the window surface - // FIXME: we should expose a destroy() method on - // GLDrawable and get rid of setRealized(), instead - // destroying and re-creating the GLDrawable associated - // with for example a GLCanvas each time if (!EGL.eglDestroySurface(display, surface)) { throw new GLException("Error destroying window surface (eglDestroySurface)"); } surface = EGL.EGL_NO_SURFACE; + if (EGL.EGL_NO_DISPLAY!=display) { + EGL.eglTerminate(display); + display=EGL.EGL_NO_DISPLAY; + } } super.setRealized(realized); } diff --git a/src/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java b/src/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java index 81f4abb8f..067e9d903 100644 --- a/src/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java +++ b/src/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java @@ -75,7 +75,6 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { System.err.println("Destroyed pbuffer: " + pBuffer); } } - super.destroy(); } public long getPbuffer() { diff --git a/src/classes/com/sun/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java b/src/classes/com/sun/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java index bfd23bb0a..85447f00b 100644 --- a/src/classes/com/sun/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java +++ b/src/classes/com/sun/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java @@ -96,6 +96,5 @@ public class WindowsDummyWGLDrawable extends WindowsWGLDrawable { WGL.DestroyWindow(hwnd); hwnd = 0; } - super.destroy(); } } diff --git a/src/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java b/src/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java index 724f64b9c..03b52be9f 100644 --- a/src/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java +++ b/src/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java @@ -122,6 +122,5 @@ public class WindowsOffscreenWGLDrawable extends WindowsWGLDrawable { nw.setSurfaceHandle(0); setChosenGLCapabilities(null); } - super.destroy(); } } diff --git a/src/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java b/src/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java index a13592d62..076031093 100644 --- a/src/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java +++ b/src/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java @@ -96,7 +96,6 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { buffer = 0; setChosenGLCapabilities(null); } - super.destroy(); } public long getPbuffer() { diff --git a/src/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java b/src/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java index 035b86708..d0d03d06b 100644 --- a/src/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java +++ b/src/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java @@ -133,7 +133,6 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable { } finally { getFactoryImpl().unlockToolkit(); } - super.destroy(); } public boolean isDoubleBuffered() { diff --git a/src/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java b/src/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java index db3dbc47f..390ca96a4 100644 --- a/src/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java +++ b/src/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java @@ -90,7 +90,6 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable { } finally { getFactoryImpl().unlockToolkit(); } - super.destroy(); } private void createPbuffer() { diff --git a/src/classes/javax/media/opengl/GLDrawable.java b/src/classes/javax/media/opengl/GLDrawable.java index 219af33c4..50c95e688 100644 --- a/src/classes/javax/media/opengl/GLDrawable.java +++ b/src/classes/javax/media/opengl/GLDrawable.java @@ -83,32 +83,52 @@ public interface GLDrawable { /** * Indicates to on-screen GLDrawable implementations whether the - * underlying window has been created and can be drawn into. This - * method must be called from GLDrawables obtained from the - * GLDrawableFactory via the {@link GLDrawableFactory#getGLDrawable - * GLDrawableFactory.getGLDrawable()} method. It must typically be - * called with an argument of <code>true</code> in the - * <code>addNotify</code> method of components performing OpenGL - * rendering and with an argument of <code>false</code> in the - * <code>removeNotify</code> method. Calling this method has no - * other effects. For example, if <code>removeNotify</code> is - * called on a Canvas implementation for which a GLDrawable has been - * created, it is also necessary to destroy all OpenGL contexts - * associated with that GLDrawable. This is not done automatically - * by the implementation. It is not necessary to call - * <code>setRealized</code> on a GLCanvas, a GLJPanel, or a + * underlying window has been created and can be drawn into. End + * users do not need to call this method; it is not necessary to + * call <code>setRealized</code> on a GLCanvas, a GLJPanel, or a * GLPbuffer, as these perform the appropriate calls on their * underlying GLDrawables internally. + * + * <P> + * + * Developers implementing new OpenGL components for various window + * toolkits need to call this method against GLDrawables obtained + * from the GLDrawableFactory via the {@link + * GLDrawableFactory#getGLDrawable + * GLDrawableFactory.getGLDrawable()} method. It must typically be + * called with an argument of <code>true</code> when the component + * associated with the GLDrawable is realized and with an argument + * of <code>false</code> just before the component is unrealized. + * For the AWT, this means calling <code>setRealized(true)</code> in + * the <code>addNotify</code> method and with an argument of + * <code>false</code> in the <code>removeNotify</code> method. + * + * <P> + * + * <code>GLDrawable</code> implementations should handle multiple + * cycles of <code>setRealized(true)</code> / + * <code>setRealized(false)</code> calls. Most, if not all, Java + * window toolkits have a persistent object associated with a given + * component, regardless of whether that component is currently + * realized. The <CODE>GLDrawable</CODE> object associated with a + * particular component is intended to be similarly persistent. A + * <CODE>GLDrawable</CODE> is intended to be created for a given + * component when it is constructed and live as long as that + * component. <code>setRealized</code> allows the + * <code>GLDrawable</code> to re-initialize and destroy any + * associated resources as the component becomes realized and + * unrealized, respectively. + * + * <P> + * + * Calling this method has no other effects. For example, if + * <code>removeNotify</code> is called on a Canvas implementation + * for which a GLDrawable has been created, it is also necessary to + * destroy all OpenGL contexts associated with that GLDrawable. This + * is not done automatically by the implementation. */ public void setRealized(boolean realized); - /** - * Cleanup the complete association to the native Canvas's display, - * and releases all ressources. - * This implies a call to <code>setRealized(false)</code> - */ - public void destroy(); - /** Returns the current width of this GLDrawable. */ public int getWidth(); diff --git a/src/classes/javax/media/opengl/awt/GLCanvas.java b/src/classes/javax/media/opengl/awt/GLCanvas.java index fe64ee90b..bce58be0f 100644 --- a/src/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/classes/javax/media/opengl/awt/GLCanvas.java @@ -418,10 +418,6 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable { return drawable.getFactory(); } - public void destroy() { - drawable.destroy(); - } - //---------------------------------------------------------------------- // Internals only below this point // diff --git a/src/classes/javax/media/opengl/awt/GLJPanel.java b/src/classes/javax/media/opengl/awt/GLJPanel.java index 2eaf932a0..d5f44ff21 100644 --- a/src/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/classes/javax/media/opengl/awt/GLJPanel.java @@ -396,10 +396,6 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable { return factory; } - public void destroy() { - throw new GLException("FIXME"); - } - //---------------------------------------------------------------------- // Internals only below this point // |