Android: added ConfigType.LEGACY
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7858 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
349c9d9e4a
commit
0a58b3c92b
@ -36,9 +36,15 @@ public class AndroidConfigChooser implements EGLConfigChooser
|
|||||||
*/
|
*/
|
||||||
FASTEST,
|
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)
|
public AndroidConfigChooser(ConfigType type, boolean verbose)
|
||||||
|
@ -131,51 +131,69 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <code>createView</code>
|
* <code>createView</code> initializes the GLSurfaceView
|
||||||
* @param view The Android input which will be used as the GLSurfaceView for this context
|
* @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
|
* @return GLSurfaceView The newly created view
|
||||||
*/
|
*/
|
||||||
public GLSurfaceView createView(AndroidInput view, ConfigType configType, boolean eglConfigVerboseLogging)
|
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
|
// Start to set up the view
|
||||||
this.view = view;
|
this.view = view;
|
||||||
|
|
||||||
// Create a config chooser
|
if (configType == ConfigType.LEGACY)
|
||||||
AndroidConfigChooser configChooser = new AndroidConfigChooser(configType, eglConfigVerboseLogging);
|
|
||||||
// Init chooser
|
|
||||||
if (!configChooser.findConfig(egl, display))
|
|
||||||
{
|
{
|
||||||
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");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
clientOpenGLESVersion = configChooser.getClientOpenGLESVersion();
|
|
||||||
if (clientOpenGLESVersion < 2)
|
|
||||||
{
|
{
|
||||||
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.setFocusableInTouchMode(true);
|
||||||
view.setFocusable(true);
|
view.setFocusable(true);
|
||||||
view.setZOrderOnTop(true);
|
view.getHolder().setType(SurfaceHolder.SURFACE_TYPE_GPU);
|
||||||
view.getHolder().setType(SurfaceHolder.SURFACE_TYPE_GPU);
|
|
||||||
view.getHolder().setFormat(configChooser.getPixelFormat());
|
|
||||||
view.setRenderer(this);
|
view.setRenderer(this);
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user