summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/GLVersionNumber.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-04-16 05:50:55 +0200
committerSven Gothel <[email protected]>2013-04-16 05:50:55 +0200
commitff25c711fe4fa627004c57e0d308d06759156290 (patch)
treebccaf1561a0582b6567c064f45c2dc9f2a22596c /src/jogl/classes/jogamp/opengl/GLVersionNumber.java
parent5b47372590ec715647ebbd75d70c41ec7a64485a (diff)
Fix Bug 705 - Cleanup & Generalize Commit 5b47372590ec715647ebbd75d70c41ec7a64485a ; Close X11 Display in isDeviceSupported()
- Moved GL vendor version parsing to GLVersionNumber - Moved X11Util.markAllDisplaysUnclosable() trigger into SharedResource creation of - X11GLXDrawableFactory - EGLDrawableFactory - GLProfile is back to pre 5b47372590ec715647ebbd75d70c41ec7a64485a, i.e. contains no quirk artifact (clean) - Close X11 Display in X11GLXDrawableFactory.isDeviceSupported() Regression of 9a4fcc7ea4ec61e4ceed791acced734ac04ea270 - TODO: Remove X11Util markAllDisplaysUnclosable detection code ? Notes to Martin: - Use TAB == 4 SPACES - No author names into source code, git commit log is enough. - No need to tag your edits, the diff is enough.
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/GLVersionNumber.java')
-rw-r--r--src/jogl/classes/jogamp/opengl/GLVersionNumber.java77
1 files changed, 53 insertions, 24 deletions
diff --git a/src/jogl/classes/jogamp/opengl/GLVersionNumber.java b/src/jogl/classes/jogamp/opengl/GLVersionNumber.java
index 83815f7a4..1784cd772 100644
--- a/src/jogl/classes/jogamp/opengl/GLVersionNumber.java
+++ b/src/jogl/classes/jogamp/opengl/GLVersionNumber.java
@@ -32,24 +32,23 @@ import java.util.StringTokenizer;
import javax.media.opengl.GLContext;
-import com.jogamp.common.util.VersionNumber;
+import com.jogamp.common.util.VersionNumberString;
/**
* A class for storing and comparing OpenGL version numbers.
* This only works for desktop OpenGL at the moment.
*/
-class GLVersionNumber extends VersionNumber {
+class GLVersionNumber extends VersionNumberString {
- protected boolean valid;
+ private final boolean valid;
- public GLVersionNumber(int majorRev, int minorRev, int subMinorRev) {
- super(majorRev, minorRev, subMinorRev);
- valid = true;
+ private GLVersionNumber(int[] val, String versionString, boolean valid) {
+ super(val[0], val[1], val[2], versionString);
+ this.valid = valid;
}
-
- public GLVersionNumber(String versionString) {
- super();
- valid = false;
+
+ public static GLVersionNumber create(String versionString) {
+ int[] val = new int[] { 0, 0, 0 };
try {
if (versionString.startsWith("GL_VERSION_")) {
StringTokenizer tok = new StringTokenizer(versionString, "_");
@@ -57,19 +56,19 @@ class GLVersionNumber extends VersionNumber {
tok.nextToken(); // VERSION_
if (!tok.hasMoreTokens()) {
val[0] = 0;
- return;
- }
- val[0] = Integer.valueOf(tok.nextToken()).intValue();
- if (!tok.hasMoreTokens()) {
- val[1] = 0;
- return;
- }
- val[1] = Integer.valueOf(tok.nextToken()).intValue();
- if (!tok.hasMoreTokens()) {
- val[2] = 0;
- return;
+ } else {
+ val[0] = Integer.valueOf(tok.nextToken()).intValue();
+ if (!tok.hasMoreTokens()) {
+ val[1] = 0;
+ } else {
+ val[1] = Integer.valueOf(tok.nextToken()).intValue();
+ if (!tok.hasMoreTokens()) {
+ val[2] = 0;
+ } else {
+ val[2] = Integer.valueOf(tok.nextToken()).intValue();
+ }
+ }
}
- val[2] = Integer.valueOf(tok.nextToken()).intValue();
} else {
int radix = 10;
if (versionString.length() > 2) {
@@ -105,7 +104,7 @@ class GLVersionNumber extends VersionNumber {
}
}
}
- valid = true;
+ return new GLVersionNumber(val, versionString, true);
} catch (Exception e) {
e.printStackTrace();
// FIXME: refactor desktop OpenGL dependencies and make this
@@ -118,11 +117,41 @@ class GLVersionNumber extends VersionNumber {
new IllegalArgumentException(
"Illegally formatted version identifier: \"" + versionString + "\"")
.initCause(e);
- */
+ */
}
+ return new GLVersionNumber(val, versionString, false);
}
public final boolean isValid() {
return valid;
}
+
+ /**
+ * Returns the optional vendor version at the end of the
+ * <code>GL_VERSION</code> string if exists, otherwise <code>null</code>.
+ * <pre>
+ * 2.1 Mesa 7.0.3-rc2 -> 7.0.3 (7.0.3-rc2)
+ * 4.2.12171 Compatibility Profile Context 9.01.8 -> 9.1.8 (9.01.8)
+ * 4.3.0 NVIDIA 310.32 -> 310.32 (310.32)
+ * </pre>
+ */
+ public static final VersionNumberString createVendorVersion(String versionString) {
+ if (versionString == null || versionString.length() <= 0) {
+ return null;
+ }
+ final String[] strings = versionString.trim().split("\\s+");
+ if ( strings.length <= 0 ) {
+ return null;
+ }
+ // Test all segments backwards from [len-1..1], skipping the 1st entry (GL version)
+ // If a segment represents a valid VersionNumber - use it.
+ for(int i=strings.length-1; i>=1; i--) {
+ final String s = strings[i];
+ final VersionNumberString version = new VersionNumberString(s, ".");
+ if( !version.isZero() ) {
+ return version;
+ }
+ }
+ return null;
+ }
}