summaryrefslogtreecommitdiffstats
path: root/src/jogl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-11-30 13:13:27 +0100
committerSven Gothel <[email protected]>2011-11-30 13:13:27 +0100
commitad0ba11b0a1d6cb4a113e467420f2f797f1d26cb (patch)
treefc263a43ea92791d5cb6e5439fc3c3669d3770de /src/jogl
parentb72ac8efaca45241a44dd631acb20a8c23ea2a7b (diff)
More Robust GLProfile Initialization ; Add NativeWindowFactory Shutdown
More Robust GLProfile Initialization - Catch GLException in GLDrawableFactory getWasSharedContextCreated(device) impl., which may fail (See comment on Firefox/Chorme EGL deployed library for Windows). - If getWasSharedContextCreated(devide) fails, set respective factory availability to false, ie. hasDesktopGLFactory, hasEGLFactory, .. Add NativeWindowFactory Shutdown - Currenly a dummy entry, may evolve. X11Util shutdown is issued by respective GLDrawableFactory
Diffstat (limited to 'src/jogl')
-rw-r--r--src/jogl/classes/javax/media/opengl/GLDrawableFactory.java3
-rw-r--r--src/jogl/classes/javax/media/opengl/GLProfile.java23
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java13
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java13
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java13
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java2
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java15
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java13
8 files changed, 70 insertions, 25 deletions
diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
index dbb91caaa..3bdbf5460 100644
--- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
+++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
@@ -199,8 +199,7 @@ public abstract class GLDrawableFactory {
private static void shutdownImpl() {
synchronized(glDrawableFactories) {
for(int i=0; i<glDrawableFactories.size(); i++) {
- GLDrawableFactory factory = glDrawableFactories.get(i);
- factory.shutdownInstance();
+ glDrawableFactories.get(i).shutdownInstance();
}
glDrawableFactories.clear();
}
diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java
index 20e2f2a33..f9e47f2db 100644
--- a/src/jogl/classes/javax/media/opengl/GLProfile.java
+++ b/src/jogl/classes/javax/media/opengl/GLProfile.java
@@ -74,6 +74,11 @@ public class GLProfile {
public static final boolean DEBUG = Debug.debug("GLProfile");
+ static {
+ // Also initializes TempJarCache if shall be used.
+ Platform.initSingleton();
+ }
+
/**
* Static one time initialization of JOGL.
* <p>
@@ -145,6 +150,7 @@ public class GLProfile {
public static synchronized void shutdown() {
if(initialized) {
initialized = false;
+ NativeWindowFactory.shutdown();
GLDrawableFactory.shutdown();
GLContext.shutdown();
}
@@ -1137,10 +1143,6 @@ public class GLProfile {
return "GLProfile[" + getName() + "/" + getImplName() + "]";
}
- static {
- Platform.initSingleton();
- }
-
private static /*final*/ boolean isAWTAvailable;
private static /*final*/ boolean hasDesktopGLFactory;
@@ -1332,10 +1334,13 @@ public class GLProfile {
// Triggers eager initialization of share context in GLDrawableFactory for the device,
// hence querying all available GLProfiles
boolean desktopSharedCtxAvail = desktopFactory.getWasSharedContextCreated(device);
+ if(!desktopSharedCtxAvail) {
+ hasDesktopGLFactory = false;
+ }
if (DEBUG) {
System.err.println("GLProfile.initProfilesForDevice: "+device+": desktop Shared Ctx "+desktopSharedCtxAvail);
}
- if( null == GLContext.getAvailableGLVersion(device, 2, GLContext.CTX_PROFILE_COMPAT) ) {
+ if( hasDesktopGLFactory && null == GLContext.getAvailableGLVersion(device, 2, GLContext.CTX_PROFILE_COMPAT) ) {
// nobody yet set the available desktop versions, see {@link GLContextImpl#makeCurrent},
// so we have to add the usual suspect
GLContext.mapAvailableGLVersion(device,
@@ -1351,6 +1356,14 @@ public class GLProfile {
// Triggers eager initialization of share context in GLDrawableFactory for the device,
// hence querying all available GLProfiles
boolean eglSharedCtxAvail = eglFactory.getWasSharedContextCreated(device);
+ if(!eglSharedCtxAvail) {
+ // Remark: On Windows there is a libEGL.dll delivered w/ Chrome 15.0.874.121m and Firefox 8.0.1
+ // but it seems even EGL.eglInitialize(eglDisplay, null, null)
+ // fails in some scenarios (eg VirtualBox 4.1.6) w/ EGL error 0x3001 (EGL_NOT_INITIALIZED).
+ hasEGLFactory = false;
+ hasGLES2Impl = false;
+ hasGLES1Impl = false;
+ }
if (DEBUG) {
System.err.println("GLProfile.initProfilesForDevice: "+device+": egl Shared Ctx "+eglSharedCtxAvail);
}
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java
index 7c5ad6a9e..4a1a4ccf5 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java
@@ -201,9 +201,16 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
}
public final boolean getWasSharedContextCreated(AbstractGraphicsDevice device) {
- SharedResource sr = getOrCreateEGLSharedResource(device);
- if(null!=sr) {
- return sr.wasES1ContextAvailable() || sr.wasES2ContextAvailable();
+ try {
+ SharedResource sr = getOrCreateEGLSharedResource(device);
+ if(null!=sr) {
+ return sr.wasES1ContextAvailable() || sr.wasES2ContextAvailable();
+ }
+ } catch (GLException gle) {
+ if(DEBUG) {
+ System.err.println("Catched Exception while EGL Shared Resource initialization");
+ gle.printStackTrace();
+ }
}
return false;
}
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java
index cea4feea8..ed7959ae8 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java
@@ -232,9 +232,16 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
}
public final boolean getWasSharedContextCreated(AbstractGraphicsDevice device) {
- SharedResource sr = getOrCreateOSXSharedResource(device);
- if(null!=sr) {
- return sr.wasContextAvailable();
+ try {
+ SharedResource sr = getOrCreateOSXSharedResource(device);
+ if(null!=sr) {
+ return sr.wasContextAvailable();
+ }
+ } catch (GLException gle) {
+ if(DEBUG) {
+ System.err.println("Catched Exception while MaxOSXCGL Shared Resource initialization");
+ gle.printStackTrace();
+ }
}
return false;
}
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java
index 9838ba156..6b75b6504 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java
@@ -370,9 +370,16 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
final static String wglMakeContextCurrent = "wglMakeContextCurrent";
public final boolean getWasSharedContextCreated(AbstractGraphicsDevice device) {
- SharedResourceRunner.Resource sr = sharedResourceRunner.getOrCreateShared(device);
- if(null!=sr) {
- return null != sr.getContext();
+ try {
+ SharedResourceRunner.Resource sr = sharedResourceRunner.getOrCreateShared(device);
+ if(null!=sr) {
+ return null != sr.getContext();
+ }
+ } catch (GLException gle) {
+ if(DEBUG) {
+ System.err.println("Catched Exception while WindowsWGL Shared Resource initialization");
+ gle.printStackTrace();
+ }
}
return false;
}
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
index 2d1ecb57f..edcaa4a24 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
@@ -238,7 +238,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
}
if(NativeSurface.LOCK_SURFACE_NOT_READY >= sharedDrawable.lockSurface()) {
- throw new GLException("Surface not ready (lockSurface)");
+ throw new GLException("Shared Surface not ready (lockSurface): "+device+" -> "+sharedDrawable);
}
try {
long hdc = sharedDrawable.getHandle();
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java
index 08cd63c5e..0f9786f1d 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java
@@ -124,12 +124,17 @@ public class WindowsAWTWGLGraphicsConfigurationFactory extends GLGraphicsConfigu
// otherwise no hardware accelerated PFD could be achieved.
// - preselect with no constrains
// - try to create dedicated GC
- winConfig.preselectGraphicsConfiguration(drawableFactory, null);
- if ( 1 <= winConfig.getPixelFormatID() ) {
- chosenGC = Win32SunJDKReflection.graphicsConfigurationGet(device, winConfig.getPixelFormatID());
- if(DEBUG) {
- System.err.println("WindowsAWTWGLGraphicsConfigurationFactory: Found new AWT PFD ID "+winConfig.getPixelFormatID()+" -> "+winConfig);
+ try {
+ winConfig.preselectGraphicsConfiguration(drawableFactory, null);
+ if ( 1 <= winConfig.getPixelFormatID() ) {
+ chosenGC = Win32SunJDKReflection.graphicsConfigurationGet(device, winConfig.getPixelFormatID());
+ if(DEBUG) {
+ System.err.println("WindowsAWTWGLGraphicsConfigurationFactory: Found new AWT PFD ID "+winConfig.getPixelFormatID()+" -> "+winConfig);
+ }
}
+ } catch (GLException gle0) {
+ gle0.printStackTrace();
+ // go on ..
}
if( null == chosenGC ) {
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java
index 40cae4980..a68b039ce 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java
@@ -290,9 +290,16 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
}
public final boolean getWasSharedContextCreated(AbstractGraphicsDevice device) {
- SharedResourceRunner.Resource sr = sharedResourceRunner.getOrCreateShared(device);
- if(null!=sr) {
- return null != sr.getContext();
+ try {
+ SharedResourceRunner.Resource sr = sharedResourceRunner.getOrCreateShared(device);
+ if(null!=sr) {
+ return null != sr.getContext();
+ }
+ } catch (GLException gle) {
+ if(DEBUG) {
+ System.err.println("Catched Exception while X11GLX Shared Resource initialization");
+ gle.printStackTrace();
+ }
}
return false;
}