From 0a58b3c92b76c9cd696f20f96579b6c19b2df578 Mon Sep 17 00:00:00 2001 From: "kim..ng" Date: Wed, 13 Jul 2011 10:32:00 +0000 Subject: [PATCH] Android: added ConfigType.LEGACY git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7858 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../system/android/AndroidConfigChooser.java | 10 ++- .../com/jme3/system/android/OGLESContext.java | 78 ++++++++++++------- 2 files changed, 56 insertions(+), 32 deletions(-) diff --git a/engine/src/android/com/jme3/system/android/AndroidConfigChooser.java b/engine/src/android/com/jme3/system/android/AndroidConfigChooser.java index e4249a1ad..57f6faba6 100644 --- a/engine/src/android/com/jme3/system/android/AndroidConfigChooser.java +++ b/engine/src/android/com/jme3/system/android/AndroidConfigChooser.java @@ -36,9 +36,15 @@ public class AndroidConfigChooser implements EGLConfigChooser */ FASTEST, /** - * RGB???, 0 alpha, 16 depth, 0 stencil + * RGB???, 0 alpha, >=16 depth, 0 stencil */ - BEST + BEST, + /** + * Turn off config chooser and use hardcoded + * setEGLContextClientVersion(2); + * setEGLConfigChooser(5, 6, 5, 0, 16, 0); + */ + LEGACY } public AndroidConfigChooser(ConfigType type, boolean verbose) diff --git a/engine/src/android/com/jme3/system/android/OGLESContext.java b/engine/src/android/com/jme3/system/android/OGLESContext.java index aee6b3d37..89839fbd2 100644 --- a/engine/src/android/com/jme3/system/android/OGLESContext.java +++ b/engine/src/android/com/jme3/system/android/OGLESContext.java @@ -131,51 +131,69 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer } /** - * createView + * createView initializes the GLSurfaceView * @param view The Android input which will be used as the GLSurfaceView for this context - * @param debugflags 0, GLSurfaceView.DEBUG_CHECK_GL_ERROR | GLSurfaceView.DEBUG_LOG_GL_CALLS + * @param configType ConfigType.FASTEST (Default) | ConfigType.LEGACY | ConfigType.BEST + * @param eglConfigVerboseLogging if true show all found configs * @return GLSurfaceView The newly created view */ public GLSurfaceView createView(AndroidInput view, ConfigType configType, boolean eglConfigVerboseLogging) { - EGL10 egl = (EGL10) EGLContext.getEGL(); - EGLDisplay display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); - - int[] version = new int[2]; - if (egl.eglInitialize(display, version) == true) - { - logger.info("Display EGL Version: " + version[0] + "." + version[1]); - } - // Start to set up the view this.view = view; - // Create a config chooser - AndroidConfigChooser configChooser = new AndroidConfigChooser(configType, eglConfigVerboseLogging); - // Init chooser - if (!configChooser.findConfig(egl, display)) + if (configType == ConfigType.LEGACY) { - logger.severe("Unable to find suitable EGL config"); + // Hardcoded egl setup + clientOpenGLESVersion = 2; + view.setEGLContextClientVersion(2); + //RGB565, Depth16 + view.setEGLConfigChooser(5, 6, 5, 0, 16, 0); + logger.info("ConfigType.LEGACY using RGB565"); } - - clientOpenGLESVersion = configChooser.getClientOpenGLESVersion(); - if (clientOpenGLESVersion < 2) + else { - logger.severe("OpenGL ES 2.0 is not supported on this device"); - } + EGL10 egl = (EGL10) EGLContext.getEGL(); + EGLDisplay display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); + + int[] version = new int[2]; + if (egl.eglInitialize(display, version) == true) + { + logger.info("Display EGL Version: " + version[0] + "." + version[1]); + } + + // Create a config chooser + AndroidConfigChooser configChooser = new AndroidConfigChooser(configType, eglConfigVerboseLogging); + // Init chooser + if (!configChooser.findConfig(egl, display)) + { + logger.severe("Unable to find suitable EGL config"); + } + + clientOpenGLESVersion = configChooser.getClientOpenGLESVersion(); + if (clientOpenGLESVersion < 2) + { + logger.severe("OpenGL ES 2.0 is not supported on this device"); + } + + if (display != null) + egl.eglTerminate(display); + + + /* + * Requesting client version from GLSurfaceView which is extended by + * AndroidInput. + */ + view.setEGLContextClientVersion(clientOpenGLESVersion); + view.setEGLConfigChooser(configChooser); + view.getHolder().setFormat(configChooser.getPixelFormat()); + } - /* - * Requesting client version from GLSurfaceView which is extended by - * AndroidInput. - */ - view.setEGLContextClientVersion(clientOpenGLESVersion); - view.setEGLConfigChooser(configChooser); view.setFocusableInTouchMode(true); view.setFocusable(true); - view.setZOrderOnTop(true); - view.getHolder().setType(SurfaceHolder.SURFACE_TYPE_GPU); - view.getHolder().setFormat(configChooser.getPixelFormat()); + view.getHolder().setType(SurfaceHolder.SURFACE_TYPE_GPU); view.setRenderer(this); + return view; }