diff options
author | Kenneth Russel <[email protected]> | 2005-05-26 22:35:03 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2005-05-26 22:35:03 +0000 |
commit | 7d270daf56094c68502e1c45283c79b896291dc2 (patch) | |
tree | 9257d476ff33b14e01f4cecbafa268af7591cfb8 /src/net/java/games/jogl/impl | |
parent | 21fae330fcf16b84233fd8b4e4ce6bef91db1208 (diff) |
Fixed Issue 94: isFunctionAvailable throws exception on valid version strings
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@283 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/net/java/games/jogl/impl')
-rw-r--r-- | src/net/java/games/jogl/impl/FunctionAvailabilityCache.java | 58 |
1 files changed, 32 insertions, 26 deletions
diff --git a/src/net/java/games/jogl/impl/FunctionAvailabilityCache.java b/src/net/java/games/jogl/impl/FunctionAvailabilityCache.java index a4b67b5e8..bfcb289dc 100644 --- a/src/net/java/games/jogl/impl/FunctionAvailabilityCache.java +++ b/src/net/java/games/jogl/impl/FunctionAvailabilityCache.java @@ -179,7 +179,7 @@ public final class FunctionAvailabilityCache { catch (IllegalArgumentException e) { // funcCoreVersionString is not an OpenGL version identifier (i.e., not - // of the form GL_VERSION_XXX). + // of the form GL_VERSION_XXX or X.Y). // // Since the association string returned from // StaticGLInfo.getFunctionAssociation() was not null, this function @@ -206,15 +206,19 @@ public final class FunctionAvailabilityCache { // belongs. if (actualVersion.compareTo(versionToCheck) <= 0) { - System.err.println( - glFunctionName + " is in core OpenGL " + glVersionString + - " because it is in OpenGL " + funcCoreVersionString); + if (DEBUG) { + System.err.println( + glFunctionName + " is in core OpenGL " + glVersionString + + " because it is in OpenGL " + funcCoreVersionString); + } return true; } - System.err.println( - glFunctionName + " is NOT a part of the OpenGL " + glVersionString + " core" + - "; it is part of OpenGL " + funcCoreVersionString); + if (DEBUG) { + System.err.println( + glFunctionName + " is NOT a part of the OpenGL " + glVersionString + " core" + + "; it is part of OpenGL " + funcCoreVersionString); + } return false; } @@ -256,33 +260,35 @@ public final class FunctionAvailabilityCache { /** * @param versionString must be of the form "GL_VERSION_X" or - * "GL_VERSION_X_Y" or "GL_VERSION_X_Y_Z", where X, Y, and Z are integers. + * "GL_VERSION_X_Y" or "GL_VERSION_X_Y_Z" or "X.Y", where X, Y, + * and Z are integers. * * @exception IllegalArgumentException if the argument is not a valid * OpenGL version identifier */ public Version(String versionString) { - if (! versionString.startsWith("GL_VERSION_")) + try { - // not a version string - throw new IllegalArgumentException( - "Illegal version identifier \"" + versionString + - "\"; does not start with \"GL_VERSION_\""); - } - - try - { - StringTokenizer tok = new StringTokenizer(versionString, "_"); + if (versionString.startsWith("GL_VERSION_")) + { + StringTokenizer tok = new StringTokenizer(versionString, "_"); - tok.nextToken(); // GL_ - tok.nextToken(); // VERSION_ - if (!tok.hasMoreTokens()) { major = 0; return; } - major = Integer.valueOf(tok.nextToken()).intValue(); - if (!tok.hasMoreTokens()) { minor = 0; return; } - minor = Integer.valueOf(tok.nextToken()).intValue(); - if (!tok.hasMoreTokens()) { sub = 0; return; } - sub = Integer.valueOf(tok.nextToken()).intValue(); + tok.nextToken(); // GL_ + tok.nextToken(); // VERSION_ + if (!tok.hasMoreTokens()) { major = 0; return; } + major = Integer.valueOf(tok.nextToken()).intValue(); + if (!tok.hasMoreTokens()) { minor = 0; return; } + minor = Integer.valueOf(tok.nextToken()).intValue(); + if (!tok.hasMoreTokens()) { sub = 0; return; } + sub = Integer.valueOf(tok.nextToken()).intValue(); + } + else + { + StringTokenizer tok = new StringTokenizer(versionString, ". "); + major = Integer.valueOf(tok.nextToken()).intValue(); + minor = Integer.valueOf(tok.nextToken()).intValue(); + } } catch (Exception e) { |