aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/macosx/cgl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-12-01 21:40:12 +0100
committerSven Gothel <[email protected]>2011-12-01 21:40:12 +0100
commitb6aa455d21fbcfc256ae8f8f4d66493c17e23f4c (patch)
tree373c8a31d6ce9ac98cd290e8c6872ec6145f0c7e /src/jogl/classes/jogamp/opengl/macosx/cgl
parent919aabb77250cb0e272dac228388592d08bf98f5 (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/macosx/cgl')
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java39
1 files changed, 24 insertions, 15 deletions
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java
index 4543424a6..45445067e 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.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 jogamp.nativewindow.WrappedSurface;
import jogamp.opengl.DesktopGLDynamicLookupHelper;
@@ -72,24 +73,30 @@ import com.jogamp.common.JogampRuntimeException;
import com.jogamp.common.util.ReflectionUtil;
public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
+ private static DesktopGLDynamicLookupHelper macOSXCGLDynamicLookupHelper = null;
+
public MacOSXCGLDrawableFactory() {
super();
- DesktopGLDynamicLookupHelper tmp = null;
- try {
- tmp = new DesktopGLDynamicLookupHelper(new MacOSXCGLDynamicLibraryBundleInfo());
- } catch (GLException gle) {
- if(DEBUG) {
- gle.printStackTrace();
+ synchronized(MacOSXCGLDrawableFactory.class) {
+ if(null==macOSXCGLDynamicLookupHelper) {
+ DesktopGLDynamicLookupHelper tmp = null;
+ try {
+ tmp = new DesktopGLDynamicLookupHelper(new MacOSXCGLDynamicLibraryBundleInfo());
+ } catch (GLException gle) {
+ if(DEBUG) {
+ gle.printStackTrace();
+ }
+ }
+ macOSXCGLDynamicLookupHelper = tmp;
+ /** FIXME ??
+ if(null!=macOSXCGLDynamicLookupHelper) {
+ CGL.getCGLProcAddressTable().reset(macOSXCGLDynamicLookupHelper);
+ } */
}
}
- macOSXCGLDynamicLookupHelper = tmp;
if(null!=macOSXCGLDynamicLookupHelper) {
- /** FIXME ??
- CGL.getCGLProcAddressTable().reset(macOSXCGLDynamicLookupHelper);
- */
-
// Register our GraphicsConfigurationFactory implementations
// The act of constructing them causes them to be registered
MacOSXCGLGraphicsConfigurationFactory.registerFactory();
@@ -105,23 +112,25 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
}
}
- protected final void destroy() {
+ protected final void destroy(ShutdownType shutdownType) {
if(null != sharedMap) {
sharedMap.clear();
sharedMap = null;
}
defaultDevice = null;
- if(null != macOSXCGLDynamicLookupHelper) {
+ /**
+ * Pulling away the native library may cause havoc ..
+ *
+ if(ShutdownType.COMPLETE == shutdownType && null != macOSXCGLDynamicLookupHelper) {
macOSXCGLDynamicLookupHelper.destroy();
macOSXCGLDynamicLookupHelper = null;
- }
+ } */
}
public GLDynamicLookupHelper getGLDynamicLookupHelper(int profile) {
return macOSXCGLDynamicLookupHelper;
}
- private DesktopGLDynamicLookupHelper macOSXCGLDynamicLookupHelper;
private HashMap<String, SharedResource> sharedMap = new HashMap<String, SharedResource>();
private MacOSXGraphicsDevice defaultDevice;