diff options
Diffstat (limited to 'src/classes/com/sun/opengl/impl')
8 files changed, 33 insertions, 50 deletions
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() { |