aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/javax/media/opengl/GLProfile.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/javax/media/opengl/GLProfile.java')
-rw-r--r--src/jogl/classes/javax/media/opengl/GLProfile.java148
1 files changed, 103 insertions, 45 deletions
diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java
index 324fdee92..08712e488 100644
--- a/src/jogl/classes/javax/media/opengl/GLProfile.java
+++ b/src/jogl/classes/javax/media/opengl/GLProfile.java
@@ -44,6 +44,7 @@ import jogamp.opengl.DesktopGLDynamicLookupHelper;
import com.jogamp.common.GlueGenVersion;
import com.jogamp.common.jvm.JNILibLoaderBase;
import com.jogamp.common.os.Platform;
+import com.jogamp.common.util.PropertyAccess;
import com.jogamp.common.util.ReflectionUtil;
import com.jogamp.common.util.VersionUtil;
import com.jogamp.common.util.cache.TempJarCache;
@@ -75,11 +76,70 @@ import java.util.Map;
*/
public class GLProfile {
- public static final boolean DEBUG = Debug.debug("GLProfile");
+ public static final boolean DEBUG;
+
+ /**
+ * In case no OpenGL ES profiles are required
+ * and if one platform may have a buggy implementation,
+ * setting the property <code>jogl.disable.opengles</code> disables querying possible existing OpenGL ES profiles.
+ */
+ public static final boolean disableOpenGLES;
+
+ /**
+ * In case no native OpenGL core profiles are required
+ * and if one platform may have a buggy implementation,
+ * setting the property <code>jogl.disable.openglcore</code> disables querying possible existing native OpenGL core profiles.
+ * <p>
+ * This exclusion is disabled for {@link Platform.OSType#MACOS}.
+ * </p>
+ */
+ public static final boolean disableOpenGLCore;
+
+ /**
+ * In case the implementation of the <i>ARB_create_context</i>
+ * context creation extension is buggy on one platform,
+ * setting the property <code>jogl.disable.openglarbcontext</code> disables utilizing it.
+ * <p>
+ * This exclusion is disabled for {@link Platform.OSType#MACOS}.
+ * </p>
+ */
+ public static final boolean disableOpenGLARBContext;
+
+ /**
+ * We have to disable support for ANGLE, the D3D ES2 emulation on Windows provided w/ Firefox and Chrome.
+ * When run in the mentioned browsers, the eglInitialize(..) implementation crashes.
+ * <p>
+ * This can be overridden by explicitly enabling ANGLE on Windows by setting the property
+ * <code>jogl.enable.ANGLE</code>.
+ * </p>
+ */
+ public static final boolean enableANGLE;
static {
// Also initializes TempJarCache if shall be used.
Platform.initSingleton();
+ final boolean isOSX = Platform.OSType.MACOS == Platform.getOSType();
+
+ DEBUG = Debug.debug("GLProfile");
+ disableOpenGLES = PropertyAccess.isPropertyDefined("jogl.disable.opengles", true);
+ disableOpenGLCore = PropertyAccess.isPropertyDefined("jogl.disable.openglcore", true) && !isOSX;
+ disableOpenGLARBContext = PropertyAccess.isPropertyDefined("jogl.disable.openglarbcontext", true) && !isOSX;
+ enableANGLE = PropertyAccess.isPropertyDefined("jogl.enable.ANGLE", true);
+ }
+
+ /**
+ * @return <code>true</code> if JOGL has been initialized, i.e. manually via {@link #initSingleton()} or implicit,
+ * otherwise returns <code>false</code>.
+ *
+ * @since 2.2.1
+ */
+ public static boolean isInitialized() {
+ initLock.lock();
+ try {
+ return initialized;
+ } finally {
+ initLock.unlock();
+ }
}
/**
@@ -425,7 +485,7 @@ public class GLProfile {
if(null != map) {
for (final Map.Entry<String,GLProfile> entry : map.entrySet()) {
- if( !GL_DEFAULT.equals(entry.getKey()) ) {
+ if( GL_DEFAULT != entry.getKey() ) {
if(useIndent) {
doIndent(sb.append(Platform.getNewline()), indent, indentCount);
}
@@ -468,44 +528,46 @@ public class GLProfile {
/** 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";
+ public static final String GL4bc = "GL4bc"; // Implicitly intern(), see Bug 1059
/** The desktop OpenGL core profile 4.x, with x >= 0 */
- public static final String GL4 = "GL4";
+ public static final String GL4 = "GL4"; // Implicitly intern(), see Bug 1059
/** 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";
+ public static final String GL3bc = "GL3bc"; // Implicitly intern(), see Bug 1059
/** The desktop OpenGL core profile 3.x, with x >= 1 */
- public static final String GL3 = "GL3";
+ public static final String GL3 = "GL3"; // Implicitly intern(), see Bug 1059
/** The desktop OpenGL profile 1.x up to 3.0 */
- public static final String GL2 = "GL2";
+ public static final String GL2 = "GL2"; // Implicitly intern(), see Bug 1059
/** The embedded OpenGL profile ES 1.x, with x >= 0 */
- public static final String GLES1 = "GLES1";
+ public static final String GLES1 = "GLES1"; // Implicitly intern(), see Bug 1059
/** The embedded OpenGL profile ES 2.x, with x >= 0 */
- public static final String GLES2 = "GLES2";
+ public static final String GLES2 = "GLES2"; // Implicitly intern(), see Bug 1059
/** The embedded OpenGL profile ES 3.x, with x >= 0 */
- public static final String GLES3 = "GLES3";
+ public static final String GLES3 = "GLES3"; // Implicitly intern(), see Bug 1059
/** The intersection of the desktop GL2 and embedded ES1 profile */
- public static final String GL2ES1 = "GL2ES1";
+ public static final String GL2ES1 = "GL2ES1"; // Implicitly intern(), see Bug 1059
/** The intersection of the desktop GL3, GL2 and embedded ES2 profile */
- public static final String GL2ES2 = "GL2ES2";
+ public static final String GL2ES2 = "GL2ES2"; // Implicitly intern(), see Bug 1059
/** The intersection of the desktop GL3 and GL2 profile */
- public static final String GL2GL3 = "GL2GL3";
+ public static final String GL2GL3 = "GL2GL3"; // Implicitly intern(), see Bug 1059
/** The intersection of the desktop GL4 and ES3 profile, available only if either ES3 or GL4 w/ <code>GL_ARB_ES3_compatibility</code> is available. */
- public static final String GL4ES3 = "GL4ES3";
+ public static final String GL4ES3 = "GL4ES3"; // Implicitly intern(), see Bug 1059
/** The default profile, used for the device default profile map */
- private static final String GL_DEFAULT = "GL_DEFAULT";
+ private static final String GL_DEFAULT = "GL_DEFAULT"; // Implicitly intern(), see Bug 1059
+ /** The default profile, used for the device default profile map */
+ private static final String GL_GL = "GL"; // Implicitly intern(), see Bug 1059
/**
* All GL Profiles in the order of default detection.
@@ -891,7 +953,7 @@ public class GLProfile {
public static GLProfile get(final AbstractGraphicsDevice device, String profile)
throws GLException
{
- if(null==profile || profile.equals("GL")) {
+ if(null==profile || profile == GL_GL) {
profile = GL_DEFAULT;
}
final HashMap<String /*GLProfile_name*/, GLProfile> glpMap = getProfileMap(device, true);
@@ -963,21 +1025,21 @@ public class GLProfile {
* This requires an EGL interface.
*/
public static boolean usesNativeGLES1(final String profileImpl) {
- return GLES1.equals(profileImpl);
+ return GLES1 == profileImpl;
}
/** Indicates whether the native OpenGL ES3 or ES2 profile is in use.
* This requires an EGL, ES3 or ES2 compatible interface.
*/
public static boolean usesNativeGLES2(final String profileImpl) {
- return GLES3.equals(profileImpl) || GLES2.equals(profileImpl);
+ return GLES3 == profileImpl || GLES2 == profileImpl;
}
/** Indicates whether the native OpenGL ES2 profile is in use.
* This requires an EGL, ES3 compatible interface.
*/
public static boolean usesNativeGLES3(final String profileImpl) {
- return GLES3.equals(profileImpl);
+ return GLES3 == profileImpl;
}
/** Indicates whether either of the native OpenGL ES profiles are in use. */
@@ -1529,7 +1591,7 @@ public class GLProfile {
@Override
public String toString() {
- return "GLProfile[" + getName() + "/" + getImplName() + "."+(this.isHardwareRasterizer?"hw":"sw")+"]";
+ return "GLProfile[" + getName() + "/" + getImplName() + "."+(this.isHardwareRasterizer?"hw":"sw")+(isCustom?".custom":"")+"]";
}
private static /*final*/ boolean isAWTAvailable;
@@ -1952,13 +2014,13 @@ public class GLProfile {
if( null != profileImpl ) {
final GLProfile glProfile;
if( profile.equals( profileImpl ) ) {
- glProfile = new GLProfile(profile, null, isHardwareRasterizer[0]);
+ glProfile = new GLProfile(profile, null, isHardwareRasterizer[0], false /* custom */);
} else {
final GLProfile _mglp = _mappedProfiles.get( profileImpl );
if( null == _mglp ) {
throw new InternalError("XXX0 profile["+i+"]: "+profile+" -> profileImpl "+profileImpl+" !!! not mapped ");
}
- glProfile = new GLProfile(profile, _mglp, isHardwareRasterizer[0]);
+ glProfile = new GLProfile(profile, _mglp, isHardwareRasterizer[0], false /* custom */);
}
_mappedProfiles.put(profile, glProfile);
if (DEBUG) {
@@ -1994,7 +2056,7 @@ public class GLProfile {
* Returns the profile implementation
*/
private static String computeProfileImpl(final AbstractGraphicsDevice device, final String profile, final boolean desktopCtxUndef, final boolean esCtxUndef, final boolean isHardwareRasterizer[]) {
- if (GL2ES1.equals(profile)) {
+ if (GL2ES1 == profile) {
final boolean es1HardwareRasterizer[] = new boolean[1];
final boolean gles1Available = hasGLES1Impl && ( esCtxUndef || GLContext.isGLES1Available(device, es1HardwareRasterizer) );
final boolean gles1HWAvailable = gles1Available && es1HardwareRasterizer[0] ;
@@ -2019,7 +2081,7 @@ public class GLProfile {
isHardwareRasterizer[0] = es1HardwareRasterizer[0];
return GLES1;
}
- } else if (GL2ES2.equals(profile)) {
+ } else if (GL2ES2 == profile) {
final boolean es2HardwareRasterizer[] = new boolean[1];
final boolean gles2Available = hasGLES3Impl && ( esCtxUndef || GLContext.isGLES2Available(device, es2HardwareRasterizer) );
final boolean gles2HWAvailable = gles2Available && es2HardwareRasterizer[0] ;
@@ -2061,7 +2123,7 @@ public class GLProfile {
isHardwareRasterizer[0] = es2HardwareRasterizer[0];
return GLES2;
}
- } else if (GL4ES3.equals(profile)) {
+ } else if (GL4ES3 == profile) {
final boolean gles3CompatAvail = GLContext.isGLES3CompatibleAvailable(device);
if( desktopCtxUndef || esCtxUndef || gles3CompatAvail ) {
final boolean es3HardwareRasterizer[] = new boolean[1];
@@ -2078,23 +2140,13 @@ public class GLProfile {
return GL4bc;
}
}
- if(GLContext.isGL3Available(device, isHardwareRasterizer)) {
- if(!gles3HWAvailable || isHardwareRasterizer[0]) {
- return GL3;
- }
- }
- if( desktopCtxUndef || GLContext.isGL3bcAvailable(device, isHardwareRasterizer)) {
- if(!gles3HWAvailable || isHardwareRasterizer[0]) {
- return GL3bc;
- }
- }
}
if(gles3Available) {
isHardwareRasterizer[0] = es3HardwareRasterizer[0];
return GLES3;
}
}
- } else if(GL2GL3.equals(profile)) {
+ } else if(GL2GL3 == profile) {
if(hasGL234Impl) {
if( GLContext.isGL4bcAvailable(device, isHardwareRasterizer)) {
return GL4bc;
@@ -2108,21 +2160,21 @@ public class GLProfile {
return GL2;
}
}
- } else if(GL4bc.equals(profile) && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL4bcAvailable(device, isHardwareRasterizer))) {
+ } else if(GL4bc == profile && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL4bcAvailable(device, isHardwareRasterizer))) {
return desktopCtxUndef ? GL4bc : GLContext.getAvailableGLProfileName(device, 4, GLContext.CTX_PROFILE_COMPAT);
- } else if(GL4.equals(profile) && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL4Available(device, isHardwareRasterizer))) {
+ } else if(GL4 == profile && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL4Available(device, isHardwareRasterizer))) {
return desktopCtxUndef ? GL4 : GLContext.getAvailableGLProfileName(device, 4, GLContext.CTX_PROFILE_CORE);
- } else if(GL3bc.equals(profile) && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL3bcAvailable(device, isHardwareRasterizer))) {
+ } else if(GL3bc == profile && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL3bcAvailable(device, isHardwareRasterizer))) {
return desktopCtxUndef ? GL3bc : GLContext.getAvailableGLProfileName(device, 3, GLContext.CTX_PROFILE_COMPAT);
- } else if(GL3.equals(profile) && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL3Available(device, isHardwareRasterizer))) {
+ } else if(GL3 == profile && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL3Available(device, isHardwareRasterizer))) {
return desktopCtxUndef ? GL3 : GLContext.getAvailableGLProfileName(device, 3, GLContext.CTX_PROFILE_CORE);
- } else if(GL2.equals(profile) && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL2Available(device, isHardwareRasterizer))) {
+ } else if(GL2 == profile && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL2Available(device, isHardwareRasterizer))) {
return desktopCtxUndef ? GL2 : GLContext.getAvailableGLProfileName(device, 2, GLContext.CTX_PROFILE_COMPAT);
- } else if(GLES3.equals(profile) && hasGLES3Impl && ( esCtxUndef || GLContext.isGLES3Available(device, isHardwareRasterizer))) {
+ } else if(GLES3 == profile && hasGLES3Impl && ( esCtxUndef || GLContext.isGLES3Available(device, isHardwareRasterizer))) {
return esCtxUndef ? GLES3 : GLContext.getAvailableGLProfileName(device, 3, GLContext.CTX_PROFILE_ES);
- } else if(GLES2.equals(profile) && hasGLES3Impl && ( esCtxUndef || GLContext.isGLES2Available(device, isHardwareRasterizer))) {
+ } else if(GLES2 == profile && hasGLES3Impl && ( esCtxUndef || GLContext.isGLES2Available(device, isHardwareRasterizer))) {
return esCtxUndef ? GLES2 : GLContext.getAvailableGLProfileName(device, 2, GLContext.CTX_PROFILE_ES);
- } else if(GLES1.equals(profile) && hasGLES1Impl && ( esCtxUndef || GLContext.isGLES1Available(device, isHardwareRasterizer))) {
+ } else if(GLES1 == profile && hasGLES1Impl && ( esCtxUndef || GLContext.isGLES1Available(device, isHardwareRasterizer))) {
return esCtxUndef ? GLES1 : GLContext.getAvailableGLProfileName(device, 1, GLContext.CTX_PROFILE_ES);
}
return null;
@@ -2180,13 +2232,19 @@ public class GLProfile {
}
}
- private GLProfile(final String profile, final GLProfile profileImpl, final boolean isHardwareRasterizer) {
+ private GLProfile(final String profile, final GLProfile profileImpl, final boolean isHardwareRasterizer, final boolean isCustom) {
this.profile = profile;
this.profileImpl = profileImpl;
this.isHardwareRasterizer = isHardwareRasterizer;
+ this.isCustom = isCustom;
+ }
+
+ public static GLProfile createCustomGLProfile(final String profile, final GLProfile profileImpl) {
+ return new GLProfile(profile, profileImpl, profileImpl.isHardwareRasterizer, true);
}
private final GLProfile profileImpl;
private final String profile;
private final boolean isHardwareRasterizer;
+ private final boolean isCustom;
}