summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/javax/media/opengl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-09-08 05:24:57 +0200
committerSven Gothel <[email protected]>2011-09-08 05:24:57 +0200
commit4191e406178cdd900030a1ec3919476aab527734 (patch)
tree3e537adb99c85735765cc4ca212ccebd589addbe /src/jogl/classes/javax/media/opengl
parentb55cda4f1d0d2dda875e16deb8a42cfa3f8af65d (diff)
JOGL: Make GLProfile shutdown()/initSingleton() functional, ie. proper recreation of all resources
- Release all GLDrawableFactory instances at shutdown, [re]create them at initialization - Release GLContext resources (availability map) as well
Diffstat (limited to 'src/jogl/classes/javax/media/opengl')
-rw-r--r--src/jogl/classes/javax/media/opengl/GLContext.java5
-rw-r--r--src/jogl/classes/javax/media/opengl/GLDrawableFactory.java32
-rw-r--r--src/jogl/classes/javax/media/opengl/GLProfile.java5
3 files changed, 24 insertions, 18 deletions
diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java
index 20930bd42..0727dad1b 100644
--- a/src/jogl/classes/javax/media/opengl/GLContext.java
+++ b/src/jogl/classes/javax/media/opengl/GLContext.java
@@ -756,6 +756,11 @@ public abstract class GLContext {
}
}
}
+
+ protected static void shutdown() {
+ deviceVersionAvailable.clear();
+ deviceVersionsAvailableSet.clear();
+ }
/**
* Called by {@link jogamp.opengl.GLContextImpl#createContextARBMapVersionsAvailable} not intended to be used by
diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
index 9bb9480c7..1282eb168 100644
--- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
+++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
@@ -90,11 +90,13 @@ import javax.media.nativewindow.ProxySurface;
public abstract class GLDrawableFactory {
- private static final GLDrawableFactory eglFactory;
- private static final GLDrawableFactory nativeOSFactory;
private static final String nativeOSType;
static final String macosxFactoryClassNameCGL = "jogamp.opengl.macosx.cgl.MacOSXCGLDrawableFactory";
static final String macosxFactoryClassNameAWTCGL = "jogamp.opengl.macosx.cgl.awt.MacOSXAWTCGLDrawableFactory";
+
+ private static volatile boolean initialized = false;
+ private static GLDrawableFactory eglFactory;
+ private static GLDrawableFactory nativeOSFactory;
protected static ArrayList<GLDrawableFactory> glDrawableFactories = new ArrayList<GLDrawableFactory>();
@@ -106,15 +108,15 @@ public abstract class GLDrawableFactory {
* Instantiate singleton factories if available, EGLES1, EGLES2 and the OS native ones.
*/
static {
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- registerFactoryShutdownHook();
- return null;
- }
- });
-
nativeOSType = NativeWindowFactory.getNativeWindowType(true);
+ }
+ protected static final void initialize() {
+ if(initialized) { return; }
+ initialized = true;
+
+ registerFactoryShutdownHook();
+
GLDrawableFactory tmp = null;
String factoryClassName = Debug.getProperty("jogl.gldrawablefactory.class.name", true, AccessController.getContext());
ClassLoader cl = GLDrawableFactory.class.getClassLoader();
@@ -205,17 +207,13 @@ public abstract class GLDrawableFactory {
}
protected static void shutdown() {
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- unregisterFactoryShutdownHook();
- return null;
- }
- });
+ unregisterFactoryShutdownHook();
shutdownImpl();
+ eglFactory = null;
+ nativeOSFactory = null;
+ initialized = false;
}
- private AbstractGraphicsDevice defaultSharedDevice = null;
-
protected GLDrawableFactory() {
synchronized(glDrawableFactories) {
glDrawableFactories.add(this);
diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java
index 1fd699dfd..a7231efc8 100644
--- a/src/jogl/classes/javax/media/opengl/GLProfile.java
+++ b/src/jogl/classes/javax/media/opengl/GLProfile.java
@@ -137,6 +137,7 @@ public class GLProfile {
if(initialized) {
initialized = false;
GLDrawableFactory.shutdown();
+ GLContext.shutdown();
}
}
@@ -1194,6 +1195,8 @@ public class GLProfile {
// - Instantiate GLDrawableFactory incl its shared dummy drawable/context,
// which will register at GLContext ..
//
+ GLDrawableFactory.initialize();
+
Throwable t=null;
// if successfull it has a shared dummy drawable and context created
try {
@@ -1318,7 +1321,7 @@ public class GLProfile {
// System.err.println(msg);
}
if(isSet) {
- return null != GLProfile.getDefault(device);
+ return GLProfile.isAvailable(device, GL_DEFAULT);
}
boolean addedDesktopProfile = false;