aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/jogl/classes/jogamp/opengl/GLVersionNumber.java16
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLVersionParsing00NEWT.java29
2 files changed, 35 insertions, 10 deletions
diff --git a/src/jogl/classes/jogamp/opengl/GLVersionNumber.java b/src/jogl/classes/jogamp/opengl/GLVersionNumber.java
index a32fdfa77..0ce34a60d 100644
--- a/src/jogl/classes/jogamp/opengl/GLVersionNumber.java
+++ b/src/jogl/classes/jogamp/opengl/GLVersionNumber.java
@@ -60,6 +60,7 @@ public class GLVersionNumber extends VersionNumberString {
int[] val = new int[] { 0, 0, 0 };
int strEnd = 0;
short state = 0;
+ boolean valid = false;
if (versionString != null && versionString.length() > 0) {
try {
final java.util.regex.Pattern versionPattern;
@@ -69,13 +70,12 @@ public class GLVersionNumber extends VersionNumberString {
versionPattern = VersionNumberString.getDefaultVersionNumberPattern();
}
final VersionNumberString version = new VersionNumberString(versionString, versionPattern);
- if( version.hasMajor() && version.hasMinor() ) { // Requires at least a defined major and minor version component!
- val[0] = version.getMajor();
- val[1] = version.getMinor();
- strEnd = version.endOfStringMatch();
- state = (short) ( ( version.hasMajor() ? VersionNumber.HAS_MAJOR : (short)0 ) |
- ( version.hasMinor() ? VersionNumber.HAS_MINOR : (short)0 ) );
- }
+ strEnd = version.endOfStringMatch();
+ val[0] = version.getMajor();
+ val[1] = version.getMinor();
+ state = (short) ( ( version.hasMajor() ? VersionNumber.HAS_MAJOR : (short)0 ) |
+ ( version.hasMinor() ? VersionNumber.HAS_MINOR : (short)0 ) );
+ valid = version.hasMajor() && version.hasMinor(); // Requires at least a defined major and minor version component!
} catch (Exception e) {
e.printStackTrace();
System.err.println("Info: ExtensionAvailabilityCache: FunctionAvailabilityCache.Version.<init>: " + e);
@@ -83,7 +83,7 @@ public class GLVersionNumber extends VersionNumberString {
val[1] = 0;
}
}
- return new GLVersionNumber(val, strEnd, state, versionString, false);
+ return new GLVersionNumber(val, strEnd, state, versionString, valid);
}
public final boolean isValid() {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLVersionParsing00NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLVersionParsing00NEWT.java
index 394772135..f2f6e4aff 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLVersionParsing00NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLVersionParsing00NEWT.java
@@ -134,13 +134,38 @@ public class TestGLVersionParsing00NEWT extends UITestCase {
public void test01GLVersion() throws InterruptedException {
for(int i=0; i<glVersionNumbers.length; i++) {
final VersionNumberString exp = glVersionNumbers[i];
- final VersionNumberString has = GLVersionNumber.create(exp.getVersionString());
- System.err.println("Test["+i+"]: "+exp+" -> "+has+", define ["+has.hasMajor()+":"+has.hasMinor()+":"+has.hasSub()+"]");
+ final GLVersionNumber has = GLVersionNumber.create(exp.getVersionString());
+ System.err.println("Test["+i+"]: "+exp+" -> "+has+", valid "+has.isValid()+", define ["+has.hasMajor()+":"+has.hasMinor()+":"+has.hasSub()+"]");
Assert.assertTrue(has.hasMajor());
Assert.assertTrue(has.hasMinor());
Assert.assertTrue(!has.hasSub());
+ Assert.assertTrue(has.isValid());
Assert.assertEquals(exp, has);
}
+ {
+ final GLVersionNumber has = GLVersionNumber.create("GL_VERSION_2");
+ System.err.println("Test-X1: "+has+", valid "+has.isValid()+", define ["+has.hasMajor()+":"+has.hasMinor()+":"+has.hasSub()+"]");
+ Assert.assertTrue(has.hasMajor());
+ Assert.assertTrue(!has.hasMinor());
+ Assert.assertTrue(!has.hasSub());
+ Assert.assertTrue(!has.isValid());
+ }
+ {
+ final GLVersionNumber has = GLVersionNumber.create("GL2 Buggy L3");
+ System.err.println("Test-X2: "+has+", valid "+has.isValid()+", define ["+has.hasMajor()+":"+has.hasMinor()+":"+has.hasSub()+"]");
+ Assert.assertTrue(has.hasMajor());
+ Assert.assertTrue(!has.hasMinor());
+ Assert.assertTrue(!has.hasSub());
+ Assert.assertTrue(!has.isValid());
+ }
+ {
+ final GLVersionNumber has = GLVersionNumber.create("GL Nope");
+ System.err.println("Test-X3: "+has+", valid "+has.isValid()+", define ["+has.hasMajor()+":"+has.hasMinor()+":"+has.hasSub()+"]");
+ Assert.assertTrue(!has.hasMajor());
+ Assert.assertTrue(!has.hasMinor());
+ Assert.assertTrue(!has.hasSub());
+ Assert.assertTrue(!has.isValid());
+ }
}
private void testGLVendorVersionImpl(VersionNumberString[] versionNumberString, boolean withMajor, boolean withMinor, boolean withSub) throws InterruptedException {