more detailed GL version/extensions check

This commit is contained in:
codeanticode
2012-09-10 20:07:32 +00:00
parent 1eff9352eb
commit 1c57d0829d
4 changed files with 88 additions and 0 deletions
@@ -2111,6 +2111,33 @@ public class PGL {
}
protected int[] getGLVersion() {
String version = GLES20.glGetString(GLES20.GL_VERSION).trim();
int[] res = {0, 0, 0};
String[] parts = version.split(" ");
for (int i = 0; i < parts.length; i++) {
if (0 < parts[i].indexOf(".")) {
String nums[] = parts[i].split("\\.");
try {
res[0] = Integer.parseInt(nums[0]);
} catch (NumberFormatException e) { }
if (1 < nums.length) {
try {
res[1] = Integer.parseInt(nums[1]);
} catch (NumberFormatException e) { }
}
if (2 < nums.length) {
try {
res[2] = Integer.parseInt(nums[2]);
} catch (NumberFormatException e) { }
}
break;
}
}
return res;
}
///////////////////////////////////////////////////////////
// Android specific stuff
@@ -6084,6 +6084,23 @@ public class PGraphicsOpenGL extends PGraphics {
OPENGL_EXTENSIONS = pgl.getString(PGL.EXTENSIONS);
GLSL_VERSION = pgl.getString(PGL.SHADING_LANGUAGE_VERSION);
int major = pgl.getGLVersion()[0];
System.err.println("OpenGL version " + OPENGL_VERSION + " " + major);
if (major < 2) {
// There might be problems...
PGraphics.showWarning("The OpenGL version in this is less than 2.0 so " +
"Processing might not draw things properly");
// ... but GLSL might still be available through extensions.
if (OPENGL_EXTENSIONS.indexOf("_fragment_shader") == -1 ||
OPENGL_EXTENSIONS.indexOf("_vertex_shader") == -1 ||
OPENGL_EXTENSIONS.indexOf("_shader_objects") == -1 ||
OPENGL_EXTENSIONS.indexOf("_shading_language") == -1) {
// GLSL extensions are not present, we cannot do anything else here.
throw new RuntimeException("GLSL shaders are not supported by this " +
"video card");
}
}
npotTexSupported =
-1 < OPENGL_EXTENSIONS.indexOf("_texture_non_power_of_two");
autoMipmapGenSupported =
+27
View File
@@ -2545,6 +2545,33 @@ public class PGL {
}
protected int[] getGLVersion() {
String version = gl.glGetString(GL.GL_VERSION).trim();
int[] res = {0, 0, 0};
String[] parts = version.split(" ");
for (int i = 0; i < parts.length; i++) {
if (0 < parts[i].indexOf(".")) {
String nums[] = parts[i].split("\\.");
try {
res[0] = Integer.parseInt(nums[0]);
} catch (NumberFormatException e) { }
if (1 < nums.length) {
try {
res[1] = Integer.parseInt(nums[1]);
} catch (NumberFormatException e) { }
}
if (2 < nums.length) {
try {
res[2] = Integer.parseInt(nums[2]);
} catch (NumberFormatException e) { }
}
break;
}
}
return res;
}
///////////////////////////////////////////////////////////
// Java specific stuff
@@ -6084,6 +6084,23 @@ public class PGraphicsOpenGL extends PGraphics {
OPENGL_EXTENSIONS = pgl.getString(PGL.EXTENSIONS);
GLSL_VERSION = pgl.getString(PGL.SHADING_LANGUAGE_VERSION);
int major = pgl.getGLVersion()[0];
System.err.println("OpenGL version " + OPENGL_VERSION + " " + major);
if (major < 2) {
// There might be problems...
PGraphics.showWarning("The OpenGL version in this is less than 2.0 so " +
"Processing might not draw things properly");
// ... but GLSL might still be available through extensions.
if (OPENGL_EXTENSIONS.indexOf("_fragment_shader") == -1 ||
OPENGL_EXTENSIONS.indexOf("_vertex_shader") == -1 ||
OPENGL_EXTENSIONS.indexOf("_shader_objects") == -1 ||
OPENGL_EXTENSIONS.indexOf("_shading_language") == -1) {
// GLSL extensions are not present, we cannot do anything else here.
throw new RuntimeException("GLSL shaders are not supported by this " +
"video card");
}
}
npotTexSupported =
-1 < OPENGL_EXTENSIONS.indexOf("_texture_non_power_of_two");
autoMipmapGenSupported =