From a393e45613d87101dbb13763df263c2f9291d2d0 Mon Sep 17 00:00:00 2001
From: Sven Gothel <sgothel@jausoft.com>
Date: Tue, 26 Jun 2012 10:44:08 +0200
Subject: Implement Bug #598 - JOGL ALL JAR File Change incl. it's Native Jar
 URL Derivation

- Depends on GlueGen commit 9a71703904ebfec343fb2c7266343d37a2e4c3db

JAR file name changes:

ALL JARs:
 - jogl.all.jar                -> jogl-all.jar
 - jogl.all-noawt.jar          -> jogl-all-noawt.jar
 - jogl.all-mobile.jar         -> jogl-all-mobile.jar
 - jogl.all-android.jar        -> jogl-all-android.jar
 - jogl.all-android.apk        -> jogl-all-android.apk

Atomic JARs:
-  nativewindow.core.jar       -> nativewindow-core.jar
-  nativewindow.awt.jar        -> nativewindow-awt.jar
-  nativewindow.os.x11.jar     -> nativewindow-os-x11.jar
-  nativewindow.os.win.jar     -> nativewindow-os-win.jar
-  nativewindow.os.macosx.jar  -> nativewindow-os-osx.jar

-  jogl.core.jar               -> jogl-core.jar
-  jogl.sdk.jar                -> jogl-sdk.jar
-  jogl.glmobile.jar           -> jogl-glmobile.jar
-  jogl.glmobile.dbg.jar       -> jogl-glmobile-dbg.jar
-  jogl.util.jar               -> jogl-util.jar
-  jogl.glutess.jar            -> jogl-glutess.jar
-  jogl.glumipmap.jar          -> jogl-glumipmap.jar
-  jogl.util.fixedfuncemu.jar  -> jogl-util-fixedfuncemu.jar
-  jogl.awt.jar                -> jogl-awt.jar
-  jogl.swt.jar                -> jogl-swt.jar
-  jogl.util.awt.jar           -> jogl-util-awt.jar
-  jogl.os.x11.jar             -> jogl-os-x11.jar
-  jogl.os.win.jar             -> jogl-os-win.jar
-  jogl.os.osx.jar             -> jogl-os-osx.jar
-  jogl.os.android.jar         -> jogl-os-android.jar
-  jogl.gldesktop.jar          -> jogl-gldesktop.jar
-  jogl.gldesktop.dbg.jar      -> jogl-gldesktop-dbg.jar
-  jogl.glugldesktop.jar       -> jogl-glu-gldesktop.jar
-  jogl.util.gldesktop.jar     -> jogl-util-gldesktop.jar
-  jogl.omx.jar                -> jogl-omx.jar
-  jogl.cg.jar                 -> jogl-cg.jar

-  newt.core.jar               -> newt-core.jar
-  newt.ogl.jar                -> newt-ogl.jar
-  newt.awt.jar                -> newt-awt.jar
-  newt.event.jar              -> newt-event.jar
-  newt.driver.x11.jar         -> newt-driver-x11.jar
-  newt.driver.win.jar         -> newt-driver-win.jar
-  newt.driver.macosx.jar      -> newt-driver-osx.jar
-  newt.driver.android.jar     -> newt-driver-android.jar
-  newt.driver.kd.jar          -> newt-driver-kd.jar
-  newt.driver.intelgdl.jar    -> newt-driver-intelgdl.jar
-  newt.driver.broadcomegl.jar -> newt-driver-broadcomegl.jar

Test JARs:
 - jogl.test.jar               -> jogl-test.jar
 - jogl.test-android.jar       -> jogl-test-android.jar
 - jogl.test-android.apk       -> jogl-test-android.apk
---
 src/jogl/classes/javax/media/opengl/GLProfile.java | 28 ++++++++++++++++------
 1 file changed, 21 insertions(+), 7 deletions(-)

(limited to 'src/jogl/classes/javax/media/opengl/GLProfile.java')

diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java
index f85c6ba23..ed457b0ea 100644
--- a/src/jogl/classes/javax/media/opengl/GLProfile.java
+++ b/src/jogl/classes/javax/media/opengl/GLProfile.java
@@ -37,6 +37,7 @@
 
 package javax.media.opengl;
 
