Android : changed the way the pixel config is passed to the OGLESContext. It's now passed in the appSettings.
This is a first step toward a generalization of the use of appSettings in the AndroidHarness. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10458 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
1871a1831d
commit
9a28fed581
@ -25,6 +25,7 @@ import com.jme3.input.event.TouchEvent;
|
|||||||
import com.jme3.renderer.android.AndroidGLSurfaceView;
|
import com.jme3.renderer.android.AndroidGLSurfaceView;
|
||||||
import com.jme3.system.AppSettings;
|
import com.jme3.system.AppSettings;
|
||||||
import com.jme3.system.SystemListener;
|
import com.jme3.system.SystemListener;
|
||||||
|
import com.jme3.system.android.AndroidConfigChooser;
|
||||||
import com.jme3.system.android.AndroidConfigChooser.ConfigType;
|
import com.jme3.system.android.AndroidConfigChooser.ConfigType;
|
||||||
import com.jme3.system.android.JmeAndroidSystem;
|
import com.jme3.system.android.JmeAndroidSystem;
|
||||||
import com.jme3.system.android.OGLESContext;
|
import com.jme3.system.android.OGLESContext;
|
||||||
@ -43,12 +44,10 @@ import java.util.logging.Logger;
|
|||||||
public class AndroidHarness extends Activity implements TouchListener, DialogInterface.OnClickListener, SystemListener {
|
public class AndroidHarness extends Activity implements TouchListener, DialogInterface.OnClickListener, SystemListener {
|
||||||
|
|
||||||
protected final static Logger logger = Logger.getLogger(AndroidHarness.class.getName());
|
protected final static Logger logger = Logger.getLogger(AndroidHarness.class.getName());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The application class to start
|
* The application class to start
|
||||||
*/
|
*/
|
||||||
protected String appClass = "jme3test.android.Test";
|
protected String appClass = "jme3test.android.Test";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The jme3 application object
|
* The jme3 application object
|
||||||
*/
|
*/
|
||||||
@ -59,55 +58,52 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
|
|||||||
* RGBA8888 or better if supported by the hardware
|
* RGBA8888 or better if supported by the hardware
|
||||||
*/
|
*/
|
||||||
protected ConfigType eglConfigType = ConfigType.FASTEST;
|
protected ConfigType eglConfigType = ConfigType.FASTEST;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If true all valid and not valid egl configs are logged
|
* If true all valid and not valid egl configs are logged
|
||||||
|
* @deprecated this has no use
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
protected boolean eglConfigVerboseLogging = false;
|
protected boolean eglConfigVerboseLogging = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If true Android Sensors are used as simulated Joysticks
|
* set to 2, 4 to enable multisampling.
|
||||||
* Users can use the Android sensor feedback through the RawInputListener
|
*/
|
||||||
* or by registering JoyAxisTriggers.
|
// protected int antiAliasingSamples = 0;
|
||||||
|
/**
|
||||||
|
* If true Android Sensors are used as simulated Joysticks Users can use the
|
||||||
|
* Android sensor feedback through the RawInputListener or by registering
|
||||||
|
* JoyAxisTriggers.
|
||||||
*/
|
*/
|
||||||
protected boolean joystickEventsEnabled = false;
|
protected boolean joystickEventsEnabled = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If true MouseEvents are generated from TouchEvents
|
* If true MouseEvents are generated from TouchEvents
|
||||||
*/
|
*/
|
||||||
protected boolean mouseEventsEnabled = true;
|
protected boolean mouseEventsEnabled = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flip X axis
|
* Flip X axis
|
||||||
*/
|
*/
|
||||||
protected boolean mouseEventsInvertX = false;
|
protected boolean mouseEventsInvertX = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flip Y axis
|
* Flip Y axis
|
||||||
*/
|
*/
|
||||||
protected boolean mouseEventsInvertY = false;
|
protected boolean mouseEventsInvertY = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* if true finish this activity when the jme app is stopped
|
* if true finish this activity when the jme app is stopped
|
||||||
*/
|
*/
|
||||||
protected boolean finishOnAppStop = true;
|
protected boolean finishOnAppStop = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set to false if you don't want the harness to handle the exit hook
|
* set to false if you don't want the harness to handle the exit hook
|
||||||
*/
|
*/
|
||||||
protected boolean handleExitHook = true;
|
protected boolean handleExitHook = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Title of the exit dialog, default is "Do you want to exit?"
|
* Title of the exit dialog, default is "Do you want to exit?"
|
||||||
*/
|
*/
|
||||||
protected String exitDialogTitle = "Do you want to exit?";
|
protected String exitDialogTitle = "Do you want to exit?";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Message of the exit dialog, default is "Use your home key to bring this
|
* Message of the exit dialog, default is "Use your home key to bring this
|
||||||
* app into the background or exit to terminate it."
|
* app into the background or exit to terminate it."
|
||||||
*/
|
*/
|
||||||
protected String exitDialogMessage = "Use your home key to bring this app into the background or exit to terminate it.";
|
protected String exitDialogMessage = "Use your home key to bring this app into the background or exit to terminate it.";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the screen window mode. If screenFullSize is true, then the
|
* Set the screen window mode. If screenFullSize is true, then the
|
||||||
* notification bar and title bar are removed and the screen covers the
|
* notification bar and title bar are removed and the screen covers the
|
||||||
@ -116,20 +112,17 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
|
|||||||
* false, then the title bar is also displayed under the notification bar.
|
* false, then the title bar is also displayed under the notification bar.
|
||||||
*/
|
*/
|
||||||
protected boolean screenFullScreen = true;
|
protected boolean screenFullScreen = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* if screenShowTitle is true while screenFullScreen is false, then the
|
* if screenShowTitle is true while screenFullScreen is false, then the
|
||||||
* title bar is also displayed under the notification bar
|
* title bar is also displayed under the notification bar
|
||||||
*/
|
*/
|
||||||
protected boolean screenShowTitle = true;
|
protected boolean screenShowTitle = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Splash Screen picture Resource ID. If a Splash Screen is desired, set
|
* Splash Screen picture Resource ID. If a Splash Screen is desired, set
|
||||||
* splashPicID to the value of the Resource ID (i.e. R.drawable.picname). If
|
* splashPicID to the value of the Resource ID (i.e. R.drawable.picname). If
|
||||||
* splashPicID = 0, then no splash screen will be displayed.
|
* splashPicID = 0, then no splash screen will be displayed.
|
||||||
*/
|
*/
|
||||||
protected int splashPicID = 0;
|
protected int splashPicID = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the screen orientation, default is SENSOR
|
* Set the screen orientation, default is SENSOR
|
||||||
* ActivityInfo.SCREEN_ORIENTATION_* constants package
|
* ActivityInfo.SCREEN_ORIENTATION_* constants package
|
||||||
@ -200,7 +193,10 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
|
|||||||
settings.setEmulateMouse(mouseEventsEnabled);
|
settings.setEmulateMouse(mouseEventsEnabled);
|
||||||
settings.setEmulateMouseFlipAxis(mouseEventsInvertX, mouseEventsInvertY);
|
settings.setEmulateMouseFlipAxis(mouseEventsInvertX, mouseEventsInvertY);
|
||||||
settings.setUseJoysticks(joystickEventsEnabled);
|
settings.setUseJoysticks(joystickEventsEnabled);
|
||||||
|
// settings.setSamples(antiAliasingSamples);
|
||||||
settings.setResolution(disp.getWidth(), disp.getHeight());
|
settings.setResolution(disp.getWidth(), disp.getHeight());
|
||||||
|
settings.put(AndroidConfigChooser.SETTINGS_CONFIG_TYPE, eglConfigType);
|
||||||
|
|
||||||
|
|
||||||
// Create application instance
|
// Create application instance
|
||||||
try {
|
try {
|
||||||
@ -221,7 +217,7 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctx = (OGLESContext) app.getContext();
|
ctx = (OGLESContext) app.getContext();
|
||||||
view = ctx.createView(eglConfigType, eglConfigVerboseLogging);
|
view = ctx.createView();
|
||||||
// AndroidHarness wraps the app as a SystemListener.
|
// AndroidHarness wraps the app as a SystemListener.
|
||||||
ctx.setSystemListener(this);
|
ctx.setSystemListener(this);
|
||||||
layoutDisplay();
|
layoutDisplay();
|
||||||
@ -401,7 +397,6 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
|
|||||||
switch (evt.getType()) {
|
switch (evt.getType()) {
|
||||||
case KEY_UP:
|
case KEY_UP:
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
AlertDialog dialog = new AlertDialog.Builder(AndroidHarness.this) // .setIcon(R.drawable.alert_dialog_icon)
|
AlertDialog dialog = new AlertDialog.Builder(AndroidHarness.this) // .setIcon(R.drawable.alert_dialog_icon)
|
||||||
@ -438,12 +433,12 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (view.getParent() != null) {
|
if (view.getParent() != null) {
|
||||||
((ViewGroup)view.getParent()).removeView(view);
|
((ViewGroup) view.getParent()).removeView(view);
|
||||||
}
|
}
|
||||||
frameLayout.addView(view);
|
frameLayout.addView(view);
|
||||||
|
|
||||||
if (splashImageView.getParent() != null) {
|
if (splashImageView.getParent() != null) {
|
||||||
((ViewGroup)splashImageView.getParent()).removeView(splashImageView);
|
((ViewGroup) splashImageView.getParent()).removeView(splashImageView);
|
||||||
}
|
}
|
||||||
frameLayout.addView(splashImageView, lp);
|
frameLayout.addView(splashImageView, lp);
|
||||||
|
|
||||||
@ -461,7 +456,6 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
|
|||||||
if (frameLayout != null) {
|
if (frameLayout != null) {
|
||||||
if (splashImageView != null) {
|
if (splashImageView != null) {
|
||||||
this.runOnUiThread(new Runnable() {
|
this.runOnUiThread(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
splashImageView.setVisibility(View.INVISIBLE);
|
splashImageView.setVisibility(View.INVISIBLE);
|
||||||
|
@ -2,6 +2,8 @@ package com.jme3.system.android;
|
|||||||
|
|
||||||
import android.graphics.PixelFormat;
|
import android.graphics.PixelFormat;
|
||||||
import android.opengl.GLSurfaceView.EGLConfigChooser;
|
import android.opengl.GLSurfaceView.EGLConfigChooser;
|
||||||
|
import com.jme3.system.AppSettings;
|
||||||
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import javax.microedition.khronos.egl.EGL10;
|
import javax.microedition.khronos.egl.EGL10;
|
||||||
import javax.microedition.khronos.egl.EGLConfig;
|
import javax.microedition.khronos.egl.EGLConfig;
|
||||||
@ -15,11 +17,12 @@ import javax.microedition.khronos.egl.EGLDisplay;
|
|||||||
public class AndroidConfigChooser implements EGLConfigChooser {
|
public class AndroidConfigChooser implements EGLConfigChooser {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(AndroidConfigChooser.class.getName());
|
private static final Logger logger = Logger.getLogger(AndroidConfigChooser.class.getName());
|
||||||
|
public final static String SETTINGS_CONFIG_TYPE = "configType";
|
||||||
protected int clientOpenGLESVersion = 0;
|
protected int clientOpenGLESVersion = 0;
|
||||||
protected EGLConfig bestConfig = null;
|
protected EGLConfig bestConfig = null;
|
||||||
protected EGLConfig fastestConfig = null;
|
protected EGLConfig fastestConfig = null;
|
||||||
protected EGLConfig choosenConfig = null;
|
protected EGLConfig choosenConfig = null;
|
||||||
protected ConfigType type;
|
protected AppSettings settings;
|
||||||
protected int pixelFormat;
|
protected int pixelFormat;
|
||||||
protected boolean verbose = false;
|
protected boolean verbose = false;
|
||||||
private final static int EGL_OPENGL_ES2_BIT = 4;
|
private final static int EGL_OPENGL_ES2_BIT = 4;
|
||||||
@ -29,24 +32,59 @@ public class AndroidConfigChooser implements EGLConfigChooser {
|
|||||||
/**
|
/**
|
||||||
* RGB565, 0 alpha, 16 depth, 0 stencil
|
* RGB565, 0 alpha, 16 depth, 0 stencil
|
||||||
*/
|
*/
|
||||||
FASTEST,
|
FASTEST(5, 6, 5, 0, 16, 0, 5, 6, 5, 0, 16, 0),
|
||||||
/**
|
/**
|
||||||
* RGB???, 0 alpha, >=16 depth, 0 stencil
|
* RGB???, 0 alpha, >=16 depth, 0 stencil
|
||||||
*/
|
*/
|
||||||
BEST,
|
BEST(8, 8, 8, 0, 32, 0, 8, 8, 8, 0, 16, 0),
|
||||||
/**
|
/**
|
||||||
* Turn off config chooser and use hardcoded
|
* Turn off config chooser and use hardcoded
|
||||||
* setEGLContextClientVersion(2); setEGLConfigChooser(5, 6, 5, 0, 16,
|
* setEGLContextClientVersion(2); setEGLConfigChooser(5, 6, 5, 0, 16,
|
||||||
* 0);
|
* 0);
|
||||||
*/
|
*/
|
||||||
LEGACY,
|
LEGACY(5, 6, 5, 0, 16, 0, 5, 6, 5, 0, 16, 0),
|
||||||
/**
|
/**
|
||||||
* RGB???, 8 alpha, >=16 depth, 0 stencil
|
* RGB???, 8 alpha, >=16 depth, 0 stencil
|
||||||
*/
|
*/
|
||||||
BEST_TRANSLUCENT,}
|
BEST_TRANSLUCENT(8, 8, 8, 8, 32, 0, 8, 8, 8, 8, 16, 0);
|
||||||
|
/**
|
||||||
|
* red, green, blue, alpha, depth, stencil
|
||||||
|
*/
|
||||||
|
int r, g, b, a, d, s;
|
||||||
|
/**
|
||||||
|
* fallback
|
||||||
|
*/
|
||||||
|
int fbr, fbg, fbb, fba, fbd, fbs;
|
||||||
|
|
||||||
|
private ConfigType(int r, int g, int b, int a, int d, int s, int fbr, int fbg, int fbb, int fba, int fbd, int fbs) {
|
||||||
|
this.r = r;
|
||||||
|
this.g = g;
|
||||||
|
this.b = b;
|
||||||
|
this.a = a;
|
||||||
|
this.d = d;
|
||||||
|
this.s = s;
|
||||||
|
this.fbr = fbr;
|
||||||
|
this.fbg = fbg;
|
||||||
|
this.fbb = fbb;
|
||||||
|
this.fba = fba;
|
||||||
|
this.fbd = fbd;
|
||||||
|
this.fbs = fbs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* @deprecated use AndroidConfigChooser(AppSettings settings)
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public AndroidConfigChooser(ConfigType type) {
|
public AndroidConfigChooser(ConfigType type) {
|
||||||
this.type = type;
|
this.settings = new AppSettings(true);
|
||||||
|
settings.put(SETTINGS_CONFIG_TYPE, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AndroidConfigChooser(AppSettings settings) {
|
||||||
|
this.settings = settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -67,33 +105,41 @@ public class AndroidConfigChooser implements EGLConfigChooser {
|
|||||||
* @return true if successfull, false if no config was found
|
* @return true if successfull, false if no config was found
|
||||||
*/
|
*/
|
||||||
public boolean findConfig(EGL10 egl, EGLDisplay display) {
|
public boolean findConfig(EGL10 egl, EGLDisplay display) {
|
||||||
ComponentSizeChooser compChooser = null;
|
ConfigType type = (ConfigType) settings.get(SETTINGS_CONFIG_TYPE);
|
||||||
switch (type) {
|
|
||||||
case BEST:
|
|
||||||
compChooser = new ComponentSizeChooser(8, 8, 8, 0, 32, 0);
|
|
||||||
choosenConfig = compChooser.chooseConfig(egl, display);
|
|
||||||
if (choosenConfig == null) {
|
|
||||||
compChooser = new ComponentSizeChooser(8, 8, 8, 0, 16, 0);
|
|
||||||
choosenConfig = compChooser.chooseConfig(egl, display);
|
|
||||||
}
|
|
||||||
logger.fine("JME3 using best EGL configuration available here: ");
|
|
||||||
break;
|
|
||||||
case BEST_TRANSLUCENT:
|
|
||||||
compChooser = new ComponentSizeChooser(8, 8, 8, 8, 32, 0);
|
|
||||||
choosenConfig = compChooser.chooseConfig(egl, display);
|
|
||||||
if (choosenConfig == null) {
|
|
||||||
compChooser = new ComponentSizeChooser(8, 8, 8, 8, 16, 0);
|
|
||||||
choosenConfig = compChooser.chooseConfig(egl, display);
|
|
||||||
}
|
|
||||||
logger.fine("JME3 using best EGL configuration available here with translucent pixels: ");
|
|
||||||
break;
|
|
||||||
case FASTEST:
|
|
||||||
compChooser = new ComponentSizeChooser(5, 6, 5, 0, 16, 0);
|
|
||||||
choosenConfig = compChooser.chooseConfig(egl, display);
|
|
||||||
logger.fine("JME3 using fastest EGL configuration available here: ");
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
ComponentSizeChooser compChooser = new ComponentSizeChooser(type.r, type.g, type.b, type.a, type.d, type.s, 4,1,2);
|
||||||
|
choosenConfig = compChooser.chooseConfig(egl, display);
|
||||||
|
if (choosenConfig == null) {
|
||||||
|
compChooser = new ComponentSizeChooser(type.fbr, type.fbg, type.fbb, type.fba, type.fbd, type.fbs);
|
||||||
|
choosenConfig = compChooser.chooseConfig(egl, display);
|
||||||
}
|
}
|
||||||
|
logger.log(Level.FINE, "JME3 using {0} EGL configuration available here: ", type.name());
|
||||||
|
// switch (type) {
|
||||||
|
// case BEST:
|
||||||
|
// compChooser = new ComponentSizeChooser(8, 8, 8, 0, 32, 0);
|
||||||
|
// choosenConfig = compChooser.chooseConfig(egl, display);
|
||||||
|
// if (choosenConfig == null) {
|
||||||
|
// compChooser = new ComponentSizeChooser(8, 8, 8, 0, 16, 0);
|
||||||
|
// choosenConfig = compChooser.chooseConfig(egl, display);
|
||||||
|
// }
|
||||||
|
// logger.fine("JME3 using best EGL configuration available here: ");
|
||||||
|
// break;
|
||||||
|
// case BEST_TRANSLUCENT:
|
||||||
|
// compChooser = new ComponentSizeChooser(8, 8, 8, 8, 32, 0);
|
||||||
|
// choosenConfig = compChooser.chooseConfig(egl, display);
|
||||||
|
// if (choosenConfig == null) {
|
||||||
|
// compChooser = new ComponentSizeChooser(8, 8, 8, 8, 16, 0);
|
||||||
|
// choosenConfig = compChooser.chooseConfig(egl, display);
|
||||||
|
// }
|
||||||
|
// logger.fine("JME3 using best EGL configuration available here with translucent pixels: ");
|
||||||
|
// break;
|
||||||
|
// case FASTEST:
|
||||||
|
// compChooser = new ComponentSizeChooser(5, 6, 5, 0, 16, 0);
|
||||||
|
// choosenConfig = compChooser.chooseConfig(egl, display);
|
||||||
|
// logger.fine("JME3 using fastest EGL configuration available here: ");
|
||||||
|
// break;
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
if (choosenConfig != null) {
|
if (choosenConfig != null) {
|
||||||
logger.fine("JME3 using choosen config: ");
|
logger.fine("JME3 using choosen config: ");
|
||||||
@ -173,6 +219,12 @@ public class AndroidConfigChooser implements EGLConfigChooser {
|
|||||||
|
|
||||||
egl.eglGetConfigAttrib(display, conf, EGL10.EGL_SURFACE_TYPE, value);
|
egl.eglGetConfigAttrib(display, conf, EGL10.EGL_SURFACE_TYPE, value);
|
||||||
logger.fine(String.format("EGL_SURFACE_TYPE = %d", value[0]));
|
logger.fine(String.format("EGL_SURFACE_TYPE = %d", value[0]));
|
||||||
|
|
||||||
|
egl.eglGetConfigAttrib(display, conf, EGL10.EGL_SAMPLE_BUFFERS, value);
|
||||||
|
logger.fine(String.format("EGL_SAMPLE_BUFFERS = %d", value[0]));
|
||||||
|
|
||||||
|
egl.eglGetConfigAttrib(display, conf, EGL10.EGL_SAMPLES, value);
|
||||||
|
logger.fine(String.format("EGL_SAMPLES = %d", value[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getClientOpenGLESVersion() {
|
public int getClientOpenGLESVersion() {
|
||||||
@ -277,6 +329,9 @@ public class AndroidConfigChooser implements EGLConfigChooser {
|
|||||||
protected int mAlphaSize;
|
protected int mAlphaSize;
|
||||||
protected int mDepthSize;
|
protected int mDepthSize;
|
||||||
protected int mStencilSize;
|
protected int mStencilSize;
|
||||||
|
protected int mRenderableType;
|
||||||
|
protected int mSampleBuffers;
|
||||||
|
protected int mSamples;
|
||||||
|
|
||||||
public ComponentSizeChooser(int redSize, int greenSize, int blueSize,
|
public ComponentSizeChooser(int redSize, int greenSize, int blueSize,
|
||||||
int alphaSize, int depthSize, int stencilSize) {
|
int alphaSize, int depthSize, int stencilSize) {
|
||||||
@ -297,6 +352,31 @@ public class AndroidConfigChooser implements EGLConfigChooser {
|
|||||||
mStencilSize = stencilSize;
|
mStencilSize = stencilSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ComponentSizeChooser(int redSize, int greenSize, int blueSize,
|
||||||
|
int alphaSize, int depthSize, int stencilSize, int renderableType, int sampleBuffers, int samples) {
|
||||||
|
super(new int[]{
|
||||||
|
EGL10.EGL_RED_SIZE, redSize,
|
||||||
|
EGL10.EGL_GREEN_SIZE, greenSize,
|
||||||
|
EGL10.EGL_BLUE_SIZE, blueSize,
|
||||||
|
EGL10.EGL_ALPHA_SIZE, alphaSize,
|
||||||
|
EGL10.EGL_DEPTH_SIZE, depthSize,
|
||||||
|
EGL10.EGL_STENCIL_SIZE, stencilSize,
|
||||||
|
EGL10.EGL_RENDERABLE_TYPE, renderableType,
|
||||||
|
EGL10.EGL_SAMPLE_BUFFERS, sampleBuffers,
|
||||||
|
EGL10.EGL_SAMPLES, samples,
|
||||||
|
EGL10.EGL_NONE});
|
||||||
|
mValue = new int[1];
|
||||||
|
mRedSize = redSize;
|
||||||
|
mGreenSize = greenSize;
|
||||||
|
mBlueSize = blueSize;
|
||||||
|
mAlphaSize = alphaSize;
|
||||||
|
mDepthSize = depthSize;
|
||||||
|
mStencilSize = stencilSize;
|
||||||
|
mRenderableType = renderableType;
|
||||||
|
mSampleBuffers = sampleBuffers;
|
||||||
|
mSamples = samples;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display, EGLConfig[] configs) {
|
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display, EGLConfig[] configs) {
|
||||||
|
|
||||||
@ -315,11 +395,9 @@ public class AndroidConfigChooser implements EGLConfigChooser {
|
|||||||
int s = findConfigAttrib(egl, display, config,
|
int s = findConfigAttrib(egl, display, config,
|
||||||
EGL10.EGL_STENCIL_SIZE, 0);
|
EGL10.EGL_STENCIL_SIZE, 0);
|
||||||
|
|
||||||
if ((
|
if ((r == mRedSize) && (g == mGreenSize)
|
||||||
r == mRedSize) && (g == mGreenSize)
|
|
||||||
&& (b == mBlueSize) && (a == mAlphaSize)
|
&& (b == mBlueSize) && (a == mAlphaSize)
|
||||||
&& (d == mDepthSize) && (s == mStencilSize)
|
&& (d == mDepthSize) && (s == mStencilSize)) {
|
||||||
) {
|
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex
|
|||||||
protected final AtomicBoolean created = new AtomicBoolean(false);
|
protected final AtomicBoolean created = new AtomicBoolean(false);
|
||||||
protected final AtomicBoolean renderable = new AtomicBoolean(false);
|
protected final AtomicBoolean renderable = new AtomicBoolean(false);
|
||||||
protected final AtomicBoolean needClose = new AtomicBoolean(false);
|
protected final AtomicBoolean needClose = new AtomicBoolean(false);
|
||||||
protected final AppSettings settings = new AppSettings(true);
|
protected AppSettings settings = new AppSettings(true);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* >= OpenGL ES 2.0 (Android 2.2+)
|
* >= OpenGL ES 2.0 (Android 2.2+)
|
||||||
@ -93,22 +93,39 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <code>createView</code> creates the GLSurfaceView that the
|
* <code>createView</code> creates the GLSurfaceView that the renderer will
|
||||||
* renderer will draw to.
|
* draw to. <p> The result GLSurfaceView will receive input events and
|
||||||
* <p>
|
* forward them to the Application. Any rendering will be done into the
|
||||||
* The result GLSurfaceView will receive input events and forward
|
* GLSurfaceView. Only one GLSurfaceView can be created at this time. The
|
||||||
* them to the Application. Any rendering will be done into
|
* given configType specifies how to determine the display configuration.
|
||||||
* the GLSurfaceView. Only one GLSurfaceView can be created at this time.
|
|
||||||
* The given configType specifies how to determine the display configuration.
|
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param configType ConfigType.FASTEST (Default) | ConfigType.LEGACY |
|
* @param configType ConfigType.FASTEST (Default) | ConfigType.LEGACY |
|
||||||
* ConfigType.BEST
|
* ConfigType.BEST
|
||||||
* @param eglConfigVerboseLogging if true show all found configs
|
* @param eglConfigVerboseLogging if true show all found configs
|
||||||
* @return GLSurfaceView The newly created view
|
* @return GLSurfaceView The newly created view
|
||||||
|
* @deprecated AndroidGLSurfaceView createView()
|
||||||
|
* and put the configType in the appSettigs with the key AndroidConfigChoose.SETTINGS_CONFIG_TYPE
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public AndroidGLSurfaceView createView(ConfigType configType, boolean eglConfigVerboseLogging) {
|
public AndroidGLSurfaceView createView(ConfigType configType, boolean eglConfigVerboseLogging) {
|
||||||
|
settings.put(AndroidConfigChooser.SETTINGS_CONFIG_TYPE, configType);
|
||||||
|
return this.createView();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* <code>createView</code> creates the GLSurfaceView that the renderer will
|
||||||
|
* draw to. <p> The result GLSurfaceView will receive input events and
|
||||||
|
* forward them to the Application. Any rendering will be done into the
|
||||||
|
* GLSurfaceView. Only one GLSurfaceView can be created at this time. The
|
||||||
|
* given configType specifies how to determine the display configuration.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param eglConfigVerboseLogging if true show all found configs
|
||||||
|
* @return GLSurfaceView The newly created view
|
||||||
|
*/
|
||||||
|
public AndroidGLSurfaceView createView() {
|
||||||
AndroidGLSurfaceView view;
|
AndroidGLSurfaceView view;
|
||||||
|
ConfigType configType = (ConfigType)settings.get(AndroidConfigChooser.SETTINGS_CONFIG_TYPE);
|
||||||
|
|
||||||
// Start to set up the view
|
// Start to set up the view
|
||||||
view = new AndroidGLSurfaceView(JmeAndroidSystem.getActivity().getApplication());
|
view = new AndroidGLSurfaceView(JmeAndroidSystem.getActivity().getApplication());
|
||||||
@ -136,7 +153,7 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// Create a config chooser
|
// Create a config chooser
|
||||||
AndroidConfigChooser configChooser = new AndroidConfigChooser(configType);
|
AndroidConfigChooser configChooser = new AndroidConfigChooser(settings);
|
||||||
// Init chooser
|
// Init chooser
|
||||||
if (!configChooser.findConfig(egl, display)) {
|
if (!configChooser.findConfig(egl, display)) {
|
||||||
listener.handleError("Unable to find suitable EGL config", null);
|
listener.handleError("Unable to find suitable EGL config", null);
|
||||||
@ -196,7 +213,6 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex
|
|||||||
|
|
||||||
// Setup unhandled Exception Handler
|
// Setup unhandled Exception Handler
|
||||||
Thread.currentThread().setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
|
Thread.currentThread().setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
|
||||||
|
|
||||||
public void uncaughtException(Thread thread, Throwable thrown) {
|
public void uncaughtException(Thread thread, Throwable thrown) {
|
||||||
listener.handleError("Exception thrown in " + thread.toString(), thrown);
|
listener.handleError("Exception thrown in " + thread.toString(), thrown);
|
||||||
}
|
}
|
||||||
@ -399,7 +415,6 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex
|
|||||||
|
|
||||||
final Activity activity = JmeAndroidSystem.getActivity();
|
final Activity activity = JmeAndroidSystem.getActivity();
|
||||||
activity.runOnUiThread(new Runnable() {
|
activity.runOnUiThread(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
@ -436,7 +451,6 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex
|
|||||||
|
|
||||||
AlertDialog dialogTextInput = new AlertDialog.Builder(activity).setTitle(title).setView(layoutTextDialogInput).setPositiveButton("OK",
|
AlertDialog dialogTextInput = new AlertDialog.Builder(activity).setTitle(title).setView(layoutTextDialogInput).setPositiveButton("OK",
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
public void onClick(DialogInterface dialog, int whichButton) {
|
public void onClick(DialogInterface dialog, int whichButton) {
|
||||||
/* User clicked OK, send COMPLETE action
|
/* User clicked OK, send COMPLETE action
|
||||||
* and text */
|
* and text */
|
||||||
@ -444,7 +458,6 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex
|
|||||||
}
|
}
|
||||||
}).setNegativeButton("Cancel",
|
}).setNegativeButton("Cancel",
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
public void onClick(DialogInterface dialog, int whichButton) {
|
public void onClick(DialogInterface dialog, int whichButton) {
|
||||||
/* User clicked CANCEL, send CANCEL action
|
/* User clicked CANCEL, send CANCEL action
|
||||||
* and text */
|
* and text */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user