aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/x11
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-12-01 16:48:45 +0100
committerSven Gothel <[email protected]>2011-12-01 16:48:45 +0100
commit53ba4a2b3639a3746218693ea588159e5c6d07c7 (patch)
tree366dfa15bf1ddc23181d4e00eedf701a260dc092 /src/jogl/classes/jogamp/opengl/x11
parent2c0a0981f7e1376064abd981c79c65c9d1b57410 (diff)
GLDrawableFactory: Implementations lifecycle is handled via constructor/destroy()
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/x11')
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java78
1 files changed, 45 insertions, 33 deletions
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java
index a68b039ce..d2b9242be 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java
@@ -72,15 +72,15 @@ import com.jogamp.common.util.VersionNumber;
public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
- private static final DesktopGLDynamicLookupHelper x11GLXDynamicLookupHelper;
-
public static final VersionNumber versionOneZero = new VersionNumber(1, 0, 0);
public static final VersionNumber versionOneOne = new VersionNumber(1, 1, 0);
public static final VersionNumber versionOneTwo = new VersionNumber(1, 2, 0);
public static final VersionNumber versionOneThree = new VersionNumber(1, 3, 0);
public static final VersionNumber versionOneFour = new VersionNumber(1, 4, 0);
- static {
+ public X11GLXDrawableFactory() {
+ super();
+
DesktopGLDynamicLookupHelper tmp = null;
try {
tmp = new DesktopGLDynamicLookupHelper(new X11GLXDynamicLibraryBundleInfo());
@@ -90,37 +90,57 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
}
}
x11GLXDynamicLookupHelper = tmp;
+
if(null!=x11GLXDynamicLookupHelper) {
GLX.getGLXProcAddressTable().reset(x11GLXDynamicLookupHelper);
+
+ // Register our GraphicsConfigurationFactory implementations
+ // The act of constructing them causes them to be registered
+ X11GLXGraphicsConfigurationFactory.registerFactory();
+
+ defaultDevice = new X11GraphicsDevice(X11Util.getNullDisplayName(), AbstractGraphicsDevice.DEFAULT_UNIT);
+ sharedMap = new HashMap<String, SharedResourceRunner.Resource>();
+
+ // Init shared resources off thread
+ // Will be released via ShutdownHook
+ sharedResourceImpl = new SharedResourceImplementation();
+ sharedResourceRunner = new SharedResourceRunner(sharedResourceImpl);
+ sharedResourceThread = new Thread(sharedResourceRunner, Thread.currentThread().getName()+"-SharedResourceRunner");
+ sharedResourceThread.setDaemon(true); // Allow JVM to exit, even if this one is running
+ sharedResourceThread.start();
+ }
+ }
+
+ protected final void destroy() {
+ if(null != sharedResourceRunner) {
+ sharedResourceRunner.releaseAndWait();
+ sharedResourceRunner = null;
+ }
+ if(null != sharedMap) {
+ sharedMap.clear();
+ sharedMap = null;
}
+ defaultDevice = null;
+ if(null != x11GLXDynamicLookupHelper) {
+ x11GLXDynamicLookupHelper.destroy();
+ x11GLXDynamicLookupHelper = null;
+ }
+
+ // Don't really close pending Display connections,
+ // since this may trigger a JVM exception
+ X11Util.shutdown( false, DEBUG );
}
public GLDynamicLookupHelper getGLDynamicLookupHelper(int profile) {
return x11GLXDynamicLookupHelper;
}
- public X11GLXDrawableFactory() {
- super();
- // Register our GraphicsConfigurationFactory implementations
- // The act of constructing them causes them to be registered
- X11GLXGraphicsConfigurationFactory.registerFactory();
-
- defaultDevice = new X11GraphicsDevice(X11Util.getNullDisplayName(), AbstractGraphicsDevice.DEFAULT_UNIT);
-
- // Init shared resources off thread
- // Will be released via ShutdownHook
- sharedResourceImpl = new SharedResourceImplementation();
- sharedResourceRunner = new SharedResourceRunner(sharedResourceImpl);
- sharedResourceThread = new Thread(sharedResourceRunner, Thread.currentThread().getName()+"-SharedResourceRunner");
- sharedResourceThread.setDaemon(true); // Allow JVM to exit, even if this one is running
- sharedResourceThread.start();
- }
-
- X11GraphicsDevice defaultDevice;
- SharedResourceImplementation sharedResourceImpl;
- SharedResourceRunner sharedResourceRunner;
- Thread sharedResourceThread;
- HashMap<String /* connection */, SharedResourceRunner.Resource> sharedMap = new HashMap<String, SharedResourceRunner.Resource>();
+ private DesktopGLDynamicLookupHelper x11GLXDynamicLookupHelper;
+ private X11GraphicsDevice defaultDevice;
+ private SharedResourceImplementation sharedResourceImpl;
+ private SharedResourceRunner sharedResourceRunner;
+ private Thread sharedResourceThread;
+ private HashMap<String /* connection */, SharedResourceRunner.Resource> sharedMap;
static class SharedResource implements SharedResourceRunner.Resource {
X11GraphicsDevice device;
@@ -332,14 +352,6 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
return (SharedResource) sharedResourceRunner.getOrCreateShared(device);
}
- protected final void shutdownInstance() {
- sharedResourceRunner.releaseAndWait();
-
- // Don't really close pending Display connections,
- // since this may trigger a JVM exception
- X11Util.shutdown( false, DEBUG );
- }
-
protected List<GLCapabilitiesImmutable> getAvailableCapabilitiesImpl(AbstractGraphicsDevice device) {
return X11GLXGraphicsConfigurationFactory.getAvailableCapabilities(this, device);
}