From 7d270daf56094c68502e1c45283c79b896291dc2 Mon Sep 17 00:00:00 2001 From: Kenneth Russel Date: Thu, 26 May 2005 22:35:03 +0000 Subject: 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 --- .../games/jogl/impl/FunctionAvailabilityCache.java | 58 ++++++++++++---------- 1 file changed, 32 insertions(+), 26 deletions(-) (limited to 'src') 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) { -- cgit v1.2.3