summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/javax/media
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-05-11 04:35:34 +0200
committerSven Gothel <[email protected]>2010-05-11 04:35:34 +0200
commit3ab87cbbad28b9f90bb83981aab73ccf478dc929 (patch)
tree3de32576eede37cba59b4ccce4814d0cd7781683 /src/jogl/classes/javax/media
parent6798fc1fb008eff4179f64775a7bf33cfbfd1981 (diff)
Missing comment for last commit 6798fc1fb008eff4179f64775a7bf33cfbfd1981:
- zip Javadocs, moved to build* dir - re-enable WGL ARB GetContext (buggy) - relaxed junit tests: src/junit/com/jogamp/test/junit/jogl/awt/TestAWT01GLn.java - GL3bc/GL4bc + AWT doesn't work with ATI currently, driver bug src/junit/com/jogamp/test/junit/jogl/offscreen/TestOffscreen01NEWT.java - All test cases, ie pbuffer detection may fail, no pixmap detection - Fix Windows ARG CreateContext - GLContext - GLVersion mapping functions: use profile bit - Fix isGL*() queries { compat|core, ..} - Pass through the profile bit (COMPAT, CORE, ES), only one can be set - GLProfile - glAvailabilityToString() add the queried HW Context info -
Diffstat (limited to 'src/jogl/classes/javax/media')
-rw-r--r--src/jogl/classes/javax/media/opengl/GLContext.java132
-rw-r--r--src/jogl/classes/javax/media/opengl/GLProfile.java70
2 files changed, 172 insertions, 30 deletions
diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java
index c07bbeaf4..37172e370 100644
--- a/src/jogl/classes/javax/media/opengl/GLContext.java
+++ b/src/jogl/classes/javax/media/opengl/GLContext.java
@@ -300,6 +300,8 @@ public abstract class GLContext {
public final int getGLVersionMajor() { return ctxMajorVersion; }
public final int getGLVersionMinor() { return ctxMinorVersion; }
public final boolean isGLCompatibilityProfile() { return ( 0 != ( CTX_PROFILE_COMPAT & ctxOptions ) ); }
+ public final boolean isGLCoreProfile() { return ( 0 != ( CTX_PROFILE_CORE & ctxOptions ) ); }
+ public final boolean isGLEmbeddedProfile() { return ( 0 != ( CTX_PROFILE_ES & ctxOptions ) ); }
public final boolean isGLForwardCompatible() { return ( 0 != ( CTX_OPTION_FORWARD & ctxOptions ) ); }
public final boolean isCreatedWithARBMethod() { return ( 0 != ( CTX_IS_ARB_CREATED & ctxOptions ) ); }
@@ -355,7 +357,7 @@ public abstract class GLContext {
protected static final int CTX_PROFILE_COMPAT = 1 << 1;
/** <code>ARB_create_context</code> related: core profile */
protected static final int CTX_PROFILE_CORE = 1 << 2;
- /** <code>ARB_create_context</code> related: flag forward compatible */
+ /** <code>ARB_create_context</code> related: ES profile */
protected static final int CTX_PROFILE_ES = 1 << 3;
/** <code>ARB_create_context</code> related: flag forward compatible */
protected static final int CTX_OPTION_FORWARD = 1 << 4;
@@ -366,23 +368,23 @@ public abstract class GLContext {
public final boolean isGL4bc() {
- return ctxMajorVersion>=4 && CTX_PROFILE_COMPAT==(ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_ES));
+ return ctxMajorVersion>=4 && 0!=(ctxOptions & CTX_PROFILE_COMPAT);
}
public final boolean isGL4() {
- return ctxMajorVersion>=4 && 0==(ctxOptions & (CTX_PROFILE_ES));
+ return ctxMajorVersion>=4 && 0!=(ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_CORE));
}
public final boolean isGL3bc() {
- return ctxMajorVersion>=3 && CTX_PROFILE_COMPAT==(ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_ES));
+ return ctxMajorVersion>=3 && 0!=(ctxOptions & CTX_PROFILE_COMPAT);
}
public final boolean isGL3() {
- return ctxMajorVersion>=3 && 0==(ctxOptions & (CTX_PROFILE_ES));
+ return ctxMajorVersion>=3 && 0!=(ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_CORE));
}
public final boolean isGL2() {
- return ctxMajorVersion>=1 && CTX_PROFILE_COMPAT==(ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_ES));
+ return ctxMajorVersion>=1 && 0!=(ctxOptions & CTX_PROFILE_COMPAT);
}
public final boolean isGL2GL3() {
@@ -390,15 +392,15 @@ public abstract class GLContext {
}
public final boolean isGLES1() {
- return ctxMajorVersion==1 && CTX_PROFILE_ES==(ctxOptions & CTX_PROFILE_ES);
+ return ctxMajorVersion==1 && 0!=(ctxOptions & CTX_PROFILE_ES);
}
public final boolean isGLES2() {
- return ctxMajorVersion==2 && CTX_PROFILE_ES==(ctxOptions & CTX_PROFILE_ES);
+ return ctxMajorVersion==2 && 0!=(ctxOptions & CTX_PROFILE_ES);
}
public final boolean isGLES() {
- return CTX_PROFILE_ES==(ctxOptions & CTX_PROFILE_ES);
+ return isGLEmbeddedProfile();
}
public final boolean isGL2ES1() {
@@ -456,16 +458,79 @@ public abstract class GLContext {
return true;
}
- public static final boolean isGLVersionAvailable(int major, boolean compatibility) {
- int key = compose8bit(major, compatibility?CTX_PROFILE_COMPAT:CTX_PROFILE_CORE, 0, 0);
- int val = mappedVersionsAvailable.get( key );
- return val>0;
+ /**
+ * @param major Key Value either 1, 2, 3 or 4
+ * @param profile Key Value either {@link #CTX_PROFILE_COMPAT}, {@link #CTX_PROFILE_CORE} or {@link #CTX_PROFILE_ES}
+ */
+ public static final String getGLVersionAvailable(int major, int profile) {
+ int _major[] = { 0 };
+ int _minor[] = { 0 };
+ int _ctp[] = { 0 };
+ if(getGLVersionAvailable(major, profile, _major, _minor, _ctp)) {
+ return getGLVersion(_major[0], _minor[0], _ctp[0], null);
+ }
+ return null;
+ }
+
+ /**
+ * @param reqMajor Key Value either 1, 2, 3 or 4
+ * @param reqProfile Key Value either {@link #CTX_PROFILE_COMPAT}, {@link #CTX_PROFILE_CORE} or {@link #CTX_PROFILE_ES}
+ * @param major if not null, returns the used major version
+ * @param minor if not null, returns the used minor version
+ * @param ctp if not null, returns the used context profile
+ */
+ public static final boolean getGLVersionAvailable(int reqMajor, int reqProfile, int[] major, int minor[], int ctp[]) {
+ int key = compose8bit(reqMajor, reqProfile, 0, 0);
+ int val = mappedVersionsAvailable.get( key );
+ if(val<=0) {
+ return false;
+ }
+ if(null!=major) {
+ major[0] = getComposed8bit(val, 1);
+ }
+ if(null!=minor) {
+ minor[0] = getComposed8bit(val, 2);
+ }
+ if(null!=ctp) {
+ ctp[0] = getComposed8bit(val, 3);
+ }
+ return true;
+ }
+
+ /**
+ * @param major Key Value either 1, 2, 3 or 4
+ * @param profile Key Value either {@link #CTX_PROFILE_COMPAT}, {@link #CTX_PROFILE_CORE} or {@link #CTX_PROFILE_ES}
+ */
+ public static final boolean isGLVersionAvailable(int major, int profile) {
+ return getGLVersionAvailable(major, profile, null, null, null);
+ }
+ public static final boolean isGL4bcAvailable() { return isGLVersionAvailable(4, CTX_PROFILE_COMPAT); }
+ public static final boolean isGL4Available() { return isGLVersionAvailable(4, CTX_PROFILE_CORE); }
+ public static final boolean isGL3bcAvailable() { return isGLVersionAvailable(3, CTX_PROFILE_COMPAT); }
+ public static final boolean isGL3Available() { return isGLVersionAvailable(3, CTX_PROFILE_CORE); }
+ public static final boolean isGL2Available() { return isGLVersionAvailable(2, CTX_PROFILE_COMPAT); }
+
+ public static String getGLVersion(int major, int minor, int ctp, String gl_version) {
+ boolean needColon = false;
+ StringBuffer sb = new StringBuffer();
+ sb.append(major);
+ sb.append(".");
+ sb.append(minor);
+ sb.append(" (");
+ needColon = appendString(sb, "ES", needColon, 0 != ( CTX_PROFILE_ES & ctp ));
+ needColon = appendString(sb, "compatibility profile", needColon, 0 != ( CTX_PROFILE_COMPAT & ctp ));
+ needColon = appendString(sb, "core profile", needColon, 0 != ( CTX_PROFILE_CORE & ctp ));
+ needColon = appendString(sb, "forward compatible", needColon, 0 != ( CTX_OPTION_FORWARD & ctp ));
+ needColon = appendString(sb, "any", needColon, 0 != ( CTX_OPTION_ANY & ctp ));
+ needColon = appendString(sb, "new", needColon, 0 != ( CTX_IS_ARB_CREATED & ctp ));
+ needColon = appendString(sb, "old", needColon, 0 == ( CTX_IS_ARB_CREATED & ctp ));
+ sb.append(")");
+ if(null!=gl_version) {
+ sb.append(" - ");
+ sb.append(gl_version);
+ }
+ return sb.toString();
}
- public static final boolean isGL4bcAvailable() { return isGLVersionAvailable(4, true); }
- public static final boolean isGL4Available() { return isGLVersionAvailable(4, false); }
- public static final boolean isGL3bcAvailable() { return isGLVersionAvailable(3, true); }
- public static final boolean isGL3Available() { return isGLVersionAvailable(3, false); }
- public static final boolean isGL2Available() { return isGLVersionAvailable(2, true); }
protected static final IntIntHashMap mappedVersionsAvailable;
protected static volatile boolean mappedVersionsAvailableSet;
@@ -478,16 +543,32 @@ public abstract class GLContext {
mappedVersionsAvailable.setKeyNotFoundValue(-1);
}
+ private static void validateProfileBits(int bits, String argName) {
+ int num = 0;
+ if( 0 != ( CTX_PROFILE_COMPAT & bits ) ) { num++; }
+ if( 0 != ( CTX_PROFILE_CORE & bits ) ) { num++; }
+ if( 0 != ( CTX_PROFILE_ES & bits ) ) { num++; }
+ if(1!=num) {
+ throw new GLException("Internal Error: "+argName+": 1 != num-profiles: "+num);
+ }
+ }
+
/**
* Called by {@link GLContextImpl#createContextARBMapVersionsAvailable} not intendet to be used by
* implementations. However, if {@link #createContextARB} is not being used within the
* {@link GLDrawableImpl} constructor, GLProfile has to map the available versions.
*
+ * @param reqMajor Key Value either 1, 2, 3 or 4
+ * @param profile Key Value either {@link #CTX_PROFILE_COMPAT}, {@link #CTX_PROFILE_CORE} or {@link #CTX_PROFILE_ES}
+
* @see #createContextARBMapVersionsAvailable
*/
- protected static void mapVersionAvailable(int reqMajor, boolean reqCompat, int resMajor, int resMinor, int resCtp)
+ protected static void mapVersionAvailable(int reqMajor, int profile, int resMajor, int resMinor, int resCtp)
{
- int key = compose8bit(reqMajor, reqCompat?CTX_PROFILE_COMPAT:CTX_PROFILE_CORE, 0, 0);
+ validateProfileBits(profile, "profile");
+ validateProfileBits(resCtp, "resCtp");
+
+ int key = compose8bit(reqMajor, profile, 0, 0);
int val = compose8bit(resMajor, resMinor, resCtp, 0);
mappedVersionsAvailable.put( key, val );
}
@@ -532,5 +613,16 @@ public abstract class GLContext {
return "0x" + Long.toHexString(hex);
}
+ private static boolean appendString(StringBuffer sb, String string, boolean needColon, boolean condition) {
+ if(condition) {
+ if(needColon) {
+ sb.append(", ");
+ }
+ sb.append(string);
+ needColon=true;
+ }
+ return needColon;
+ }
+
}
diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java
index 7b8ac6c2a..6b49b24df 100644
--- a/src/jogl/classes/javax/media/opengl/GLProfile.java
+++ b/src/jogl/classes/javax/media/opengl/GLProfile.java
@@ -72,26 +72,76 @@ public class GLProfile implements Cloneable {
public static final boolean isGL2ES1Available() { return null != mappedProfiles.get(GL2ES1); }
public static final boolean isGL2ES2Available() { return null != mappedProfiles.get(GL2ES2); }
+ private static final void glAvailabilityToString(StringBuffer sb, int major, int profile) {
+ String str = GLContext.getGLVersionAvailable(major, profile);
+ if(null==str) {
+ throw new GLException("Internal Error");
+ }
+ sb.append("[");
+ sb.append(str);
+ sb.append("]");
+ }
+
public static final String glAvailabilityToString() {
+ boolean avail;
+ String str;
StringBuffer sb = new StringBuffer();
+
sb.append("GLAvailability[Native[GL4bc ");
- sb.append(isGL4bcAvailable());
+ avail=isGL4bcAvailable();
+ sb.append(avail);
+ if(avail) {
+ glAvailabilityToString(sb, 4, GLContext.CTX_PROFILE_COMPAT);
+ }
+
sb.append(", GL4 ");
- sb.append(isGL4Available());
+ avail=isGL4Available();
+ sb.append(avail);
+ if(avail) {
+ glAvailabilityToString(sb, 4, GLContext.CTX_PROFILE_CORE);
+ }
+
sb.append(", GL3bc ");
- sb.append(isGL3bcAvailable());
+ avail=isGL3bcAvailable();
+ sb.append(avail);
+ if(avail) {
+ glAvailabilityToString(sb, 3, GLContext.CTX_PROFILE_COMPAT);
+ }
+
sb.append(", GL3 ");
- sb.append(isGL3Available());
+ avail=isGL3Available();
+ sb.append(avail);
+ if(avail) {
+ glAvailabilityToString(sb, 3, GLContext.CTX_PROFILE_CORE);
+ }
+
sb.append(", GL2 ");
- sb.append(isGL2Available());
+ avail=isGL2Available();
+ sb.append(avail);
+ if(avail) {
+ glAvailabilityToString(sb, 2, GLContext.CTX_PROFILE_COMPAT);
+ }
+
sb.append(", GL2ES1 ");
sb.append(isGL2ES1Available());
+
sb.append(", GLES1 ");
- sb.append(isGLES1Available());
+ avail=isGLES1Available();
+ sb.append(avail);
+ if(avail) {
+ glAvailabilityToString(sb, 1, GLContext.CTX_PROFILE_ES);
+ }
+
sb.append(", GL2ES2 ");
sb.append(isGL2ES2Available());
+
sb.append(", GLES2 ");
- sb.append(isGLES2Available());
+ avail=isGLES2Available();
+ sb.append(avail);
+ if(avail) {
+ glAvailabilityToString(sb, 2, GLContext.CTX_PROFILE_ES);
+ }
+
sb.append("], Profiles[");
for(Iterator i=mappedProfiles.values().iterator(); i.hasNext(); ) {
sb.append(((GLProfile)i.next()).toString());
@@ -910,7 +960,7 @@ public class GLProfile implements Cloneable {
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);
+ GLContext.mapVersionAvailable(2, GLContext.CTX_PROFILE_COMPAT, 1, 5, GLContext.CTX_PROFILE_COMPAT|GLContext.CTX_OPTION_ANY);
}
if(!hasNativeOSFactory) {
@@ -957,7 +1007,7 @@ public class GLProfile implements Cloneable {
}
hasGLES2Impl = btest;
if(hasGLES2Impl) {
- GLContext.mapVersionAvailable(2, false, 2, 0, GLContext.CTX_PROFILE_ES|GLContext.CTX_PROFILE_CORE|GLContext.CTX_OPTION_ANY);
+ GLContext.mapVersionAvailable(2, GLContext.CTX_PROFILE_ES, 2, 0, GLContext.CTX_PROFILE_ES|GLContext.CTX_OPTION_ANY);
}
btest = false;
@@ -983,7 +1033,7 @@ public class GLProfile implements Cloneable {
}
hasGLES1Impl = btest;
if(hasGLES1Impl) {
- GLContext.mapVersionAvailable(1, false, 1, 0, GLContext.CTX_PROFILE_ES|GLContext.CTX_PROFILE_CORE|GLContext.CTX_OPTION_ANY);
+ GLContext.mapVersionAvailable(1, GLContext.CTX_PROFILE_ES, 1, 0, GLContext.CTX_PROFILE_ES|GLContext.CTX_OPTION_ANY);
}
mappedProfiles = computeProfileMap();