diff options
author | Sven Gothel <[email protected]> | 2013-10-19 02:49:15 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-10-19 02:49:15 +0200 |
commit | 34b35c5a0a379a6b4c0b23b9d347a0b1338f0239 (patch) | |
tree | 7e5df9aead4e988d8d4ca5333b8d18c692eed65a /src/jogl/classes/javax | |
parent | c6b8ad4a8972f62fb8d0c1dcd7eca1de24393028 (diff) |
Fix Bug 862: Fix GL Version Validation / NVidia GTX550 driver 331.13 - 64bit Linux - No compatibility GLProfile (GL2, >= GL3bc)
Fix GL Version Validation:
We shall not rely on our known good versions when validating a queried GL context version,
but allow some 'room' for a higher version post JOGL release while still
cutting off 'odd versions'.
While GL version detection, we always iterate from the highest known version
down to the lowest. Hence 'GLContext.isValidGLVersion(..)' is satisfied
by validating the lowest version number but allowing a higher than known one.
Now we would return 'invalid' for a version >= 6.
It is enough to clip to the maximum known version when iterating,
allowing the highest unknown version to be available.
GLContext.isValidGLVersion(..):
Returns true, if the major.minor is not inferior to the lowest
valid version and does not exceed the highest known major number by more than one.
The minor version number is ignored by the upper limit validation
and the major version number may exceed by one.
The upper limit check is relaxed since we don't want to cut-off
unforseen new GL version since the release of JOGL.
Hence it is important to iterate through GL version from the upper limit
and 'decrementGLVersion(..)' until invalid.
Add GL Version 4.4 to valid known versions.
Remove ES3 desktop detection, which is impossible
Regression of commit 3a0d7703da32e9a5ddf08a334f18588a78038d88 (ES3 support)
Diffstat (limited to 'src/jogl/classes/javax')
-rw-r--r-- | src/jogl/classes/javax/media/opengl/GLContext.java | 111 |
1 files changed, 80 insertions, 31 deletions
diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index bd6867359..9f2e96781 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -1362,7 +1362,7 @@ public abstract class GLContext { /* 1.*/ { 0, 1, 2, 3, 4, 5 }, /* 2.*/ { 0, 1 }, /* 3.*/ { 0, 1, 2, 3 }, - /* 4.*/ { 0, 1, 2, 3 } }; + /* 4.*/ { 0, 1, 2, 3, 4 } }; public static final int ES_VERSIONS[][] = { /* 0.*/ { -1 }, @@ -1387,51 +1387,100 @@ public abstract class GLContext { } } + /** + * Returns true, if the major.minor is not inferior to the lowest + * valid version and does not exceed the highest known major number by more than one. + * <p> + * The minor version number is ignored by the upper limit validation + * and the major version number may exceed by one. + * </p> + * <p> + * The upper limit check is relaxed since we don't want to cut-off + * unforseen new GL version since the release of JOGL. + * </p> + * <p> + * Hence it is important to iterate through GL version from the upper limit + * and {@link #decrementGLVersion(int, int[], int[])} until invalid. + * </p> + */ public static final boolean isValidGLVersion(int ctxProfile, int major, int minor) { if( 1>major || 0>minor ) { return false; } - if( ( 0 != ( CTX_PROFILE_ES & ctxProfile ) ) ) { - if( major>=ES_VERSIONS.length) return false; - if( minor>=ES_VERSIONS[major].length) return false; + if( 0 != ( CTX_PROFILE_ES & ctxProfile ) ) { + if( major >= ES_VERSIONS.length + 1 ) return false; } else { - if( major>=GL_VERSIONS.length) return false; - if( minor>=GL_VERSIONS[major].length) return false; + if( major>=GL_VERSIONS.length + 1 ) return false; } return true; } - public static final boolean decrementGLVersion(int ctxProfile, int major[], int minor[]) { - if(null==major || major.length<1 ||null==minor || minor.length<1) { - throw new GLException("invalid array arguments"); - } - int m = major[0]; - int n = minor[0]; - if( !isValidGLVersion(ctxProfile, m, n) ) { - return false; + /** + * Clip the given GL version to the maximum known valid version if exceeding. + * @return true if clipped, i.e. given value exceeds maximum, otherwise false. + */ + public static final boolean clipGLVersion(int ctxProfile, int major[], int minor[]) { + final int m = major[0]; + final int n = minor[0]; + + if( 0 != ( CTX_PROFILE_ES & ctxProfile ) ) { + if( m >= ES_VERSIONS.length ) { + major[0] = ES_VERSIONS.length - 1; + minor[0] = ES_VERSIONS[major[0]].length - 1; + return true; + } + if( n >= ES_VERSIONS[m].length ) { + minor[0] = ES_VERSIONS[m].length - 1; + return true; + } + } else if( m >= GL_VERSIONS.length ) { // !isES + major[0] = GL_VERSIONS.length - 1; + minor[0] = GL_VERSIONS[major[0]].length - 1; + return true; + } else if( n >= GL_VERSIONS[m].length ) { // !isES + minor[0] = GL_VERSIONS[m].length - 1; + return true; } + return false; + } - // decrement .. - n -= 1; - if(n < 0) { - if( ( 0 != ( CTX_PROFILE_ES & ctxProfile ) ) ) { - if( m >= 3) { - m -= 1; + /** + * Decrement the given GL version by one + * and return true if still valid, otherwise false. + * <p> + * If the given version exceeds the maximum known valid version, + * it is {@link #clipGLVersion(int, int[], int[]) clipped} and + * true is returned. + * </p> + * + * @param ctxProfile + * @param major + * @param minor + * @return + */ + public static final boolean decrementGLVersion(int ctxProfile, int major[], int minor[]) { + if( !clipGLVersion(ctxProfile, major, minor) ) { + int m = major[0]; + int n = minor[0] - 1; + if(n < 0) { + if( 0 != ( CTX_PROFILE_ES & ctxProfile ) ) { + if( m >= 3 ) { + m -= 1; + } else { + m = 0; // major decr [1,2] -> 0 + } + n = ES_VERSIONS[m].length-1; } else { - m = 0; // major decr [1,2] -> 0 + m -= 1; + n = GL_VERSIONS[m].length-1; } - n = ES_VERSIONS[m].length-1; - } else { - m -= 1; - n = GL_VERSIONS[m].length-1; } + if( !isValidGLVersion(ctxProfile, m, n) ) { + return false; + } + major[0]=m; + minor[0]=n; } - if( !isValidGLVersion(ctxProfile, m, n) ) { - return false; - } - major[0]=m; - minor[0]=n; - return true; } |