Commits

Michael Ludwig  committed ea2a79a

Make the version parsing more platform friendly (somehow this got missed awhile ago).

  • Participants
  • Parent commits 0b7c18c

Comments (0)

Files changed (1)

File src/com/ferox/impl/jsr231/JOGLCapabilitiesFetcher.java

 		// do nothing
 	}
 
+	private String formatVersion(String glv) {
+		glv = glv.trim();
+		char[] c = glv.toCharArray();
+		boolean dotFound = false;
+		char h;
+		String v = "";
+		for (int i = 0; i < c.length; i++) {
+			h = c[i];
+			if (!Character.isDigit(h)) {
+				if (dotFound || h != '.') {
+					break;
+				}
+				dotFound = true;
+			}
+			v += h;
+		}
+		
+		return v;
+	}
+	
 	public void init(GLAutoDrawable glAD) {
 		GL gl = glAD.getGL();
 		int[] store = new int[1];
 		
-		String version = gl.glGetString(GL.GL_VERSION);
-		float vNum = Float.parseFloat(version.substring(0, version.indexOf(" ")));
+		String version = this.formatVersion(gl.glGetString(GL.GL_VERSION));
+		float vNum = Float.parseFloat(version);
 		
 		boolean vboSupported = gl.isFunctionAvailable("glGenBuffersARB") && 
 							   gl.isFunctionAvailable("glBindBufferARB") &&