aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/javax/media/opengl/GLProfile.java
diff options
context:
space:
mode:
authorJOGAMP DEV TEAM <[email protected]>2010-04-22 21:12:36 -0400
committerJOGAMP DEV TEAM <[email protected]>2010-04-22 21:12:36 -0400
commit1d889ddc4728d1534e310b44fad74a2932d22d39 (patch)
tree4ad0c3eeb3ef728522ac9459eb12c667301a0c32 /src/jogl/classes/javax/media/opengl/GLProfile.java
parent8790075f074013aa3c71b96993838cf1117275f1 (diff)
parenta588326d206ff32e5ff5db97560851cb9b826022 (diff)
Merge branch 'master' of github.com:sgothel/jogl
Diffstat (limited to 'src/jogl/classes/javax/media/opengl/GLProfile.java')
-rw-r--r--src/jogl/classes/javax/media/opengl/GLProfile.java512
1 files changed, 373 insertions, 139 deletions
diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java
index 69cdd3f24..0e10b32b3 100644
--- a/src/jogl/classes/javax/media/opengl/GLProfile.java
+++ b/src/jogl/classes/javax/media/opengl/GLProfile.java
@@ -36,13 +36,16 @@
package javax.media.opengl;
-import javax.media.opengl.fixedfunc.*;
-import java.lang.reflect.*;
+import com.jogamp.common.util.*;
+import com.jogamp.opengl.impl.DRIHack;
+import com.jogamp.opengl.impl.Debug;
+import com.jogamp.opengl.impl.GLJNILibLoader;
+import com.jogamp.common.jvm.JVMUtil;
import java.util.HashMap;
-import java.security.*;
-import com.sun.opengl.impl.*;
-import com.sun.nativewindow.impl.NWReflection;
-import com.sun.nativewindow.impl.jvm.JVMUtil;
+import java.util.Iterator;
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import javax.media.opengl.fixedfunc.GLPointerFunc;
/**
* Specifies the the OpenGL profile.
@@ -57,9 +60,62 @@ public class GLProfile implements Cloneable {
public static final boolean DEBUG = Debug.debug("GLProfile");
//
+ // Query platform available OpenGL implementation
+ //
+
+ public static final boolean isGL4bcAvailable() { return null != mappedProfiles.get(GL4bc); }
+ public static final boolean isGL4Available() { return null != mappedProfiles.get(GL4); }
+ public static final boolean isGL3bcAvailable() { return null != mappedProfiles.get(GL3bc); }
+ public static final boolean isGL3Available() { return null != mappedProfiles.get(GL3); }
+ public static final boolean isGL2Available() { return null != mappedProfiles.get(GL2); }
+ public static final boolean isGLES2Available() { return null != mappedProfiles.get(GLES2); }
+ public static final boolean isGLES1Available() { return null != mappedProfiles.get(GLES1); }
+ public static final boolean isGL2ES1Available() { return null != mappedProfiles.get(GL2ES1); }
+ public static final boolean isGL2ES2Available() { return null != mappedProfiles.get(GL2ES2); }
+
+ public static final String glAvailabilityToString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append("GLAvailability[Native[GL4bc ");
+ sb.append(isGL4bcAvailable());
+ sb.append(", GL4 ");
+ sb.append(isGL4Available());
+ sb.append(", GL3bc ");
+ sb.append(isGL3bcAvailable());
+ sb.append(", GL3 ");
+ sb.append(isGL3Available());
+ sb.append(", GL2 ");
+ sb.append(isGL2Available());
+ sb.append(", GL2ES1 ");
+ sb.append(isGL2ES1Available());
+ sb.append(", GLES1 ");
+ sb.append(isGLES1Available());
+ sb.append(", GL2ES2 ");
+ sb.append(isGL2ES2Available());
+ sb.append(", GLES2 ");
+ sb.append(isGLES2Available());
+ sb.append("], Profiles[");
+ for(Iterator i=mappedProfiles.values().iterator(); i.hasNext(); ) {
+ sb.append(((GLProfile)i.next()).toString());
+ sb.append(", ");
+ }
+ sb.append(", default ");
+ sb.append(defaultGLProfile);
+ sb.append("]]");
+
+ return sb.toString();
+ }
+
+ //
// Public (user-visible) profiles
//
+ /** The desktop OpenGL compatibility profile 4.x, with x >= 0, ie GL2 plus GL4.<br>
+ <code>bc</code> stands for backward compatibility. */
+ public static final String GL4bc = "GL4bc";
+
+ /** The desktop OpenGL core profile 4.x, with x >= 0 */
+ public static final String GL4 = "GL4";
+
/** The desktop OpenGL compatibility profile 3.x, with x >= 1, ie GL2 plus GL3.<br>
<code>bc</code> stands for backward compatibility. */
public static final String GL3bc = "GL3bc";
@@ -86,22 +142,92 @@ public class GLProfile implements Cloneable {
public static final String GL2GL3 = "GL2GL3";
/**
- * All GL Profiles in the order of default detection: GL2, GL2ES2, GL2ES1, GLES2, GLES1, GL2GL3, GL3
+ * All GL Profiles in the order of default detection.
+ * Desktop compatibility profiles (the one with fixed function pipeline) comes first.
+ *
+ * FIXME GL3GL4: Due to GL3 and GL4 implementation bugs, we still choose GL2 first, if available!
+ *
+ * <ul>
+ * <li> GL2
+ * <li> GL3bc
+ * <li> GL4bc
+ * <li> GL2GL3
+ * <li> GL3
+ * <li> GL4
+ * <li> GL2ES2
+ * <li> GLES2
+ * <li> GL2ES1
+ * <li> GLES1
+ * </ul>
+ *
+ */
+ public static final String[] GL_PROFILE_LIST_ALL = new String[] { GL2, GL3bc, GL4bc, GL2GL3, GL3, GL4, GL2ES2, GLES2, GL2ES1, GLES1 };
+
+ /**
+ * Order of maximum fixed function profiles
+ *
+ * <ul>
+ * <li> GL4bc
+ * <li> GL3bc
+ * <li> GL2
+ * <li> GL2ES1
+ * <li> GLES1
+ * </ul>
+ *
+ */
+ public static final String[] GL_PROFILE_LIST_MAX_FIXEDFUNC = new String[] { GL4bc, GL3bc, GL2, GL2ES1, GLES1 };
+
+ /**
+ * Order of maximum programmable shader profiles
+ *
+ * <ul>
+ * <li> GL4
+ * <li> GL4bc
+ * <li> GL3
+ * <li> GL3bc
+ * <li> GL2
+ * <li> GL2ES2
+ * <li> GLES2
+ * </ul>
+ *
*/
- public static final String[] GL_PROFILE_LIST_ALL = new String[] { GL2, GL2ES2, GL2ES1, GLES2, GLES1, GL2GL3, GL3bc, GL3 };
+ public static final String[] GL_PROFILE_LIST_MAX_PROGSHADER = new String[] { GL4, GL4bc, GL3, GL3bc, GL2, GL2ES2, GLES2 };
/**
- * All GL2ES2 Profiles in the order of default detection: GL2ES2, GL2, GLES2, GL3
+ * All GL2ES2 Profiles in the order of default detection.
+ *
+ * FIXME GL3GL4: Due to GL3 and GL4 implementation bugs, we still choose GL2 first, if available!
+ *
+ * <ul>
+ * <li> GL2ES2
+ * <li> GL2
+ * <li> GL3
+ * <li> GL4
+ * <li> GLES2
+ * </ul>
+ *
*/
- public static final String[] GL_PROFILE_LIST_GL2ES2 = new String[] { GL2ES2, GL2, GLES2, GL3bc, GL3 };
+ public static final String[] GL_PROFILE_LIST_GL2ES2 = new String[] { GL2ES2, GL2, GL3, GL4, GLES2 };
/**
- * All GL2ES1 Profiles in the order of default detection: GL2ES1, GL2, GLES1
+ * All GL2ES1 Profiles in the order of default detection.
+ *
+ * FIXME GL3GL4: Due to GL3 and GL4 implementation bugs, we still choose GL2 first, if available!
+ *
+ * <ul>
+ * <li> GL2ES1
+ * <li> GL2
+ * <li> GL3bc
+ * <li> GL4bc
+ * <li> GLES1
+ * </ul>
+ *
*/
- public static final String[] GL_PROFILE_LIST_GL2ES1 = new String[] { GL2ES1, GL2, GLES1 };
+ public static final String[] GL_PROFILE_LIST_GL2ES1 = new String[] { GL2ES1, GL2, GL3bc, GL4bc, GLES1 };
/** Returns a default GLProfile object, reflecting the best for the running platform.
* It selects the first of the set {@link GLProfile#GL_PROFILE_LIST_ALL}
+ * @see #GL_PROFILE_LIST_ALL
*/
public static final GLProfile getDefault() {
if(null==defaultGLProfile) {
@@ -110,22 +236,30 @@ public class GLProfile implements Cloneable {
return defaultGLProfile;
}
- /** Returns a GLProfile object.
- * Verfifies the given profile and chooses an apropriate implementation.
- * A generic value of <code>null</code> or <code>GL</code> will result in
- * the default profile.
+ /**
+ * Returns the highest profile, implementing the fixed function pipeline
+ * It selects the first of the set: {@link GLProfile#GL_PROFILE_LIST_MAX_FIXEDFUNC}
*
* @throws GLException if no implementation for the given profile is found.
+ * @see #GL_PROFILE_LIST_MAX_FIXEDFUNC
*/
- public static final GLProfile get(String profile)
+ public static final GLProfile getMaxFixedFunc()
throws GLException
{
- if(null==profile || profile.equals("GL")) return getDefault();
- GLProfile glProfile = (GLProfile) mappedProfiles.get(profile);
- if(null==glProfile) {
- throw new GLException("No implementation for profile "+profile+" available");
- }
- return glProfile;
+ return get(GL_PROFILE_LIST_MAX_FIXEDFUNC);
+ }
+
+ /**
+ * Returns the highest profile, implementing the programmable shader pipeline.
+ * It selects the first of the set: {@link GLProfile#GL_PROFILE_LIST_MAX_PROGSHADER}
+ *
+ * @throws GLException if no implementation for the given profile is found.
+ * @see #GL_PROFILE_LIST_MAX_PROGSHADER
+ */
+ public static final GLProfile getMaxProgrammable()
+ throws GLException
+ {
+ return get(GL_PROFILE_LIST_MAX_PROGSHADER);
}
/**
@@ -133,6 +267,7 @@ public class GLProfile implements Cloneable {
* It selects the first of the set: {@link GLProfile#GL_PROFILE_LIST_GL2ES1}
*
* @throws GLException if no implementation for the given profile is found.
+ * @see #GL_PROFILE_LIST_GL2ES1
*/
public static final GLProfile getGL2ES1()
throws GLException
@@ -145,6 +280,7 @@ public class GLProfile implements Cloneable {
* It selects the first of the set: {@link GLProfile#GL_PROFILE_LIST_GL2ES2}
*
* @throws GLException if no implementation for the given profile is found.
+ * @see #GL_PROFILE_LIST_GL2ES2
*/
public static final GLProfile getGL2ES2()
throws GLException
@@ -152,6 +288,24 @@ public class GLProfile implements Cloneable {
return get(GL_PROFILE_LIST_GL2ES2);
}
+ /** Returns a GLProfile object.
+ * Verfifies the given profile and chooses an apropriate implementation.
+ * A generic value of <code>null</code> or <code>GL</code> will result in
+ * the default profile.
+ *
+ * @throws GLException if no implementation for the given profile is found.
+ */
+ public static final GLProfile get(String profile)
+ throws GLException
+ {
+ if(null==profile || profile.equals("GL")) return getDefault();
+ GLProfile glProfile = (GLProfile) mappedProfiles.get(profile);
+ if(null==glProfile) {
+ throw new GLException("No implementation for profile "+profile+" available");
+ }
+ return glProfile;
+ }
+
/**
* Returns the first profile from the given list,
* where an implementation is available.
@@ -191,18 +345,18 @@ public class GLProfile implements Cloneable {
}
private static final String getGLImplBaseClassName(String profileImpl) {
- if(GL3bc.equals(profileImpl)) {
- return "com.sun.opengl.impl.gl3.GL3bc";
- } else if(GL3.equals(profileImpl)) {
- return "com.sun.opengl.impl.gl3.GL3";
- } else if(GL2.equals(profileImpl)) {
- return "com.sun.opengl.impl.gl2.GL2";
+ if ( GL4bc.equals(profileImpl) ||
+ GL4.equals(profileImpl) ||
+ GL3bc.equals(profileImpl) ||
+ GL3.equals(profileImpl) ||
+ GL2.equals(profileImpl) ) {
+ return "com.jogamp.opengl.impl.gl4.GL4bc";
} else if(GL2ES12.equals(profileImpl)) {
- return "com.sun.opengl.impl.gl2es12.GL2ES12";
+ return "com.jogamp.opengl.impl.gl2es12.GL2ES12";
} else if(GLES1.equals(profileImpl) || GL2ES1.equals(profileImpl)) {
- return "com.sun.opengl.impl.es1.GLES1";
+ return "com.jogamp.opengl.impl.es1.GLES1";
} else if(GLES2.equals(profileImpl) || GL2ES2.equals(profileImpl)) {
- return "com.sun.opengl.impl.es2.GLES2";
+ return "com.jogamp.opengl.impl.es2.GLES2";
} else {
throw new GLException("unsupported profile \"" + profileImpl + "\"");
}
@@ -252,19 +406,29 @@ public class GLProfile implements Cloneable {
return profileImpl;
}
+ /** Indicates whether this profile is capable of GL4bc. */
+ public final boolean isGL4bc() {
+ return GL4bc.equals(profile);
+ }
+
+ /** Indicates whether this profile is capable of GL4. */
+ public final boolean isGL4() {
+ return isGL4bc() || GL4.equals(profile);
+ }
+
/** Indicates whether this profile is capable of GL3bc. */
public final boolean isGL3bc() {
- return GL3bc.equals(profile);
+ return isGL4bc() || GL3bc.equals(profile);
}
/** Indicates whether this profile is capable of GL3. */
public final boolean isGL3() {
- return isGL3bc() || GL3.equals(profile);
+ return isGL4() || isGL3bc() || GL3.equals(profile);
}
- /** Indicates whether this profile is capable of GL2. */
+ /** Indicates whether this context is a GL2 context */
public final boolean isGL2() {
- return GL2.equals(profile);
+ return isGL3bc() || GL2.equals(profile);
}
/** Indicates whether this profile is capable of GLES1. */
@@ -292,6 +456,11 @@ public class GLProfile implements Cloneable {
return GL2GL3.equals(profile) || isGL2() || isGL3() ;
}
+ /** Indicates whether this profile supports GLSL. */
+ public final boolean hasGLSL() {
+ return isGL2ES2() ;
+ }
+
/** Indicates whether this profile uses the native OpenGL ES1 implementations. */
public final boolean usesNativeGLES1() {
return GLES1.equals(profileImpl);
@@ -307,31 +476,6 @@ public class GLProfile implements Cloneable {
return usesNativeGLES2() || usesNativeGLES1();
}
- /** Indicates whether this profile uses the native desktop OpenGL GL2 implementations. */
- public final boolean usesNativeGL2() {
- return GL2.equals(profileImpl) || GL2ES12.equals(profileImpl) ;
- }
-
- /** Indicates whether this profile uses the native desktop OpenGL GL3bc implementations. */
- public final boolean usesNativeGL3bc() {
- return GL3bc.equals(profileImpl);
- }
-
- /** Indicates whether this profile uses the native desktop OpenGL GL3 implementations. */
- public final boolean usesNativeGL3() {
- return usesNativeGL3bc() || GL3.equals(profileImpl);
- }
-
- /** Indicates whether this profile uses the native desktop OpenGL GL2 or GL3 implementations. */
- public final boolean usesNativeGL2GL3() {
- return usesNativeGL2() || usesNativeGL3() ;
- }
-
- /** Indicates whether this profile supports GLSL. */
- public final boolean hasGLSL() {
- return isGL2ES2() ;
- }
-
/**
* General validation if type is a valid GL data type
* for the current profile
@@ -639,18 +783,21 @@ public class GLProfile implements Cloneable {
private static final boolean isAWTAvailable;
private static final boolean isAWTJOGLAvailable;
- private static final boolean hasGL3bcImpl;
- private static final boolean hasGL3Impl;
- private static final boolean hasGL2Impl;
- private static final boolean hasGL2ES12Impl;
- private static final boolean hasGLES2Impl;
- private static final boolean hasGLES1Impl;
+ private static /*final*/ boolean hasGL234Impl;
+ private static /*final*/ boolean hasGL4bcImpl;
+ private static /*final*/ boolean hasGL4Impl;
+ private static /*final*/ boolean hasGL3bcImpl;
+ private static /*final*/ boolean hasGL3Impl;
+ private static /*final*/ boolean hasGL2Impl;
+ private static /*final*/ boolean hasGL2ES12Impl;
+ private static /*final*/ boolean hasGLES2Impl;
+ private static /*final*/ boolean hasGLES1Impl;
/** The JVM/process wide default GL profile **/
- private static GLProfile defaultGLProfile;
+ private static /*final*/ GLProfile defaultGLProfile;
/** All GLProfiles */
- private static final HashMap/*<String, GLProfile>*/ mappedProfiles;
+ private static /*final*/ HashMap/*<String, GLProfile>*/ mappedProfiles;
/**
* Tries the profiles implementation and native libraries.
@@ -662,115 +809,203 @@ public class GLProfile implements Cloneable {
AccessControlContext acc = AccessController.getContext();
isAWTAvailable = !Debug.getBooleanProperty("java.awt.headless", true, acc) &&
- NWReflection.isClassAvailable("java.awt.Component") ;
+ ReflectionUtil.isClassAvailable("java.awt.Component") ;
isAWTJOGLAvailable = isAWTAvailable &&
- NWReflection.isClassAvailable("javax.media.nativewindow.awt.AWTGraphicsDevice") && // NativeWindow
- NWReflection.isClassAvailable("javax.media.opengl.awt.GLCanvas") ; // JOGL
+ ReflectionUtil.isClassAvailable("javax.media.nativewindow.awt.AWTGraphicsDevice") && // NativeWindow
+ ReflectionUtil.isClassAvailable("javax.media.opengl.awt.GLCanvas") ; // JOGL
boolean hasDesktopGL = false;
boolean hasDesktopGLES12 = false;
boolean hasNativeOSFactory = false;
-
+ Throwable t;
+
+ //
+ // First iteration of desktop GL availability detection
+ // - native libs exist
+ // - class exists
+ //
+ t=null;
try {
// See DRIHack.java for an explanation of why this is necessary
DRIHack.begin();
- NativeLibLoader.loadGLDesktop();
+ GLJNILibLoader.loadGLDesktop();
DRIHack.end();
hasDesktopGL = true;
- } catch (Throwable t) {
+ } catch (UnsatisfiedLinkError ule) {
+ t=ule;
+ } catch (SecurityException se) {
+ t=se;
+ } catch (NullPointerException npe) {
+ t=npe;
+ } catch (RuntimeException re) {
+ t=re;
+ }
+ if(null!=t) {
if (DEBUG) {
System.err.println("GLProfile.static Desktop GL Library not available");
t.printStackTrace();
}
}
+ t=null;
try {
// See DRIHack.java for an explanation of why this is necessary
DRIHack.begin();
- NativeLibLoader.loadGLDesktopES12();
+ GLJNILibLoader.loadGLDesktopES12();
DRIHack.end();
hasDesktopGLES12 = true;
- } catch (Throwable t) {
+ } catch (UnsatisfiedLinkError ule) {
+ t=ule;
+ } catch (SecurityException se) {
+ t=se;
+ } catch (NullPointerException npe) {
+ t=npe;
+ } catch (RuntimeException re) {
+ t=re;
+ }
+ if(null!=t) {
if (DEBUG) {
- System.err.println("GLProfile.static Desktop GL ES12 Library not available");
+ System.err.println("GLProfile.static Desktop GLES12 Library not available");
t.printStackTrace();
}
}
+
+ hasGL234Impl = hasDesktopGL && ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.gl4.GL4bcImpl");
+ hasGL4bcImpl = hasGL234Impl;
+ hasGL4Impl = hasGL234Impl;
+ hasGL3bcImpl = hasGL234Impl;
+ hasGL3Impl = hasGL234Impl;
+ hasGL2Impl = hasGL234Impl;
+ hasGL2ES12Impl = hasDesktopGLES12 && ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.gl2es12.GL2ES12Impl");
+ mappedProfiles = computeProfileMap();
+
+ //
+ // Second iteration of desktop GL availability detection
+ // utilizing the detected GL version in the shared context.
+ //
+ // - Instantiate GLDrawableFactory incl its shared dummy drawable/context,
+ // which will register at GLContext ..
+ //
+
if(hasDesktopGL||hasDesktopGLES12) {
+ // if successfull it has a shared dummy drawable and context created
try {
- hasNativeOSFactory = null!=GLDrawableFactory.getFactoryImpl(GL2);
- } catch (Throwable t) {
- if (DEBUG) {
- System.err.println("GLProfile.static - Native platform GLDrawable factory not available");
- t.printStackTrace();
- }
+ hasNativeOSFactory = null != GLDrawableFactory.getFactoryImpl(GL2);
+ } catch (RuntimeException re) {
+ System.err.println("GLProfile.static - Native platform GLDrawable factory not available");
+ re.printStackTrace();
}
}
- if(!hasNativeOSFactory) {
- hasDesktopGLES12=false;
- hasDesktopGL=false;
+ if(hasNativeOSFactory && !GLContext.mappedVersionsAvailableSet) {
+ // nobody yet set the available desktop versions, see {@link GLContextImpl#makeCurrent},
+ // so we have to add the usual suspect
+ GLContext.mapVersionAvailable(2, true, 1, 5, GLContext.CTX_PROFILE_COMPAT|GLContext.CTX_OPTION_ANY);
}
- // FIXME: check for real GL3 availability .. ?
- hasGL3bcImpl = hasDesktopGL && NWReflection.isClassAvailable("com.sun.opengl.impl.gl3.GL3bcImpl");
- hasGL3Impl = hasDesktopGL && NWReflection.isClassAvailable("com.sun.opengl.impl.gl3.GL3Impl");
- hasGL2Impl = hasDesktopGL && NWReflection.isClassAvailable("com.sun.opengl.impl.gl2.GL2Impl");
-
- hasGL2ES12Impl = hasDesktopGLES12 && NWReflection.isClassAvailable("com.sun.opengl.impl.gl2es12.GL2ES12Impl");
+ if(!hasNativeOSFactory) {
+ hasDesktopGL = false;
+ hasGL234Impl = false;
+ hasGL4bcImpl = false;
+ hasGL4Impl = false;
+ hasGL3bcImpl = false;
+ hasGL3Impl = false;
+ hasGL2ES12Impl = false;
+ hasGL2Impl = false;
+ } else {
+ hasGL4bcImpl = hasGL4bcImpl && GLContext.isGL4bcAvailable();
+ hasGL4Impl = hasGL4Impl && GLContext.isGL4Available();
+ hasGL3bcImpl = hasGL3bcImpl && GLContext.isGL3bcAvailable();
+ hasGL3Impl = hasGL3Impl && GLContext.isGL3Available();
+ hasGL2Impl = hasGL2Impl && GLContext.isGL2Available();
+ hasGL2ES12Impl = hasGL2ES12Impl && GLContext.isGL2Available();
+ }
boolean btest = false;
- boolean hasEGLDynLookup = NWReflection.isClassAvailable("com.sun.opengl.impl.egl.EGLDynamicLookupHelper");
+ boolean hasEGLDynLookup = ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.egl.EGLDynamicLookupHelper");
boolean hasEGLDrawableFactory = false;
+ t=null;
try {
if(hasEGLDynLookup) {
hasEGLDrawableFactory = null!=GLDrawableFactory.getFactoryImpl(GLES2);
- btest = hasEGLDrawableFactory &&
- NWReflection.isClassAvailable("com.sun.opengl.impl.es2.GLES2Impl") &&
- null!=com.sun.opengl.impl.egl.EGLDynamicLookupHelper.getDynamicLookupHelper(2);
+ try {
+ btest = hasEGLDrawableFactory &&
+ ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.es2.GLES2Impl") &&
+ null!=com.jogamp.opengl.impl.egl.EGLDynamicLookupHelper.getDynamicLookupHelper(2);
+ } catch (GLException gle) {
+ // n/a ..
+ }
}
- } catch (Throwable t) {
+ } catch (UnsatisfiedLinkError ule) {
+ t=ule;
+ } catch (SecurityException se) {
+ t=se;
+ } catch (NullPointerException npe) {
+ t=npe;
+ } catch (RuntimeException re) {
+ t=re;
+ }
+ if(null!=t) {
if (DEBUG) {
System.err.println("GLProfile.static - GL ES2 Factory/Library not available");
t.printStackTrace();
}
}
hasGLES2Impl = btest;
+ if(hasGLES2Impl) {
+ GLContext.mapVersionAvailable(2, false, 2, 0, GLContext.CTX_PROFILE_ES|GLContext.CTX_PROFILE_CORE|GLContext.CTX_OPTION_ANY);
+ }
btest = false;
- try {
- if(hasEGLDynLookup) {
+ if(hasEGLDynLookup) {
+ try {
btest = hasEGLDrawableFactory &&
- NWReflection.isClassAvailable("com.sun.opengl.impl.es1.GLES1Impl") &&
- null!=com.sun.opengl.impl.egl.EGLDynamicLookupHelper.getDynamicLookupHelper(1);
- }
- } catch (Throwable t) {
- if (DEBUG) {
- System.err.println("GLProfile.static - GL ES1 Factory/Library not available");
- t.printStackTrace();
+ ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.es1.GLES1Impl") &&
+ null!=com.jogamp.opengl.impl.egl.EGLDynamicLookupHelper.getDynamicLookupHelper(1);
+ } catch (GLException jre) {
+ /* just not available .. */
}
}
hasGLES1Impl = btest;
+ if(hasGLES1Impl) {
+ GLContext.mapVersionAvailable(1, false, 1, 0, GLContext.CTX_PROFILE_ES|GLContext.CTX_PROFILE_CORE|GLContext.CTX_OPTION_ANY);
+ }
+
+ mappedProfiles = computeProfileMap();
+ if(null==defaultGLProfile) {
+ throw new GLException("No profile available: "+list2String(GL_PROFILE_LIST_ALL)+", "+glAvailabilityToString());
+ }
if (DEBUG) {
System.err.println("GLProfile.static isAWTAvailable "+isAWTAvailable);
System.err.println("GLProfile.static isAWTJOGLAvailable "+isAWTJOGLAvailable);
System.err.println("GLProfile.static hasNativeOSFactory "+hasNativeOSFactory);
- System.err.println("GLProfile.static hasDesktopGLES12 "+hasDesktopGLES12);
System.err.println("GLProfile.static hasDesktopGL "+hasDesktopGL);
- System.err.println("GLProfile.static hasGL3bcImpl "+hasGL3bcImpl);
- System.err.println("GLProfile.static hasGL3Impl "+hasGL3Impl);
- System.err.println("GLProfile.static hasGL2Impl "+hasGL2Impl);
- System.err.println("GLProfile.static hasGL2ES12Impl "+hasGL2ES12Impl);
+ System.err.println("GLProfile.static hasDesktopGLES12 "+hasDesktopGLES12);
System.err.println("GLProfile.static hasEGLDynLookup "+hasEGLDynLookup);
System.err.println("GLProfile.static hasEGLDrawableFactory "+hasEGLDrawableFactory);
- System.err.println("GLProfile.static hasGLES2Impl "+hasGLES2Impl);
- System.err.println("GLProfile.static hasGLES1Impl "+hasGLES1Impl);
+ System.err.println("GLProfile.static hasGL234Impl "+hasGL234Impl);
+ System.err.println("GLProfile.static "+glAvailabilityToString());
}
+ }
+ private static final String list2String(String[] list) {
+ StringBuffer msg = new StringBuffer();
+ msg.append("[");
+ for (int i = 0; i < list.length; i++) {
+ if (i > 0)
+ msg.append(", ");
+ msg.append(list[i]);
+ }
+ msg.append("]");
+ return msg.toString();
+ }
+
+ private static HashMap computeProfileMap() {
+ defaultGLProfile=null;
HashMap/*<String, GLProfile>*/ _mappedProfiles = new HashMap(GL_PROFILE_LIST_ALL.length);
for(int i=0; i<GL_PROFILE_LIST_ALL.length; i++) {
String profile = GL_PROFILE_LIST_ALL[i];
@@ -793,22 +1028,7 @@ public class GLProfile implements Cloneable {
}
}
}
- mappedProfiles = _mappedProfiles; // final ..
- if(null==defaultGLProfile) {
- throw new GLException("No profile available: "+list2String(GL_PROFILE_LIST_ALL));
- }
- }
-
- private static final String list2String(String[] list) {
- StringBuffer msg = new StringBuffer();
- msg.append("[");
- for (int i = 0; i < list.length; i++) {
- if (i > 0)
- msg.append(", ");
- msg.append(list[i]);
- }
- msg.append("]");
- return msg.toString();
+ return _mappedProfiles;
}
/**
@@ -820,6 +1040,10 @@ public class GLProfile implements Cloneable {
return GL2ES12;
} else if(hasGL2Impl) {
return GL2;
+ } else if(hasGL3bcImpl) {
+ return GL3bc;
+ } else if(hasGL4bcImpl) {
+ return GL4bc;
} else if(hasGLES1Impl) {
return GLES1;
}
@@ -830,23 +1054,33 @@ public class GLProfile implements Cloneable {
return GL2;
} else if(hasGL3Impl) {
return GL3;
- } else if(hasGL3bcImpl) {
- return GL3bc;
+ } else if(hasGL4Impl) {
+ return GL4;
} else if(hasGLES2Impl) {
return GLES2;
}
- } else if(GL3bc.equals(profile) && hasGL3bcImpl) {
- return GL3bc;
- } else if(GL3.equals(profile)) {
- if(hasGL3Impl) {
- return GL3;
+ } else if(GL2GL3.equals(profile)) {
+ if(hasGL2Impl) {
+ return GL2;
} else if(hasGL3bcImpl) {
return GL3bc;
+ } else if(hasGL4bcImpl) {
+ return GL4bc;
+ } else if(hasGL3Impl) {
+ return GL3;
+ } else if(hasGL4Impl) {
+ return GL4;
}
+ } else if(GL4bc.equals(profile) && hasGL4bcImpl) {
+ return GL4bc;
+ } else if(GL4.equals(profile) && hasGL4Impl) {
+ return GL4;
+ } else if(GL3bc.equals(profile) && hasGL3bcImpl) {
+ return GL3bc;
+ } else if(GL3.equals(profile) && hasGL3Impl) {
+ return GL3;
} else if(GL2.equals(profile) && hasGL2Impl) {
return GL2;
- } else if(GL2GL3.equals(profile) && hasGL2Impl) {
- return GL2;
} else if(GLES2.equals(profile) && hasGLES2Impl) {
return GLES2;
} else if(GLES1.equals(profile) && hasGLES1Impl) {