* Running jME3-android in emulator with GPU emulation now supported but sometimes there are opengl errors (?)

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9428 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
Sha..rd 13 years ago
parent f9dbfc1f7c
commit 1009cd18b0
  1. 46
      engine/src/android/com/jme3/renderer/android/OGLESShaderRenderer.java

@ -132,39 +132,44 @@ public class OGLESShaderRenderer implements Renderer {
return caps; return caps;
} }
private 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();
}
float version = Float.parseFloat(versionStr);
return (int) (version * 100);
} else {
return -1;
}
}
public void initialize() { public void initialize() {
logger.log(Level.INFO, "Vendor: {0}", GLES20.glGetString(GLES20.GL_VENDOR)); logger.log(Level.INFO, "Vendor: {0}", GLES20.glGetString(GLES20.GL_VENDOR));
logger.log(Level.INFO, "Renderer: {0}", GLES20.glGetString(GLES20.GL_RENDERER)); logger.log(Level.INFO, "Renderer: {0}", GLES20.glGetString(GLES20.GL_RENDERER));
logger.log(Level.INFO, "Version: {0}", GLES20.glGetString(GLES20.GL_VERSION)); logger.log(Level.INFO, "Version: {0}", GLES20.glGetString(GLES20.GL_VERSION));
logger.log(Level.INFO, "Shading Language Version: {0}", GLES20.glGetString(GLES20.GL_SHADING_LANGUAGE_VERSION));
powerVr = GLES20.glGetString(GLES20.GL_RENDERER).contains("PowerVR"); powerVr = GLES20.glGetString(GLES20.GL_RENDERER).contains("PowerVR");
String versionStr = GLES20.glGetString(GLES20.GL_SHADING_LANGUAGE_VERSION);
logger.log(Level.INFO, "GLES20.Shading Language Version: {0}", versionStr);
if (versionStr == null || versionStr.equals("")) {
glslVer = -1;
throw new UnsupportedOperationException("GLSL and OpenGL2 is "
+ "required for the OpenGL ES "
+ "renderer!");
}
// Fix issue in TestRenderToMemory when GL_FRONT is the main // Fix issue in TestRenderToMemory when GL_FRONT is the main
// buffer being used. // buffer being used.
// initialDrawBuf = GLES20.glGetIntegeri(GLES20.GL_DRAW_BUFFER); // initialDrawBuf = GLES20.glGetIntegeri(GLES20.GL_DRAW_BUFFER);
// initialReadBuf = GLES20.glGetIntegeri(GLES20.GL_READ_BUFFER); // initialReadBuf = GLES20.glGetIntegeri(GLES20.GL_READ_BUFFER);
String openGlEsStr = "OpenGL ES GLSL ES "; // Check OpenGL version
int spaceIdx = versionStr.indexOf(" ", openGlEsStr.length()); int openGlVer = extractVersion("OpenGL ES ", GLES20.glGetString(GLES20.GL_VERSION));
if (spaceIdx >= 1) { if (openGlVer == -1) {
versionStr = versionStr.substring(openGlEsStr.length(), spaceIdx).trim(); glslVer = -1;
}else{ throw new UnsupportedOperationException("OpenGL ES 2.0+ is required for OGLESShaderRenderer!");
versionStr = versionStr.substring(openGlEsStr.length()).trim();
} }
float version = Float.parseFloat(versionStr); // Check shader language version
glslVer = (int) (version * 100); glslVer = extractVersion("OpenGL ES GLSL ES ", GLES20.glGetString(GLES20.GL_SHADING_LANGUAGE_VERSION));
switch (glslVer) { switch (glslVer) {
// TODO: When new versions of OpenGL ES shader language come out, // TODO: When new versions of OpenGL ES shader language come out,
// update this. // update this.
@ -173,11 +178,6 @@ public class OGLESShaderRenderer implements Renderer {
break; break;
} }
if (!caps.contains(Caps.GLSL100)) {
logger.warning("Force-adding GLSL100 support, since OpenGL2 is supported.");
caps.add(Caps.GLSL100);
}
GLES20.glGetIntegerv(GLES20.GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, intBuf16); GLES20.glGetIntegerv(GLES20.GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, intBuf16);
vertexTextureUnits = intBuf16.get(0); vertexTextureUnits = intBuf16.get(0);
logger.log(Level.INFO, "VTF Units: {0}", vertexTextureUnits); logger.log(Level.INFO, "VTF Units: {0}", vertexTextureUnits);

Loading…
Cancel
Save