+import jogamp.nativewindow.NWJNILibLoader;
 import jogamp.opengl.Debug;
 import jogamp.opengl.GLDrawableFactoryImpl;
 import jogamp.opengl.DesktopGLDynamicLookupHelper;
@@ -133,11 +134,17 @@ public class GLProfile {
                         Platform.initSingleton();
                         
                         if(TempJarCache.isInitialized()) {
-                           String[] atomicNativeJarBaseNames = new String[] { "nativewindow", "jogl", null };
-                           if( ReflectionUtil.isClassAvailable("com.jogamp.newt.NewtFactory", GLProfile.class.getClassLoader()) ) {
-                               atomicNativeJarBaseNames[2] = "newt";
+                           final ClassLoader cl = GLProfile.class.getClassLoader();
+                           // either: [jogl-all.jar, jogl-all-noawt.jar, jogl-all-mobile.jar] -> jogl-all-natives-<os.and.arch>.jar
+                           // or:     nativewindow-core.jar                                   -> nativewindow-natives-<os.and.arch>.jar,
+                           //         jogl-core.jar                                           -> jogl-natives-<os.and.arch>.jar,
+                           //        (newt-core.jar                                           -> newt-natives-<os.and.arch>.jar)? (if available)
+                           final String newtFactoryClassName = "com.jogamp.newt.NewtFactory";
+                           final Class<?>[] classesFromJavaJars = new Class<?>[] { NWJNILibLoader.class, GLProfile.class, null };
+                           if( ReflectionUtil.isClassAvailable(newtFactoryClassName, cl) ) {
+                               classesFromJavaJars[2] = ReflectionUtil.getClass(newtFactoryClassName, false, cl);
                            }
-                           JNILibLoaderBase.addNativeJarLibs(GLProfile.class, "jogl-all", atomicNativeJarBaseNames);
+                           JNILibLoaderBase.addNativeJarLibs(classesFromJavaJars, "-all", new String[] { "-noawt", "-mobile", "-core" } );
                         }
                         initProfilesForDefaultDevices(firstUIActionOnProcess);
                         return null;
@@ -1497,8 +1504,10 @@ public class GLProfile {
             System.err.println("GLProfile.init hasGLES1Impl         "+hasGLES1Impl);
             System.err.println("GLProfile.init hasGLES2Impl         "+hasGLES2Impl);
             System.err.println("GLProfile.init defaultDevice        "+defaultDevice);
-            System.err.println("GLProfile.init profile order        "+array2String(GL_PROFILE_LIST_ALL));            
-            System.err.println(JoglVersion.getDefaultOpenGLInfo(null));            
+            System.err.println("GLProfile.init profile order        "+array2String(GL_PROFILE_LIST_ALL));
+            if(hasGL234Impl || hasGLES1Impl || hasGLES2Impl) { // avoid deadlock
+                System.err.println(JoglVersion.getDefaultOpenGLInfo(null));
+            }
         }
     }
 
@@ -1527,7 +1536,7 @@ public class GLProfile {
         boolean isSet = GLContext.getAvailableGLVersionsSet(device);
 
         if(DEBUG) {
-            System.err.println("Info: GLProfile.initProfilesForDevice: "+device+", isSet "+isSet);
+            System.err.println("Info: GLProfile.initProfilesForDevice: "+device+" ("+device.getClass().getName()+"), isSet "+isSet+", hasDesktopGLFactory "+hasDesktopGLFactory+", hasEGLFactory "+hasEGLFactory);
         }
         if(isSet) {
             // Avoid recursion and check whether impl. is sane!
@@ -1901,9 +1910,14 @@ public class GLProfile {
     {
         initSingleton();
 
+        if(null==defaultDevice) { // avoid NPE and notify of incomplete initialization
+            throw new GLException("No default device available");
+        }
+        
         if(null==device) {
             device = defaultDevice;
         }
+        
         final String deviceKey = device.getUniqueID();
         HashMap<String /*GLProfile_name*/, GLProfile> map = deviceConn2ProfileMap.get(deviceKey);
         if( null != map ) {
-- 
cgit v1.2.3