Temporary fix for searching for version strings until URA is done.

experimental
iwgeric 10 years ago
parent fb04910980
commit 6f4b90feed
  1. 69
      jme3-android/src/main/java/com/jme3/renderer/android/OGLESShaderRenderer.java

@ -77,6 +77,8 @@ import java.util.EnumSet;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import jme3tools.shader.ShaderDebug;
public class OGLESShaderRenderer implements Renderer {
@ -142,45 +144,16 @@ public class OGLESShaderRenderer implements Renderer {
return caps;
}
private static int extractVersion(String prefixStr, String versionStr) {
if (versionStr != null) {
int spaceIdx = versionStr.indexOf(" ", prefixStr.length());
if (spaceIdx >= 1) {
versionStr = versionStr.substring(prefixStr.length(), spaceIdx).trim();
} else {
versionStr = versionStr.substring(prefixStr.length()).trim();
}
// Find a character which is not a period or digit.
for (int i = 0; i < versionStr.length(); i++) {
char c = versionStr.charAt(i);
if (c != '.' && (c < '0' || c > '9')) {
versionStr = versionStr.substring(0, i);
break;
}
}
// Pivot on first point.
int firstPoint = versionStr.indexOf(".");
// Remove everything after second point.
int secondPoint = versionStr.indexOf(".", firstPoint + 1);
if (secondPoint != -1) {
versionStr = versionStr.substring(0, secondPoint);
}
String majorVerStr = versionStr.substring(0, firstPoint);
String minorVerStr = versionStr.substring(firstPoint + 1);
if (minorVerStr.endsWith("0") && minorVerStr.length() > 1) {
minorVerStr = minorVerStr.substring(0, minorVerStr.length() - 1);
}
int majorVer = Integer.parseInt(majorVerStr);
int minorVer = Integer.parseInt(minorVerStr);
return majorVer * 100 + minorVer * 10;
private static final Pattern VERSION = Pattern.compile(".*?(\\d+)\\.(\\d+).*");
public static int extractVersion(String version) {
Matcher m = VERSION.matcher(version);
if (m.matches()) {
int major = Integer.parseInt(m.group(1));
int minor = Integer.parseInt(m.group(2));
return major * 100 + minor * 10;
} else {
return -1;
}
@ -194,11 +167,11 @@ public class OGLESShaderRenderer implements Renderer {
powerVr = GLES20.glGetString(GLES20.GL_RENDERER).contains("PowerVR");
//workaround, always assume we support GLSL100
//some cards just don't report this correctly
caps.add(Caps.GLSL100);
/*
// Fix issue in TestRenderToMemory when GL_FRONT is the main
// buffer being used.
@ -213,14 +186,14 @@ public class OGLESShaderRenderer implements Renderer {
*/
// Check OpenGL version
int openGlVer = extractVersion("OpenGL ES ", GLES20.glGetString(GLES20.GL_VERSION));
int openGlVer = extractVersion(GLES20.glGetString(GLES20.GL_VERSION));
if (openGlVer == -1) {
glslVer = -1;
throw new UnsupportedOperationException("OpenGL ES 2.0+ is required for OGLESShaderRenderer!");
}
// Check shader language version
glslVer = extractVersion("OpenGL ES GLSL ", GLES20.glGetString(GLES20.GL_SHADING_LANGUAGE_VERSION));
glslVer = extractVersion(GLES20.glGetString(GLES20.GL_SHADING_LANGUAGE_VERSION));
switch (glslVer) {
// TODO: When new versions of OpenGL ES shader language come out,
// update this.
@ -477,7 +450,7 @@ public class OGLESShaderRenderer implements Renderer {
*/
if (state.isDepthTest() && !context.depthTestEnabled) {
GLES20.glEnable(GLES20.GL_DEPTH_TEST);
GLES20.glDepthFunc(convertTestFunction(context.depthFunc));
GLES20.glDepthFunc(convertTestFunction(context.depthFunc));
RendererUtil.checkGLError();
context.depthTestEnabled = true;
} else if (!state.isDepthTest() && context.depthTestEnabled) {
@ -612,7 +585,7 @@ public class OGLESShaderRenderer implements Renderer {
break;
case Screen:
GLES20.glBlendFunc(GLES20.GL_ONE, GLES20.GL_ONE_MINUS_SRC_COLOR);
break;
break;
case Exclusion:
GLES20.glBlendFunc(GLES20.GL_ONE_MINUS_DST_COLOR, GLES20.GL_ONE_MINUS_SRC_COLOR);
break;
@ -1095,7 +1068,7 @@ public class OGLESShaderRenderer implements Renderer {
throw new UnsupportedOperationException("Unrecognized test function: " + testFunc);
}
}
/*********************************************************************\
|* Framebuffers *|
\*********************************************************************/
@ -2585,10 +2558,10 @@ public class OGLESShaderRenderer implements Renderer {
}
public void setMainFrameBufferSrgb(boolean srgb) {
//TODO once opglES3.0 is supported maybe....
//TODO once opglES3.0 is supported maybe....
}
public void setLinearizeSrgbImages(boolean linearize) {
//TODO once opglES3.0 is supported maybe....
//TODO once opglES3.0 is supported maybe....
}
}

Loading…
Cancel
Save