diff options
author | Sven Gothel <[email protected]> | 2011-12-01 21:40:12 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-12-01 21:40:12 +0100 |
commit | b6aa455d21fbcfc256ae8f8f4d66493c17e23f4c (patch) | |
tree | 373c8a31d6ce9ac98cd290e8c6872ec6145f0c7e /src/jogl/classes/jogamp/opengl/windows | |
parent | 919aabb77250cb0e272dac228388592d08bf98f5 (diff) |
New GLProfile.ShutdownType: SHARED_ONLY / COMPLETE - Enhance/Fix Lifecycle Management
- Leave Platform, .. TempJarCache untouched.
- GLDrawableFactoryImpl*: Leave DynamicLibraryBundle(lib-binding) untouched,
for NativeLibrary, JNILibLoaderBase (JNI libs), .. consistency.
- SHARED_ONLY: shutdown shared GLDrawableFactoryImpl* resources and NativeWindowFactory
- COMPLETE: additionally shutdown GLContext*
Clear all cached GL/GLX proc-address and device/context mappings.
- Use new "GLProfile.shutdown(GLProfile.ShutdownType.SHARED_ONLY)" in Applets
- X11GLXDrawableFactory Shutdown: Uncomment close/destroy of shared resources.
- JAWTWindow.destroy(): Close the delegated device.
In case it's X11 this closes the exclusive opened X11 Display.
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/windows')
-rw-r--r-- | src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java index 8e9bf553b..917402b0a 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java @@ -61,6 +61,7 @@ import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawable; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; +import javax.media.opengl.GLProfile.ShutdownType; import com.jogamp.common.JogampRuntimeException; import com.jogamp.common.nio.PointerBuffer; @@ -80,22 +81,29 @@ import jogamp.opengl.GLDynamicLookupHelper; import jogamp.opengl.SharedResourceRunner; public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { + private static DesktopGLDynamicLookupHelper windowsWGLDynamicLookupHelper = null; + public WindowsWGLDrawableFactory() { super(); - DesktopGLDynamicLookupHelper tmp = null; - try { - tmp = new DesktopGLDynamicLookupHelper(new WindowsWGLDynamicLibraryBundleInfo()); - } catch (GLException gle) { - if(DEBUG) { - gle.printStackTrace(); + synchronized(WindowsWGLDrawableFactory.class) { + if(null==windowsWGLDynamicLookupHelper) { + DesktopGLDynamicLookupHelper tmp = null; + try { + tmp = new DesktopGLDynamicLookupHelper(new WindowsWGLDynamicLibraryBundleInfo()); + } catch (GLException gle) { + if(DEBUG) { + gle.printStackTrace(); + } + } + windowsWGLDynamicLookupHelper = tmp; + if(null!=windowsWGLDynamicLookupHelper) { + WGL.getWGLProcAddressTable().reset(windowsWGLDynamicLookupHelper); + } } } - windowsWGLDynamicLookupHelper = tmp; if(null!=windowsWGLDynamicLookupHelper) { - WGL.getWGLProcAddressTable().reset(windowsWGLDynamicLookupHelper); - // Register our GraphicsConfigurationFactory implementations // The act of constructing them causes them to be registered WindowsWGLGraphicsConfigurationFactory.registerFactory(); @@ -119,7 +127,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { } } - protected final void destroy() { + protected final void destroy(ShutdownType shutdownType) { if(null != sharedResourceRunner) { sharedResourceRunner.releaseAndWait(); sharedResourceRunner = null; @@ -129,12 +137,13 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { sharedMap = null; } defaultDevice = null; - if(null != windowsWGLDynamicLookupHelper) { - // FIXME: If closing the native library NativeLibrary.close(), - // reload of Applets doesn't work. Dunno why. - // windowsWGLDynamicLookupHelper.destroy(); + /** + * Pulling away the native library may cause havoc .. + * + if(ShutdownType.COMPLETE == shutdownType && null != windowsWGLDynamicLookupHelper) { + windowsWGLDynamicLookupHelper.destroy(); windowsWGLDynamicLookupHelper = null; - } + } */ RegisteredClassFactory.shutdownSharedClasses(); } @@ -143,7 +152,6 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { return windowsWGLDynamicLookupHelper; } - private DesktopGLDynamicLookupHelper windowsWGLDynamicLookupHelper; private WindowsGraphicsDevice defaultDevice; private SharedResourceImplementation sharedResourceImpl; private SharedResourceRunner sharedResourceRunner; |