• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Main repository of MikuMikuStudio


Commit MetaInfo

修訂25f01b6ead42f9f03970ec50660afc39ed54891e (tree)
時間2013-03-04 18:30:24
作者remy.bouquet@gmail.com <remy.bouquet@gmai...>
Commiterremy.bouquet@gmail.com

Log Message

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: http://jmonkeyengine.googlecode.com/svn/trunk@10458 75d07b2b-3a1a-0410-a2c5-0572b91ccdca

Change Summary

差異

--- a/engine/src/android/com/jme3/app/AndroidHarness.java
+++ b/engine/src/android/com/jme3/app/AndroidHarness.java
@@ -25,6 +25,7 @@ import com.jme3.input.event.TouchEvent;
2525 import com.jme3.renderer.android.AndroidGLSurfaceView;
2626 import com.jme3.system.AppSettings;
2727 import com.jme3.system.SystemListener;
28+import com.jme3.system.android.AndroidConfigChooser;
2829 import com.jme3.system.android.AndroidConfigChooser.ConfigType;
2930 import com.jme3.system.android.JmeAndroidSystem;
3031 import com.jme3.system.android.OGLESContext;
@@ -43,12 +44,10 @@ import java.util.logging.Logger;
4344 public class AndroidHarness extends Activity implements TouchListener, DialogInterface.OnClickListener, SystemListener {
4445
4546 protected final static Logger logger = Logger.getLogger(AndroidHarness.class.getName());
46-
4747 /**
4848 * The application class to start
4949 */
5050 protected String appClass = "jme3test.android.Test";
51-
5251 /**
5352 * The jme3 application object
5453 */
@@ -59,55 +58,52 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
5958 * RGBA8888 or better if supported by the hardware
6059 */
6160 protected ConfigType eglConfigType = ConfigType.FASTEST;
62-
6361 /**
6462 * If true all valid and not valid egl configs are logged
63+ * @deprecated this has no use
6564 */
65+ @Deprecated
6666 protected boolean eglConfigVerboseLogging = false;
67-
67+
68+ /**
69+ * set to 2, 4 to enable multisampling.
70+ */
71+// protected int antiAliasingSamples = 0;
6872 /**
69- * If true Android Sensors are used as simulated Joysticks
70- * Users can use the Android sensor feedback through the RawInputListener
71- * or by registering JoyAxisTriggers.
73+ * If true Android Sensors are used as simulated Joysticks Users can use the
74+ * Android sensor feedback through the RawInputListener or by registering
75+ * JoyAxisTriggers.
7276 */
7377 protected boolean joystickEventsEnabled = false;
74-
7578 /**
7679 * If true MouseEvents are generated from TouchEvents
7780 */
7881 protected boolean mouseEventsEnabled = true;
79-
8082 /**
8183 * Flip X axis
8284 */
8385 protected boolean mouseEventsInvertX = false;
84-
8586 /**
8687 * Flip Y axis
8788 */
8889 protected boolean mouseEventsInvertY = false;
89-
9090 /**
9191 * if true finish this activity when the jme app is stopped
9292 */
9393 protected boolean finishOnAppStop = true;
94-
9594 /**
9695 * set to false if you don't want the harness to handle the exit hook
9796 */
9897 protected boolean handleExitHook = true;
99-
10098 /**
10199 * Title of the exit dialog, default is "Do you want to exit?"
102100 */
103101 protected String exitDialogTitle = "Do you want to exit?";
104-
105102 /**
106103 * Message of the exit dialog, default is "Use your home key to bring this
107104 * app into the background or exit to terminate it."
108105 */
109106 protected String exitDialogMessage = "Use your home key to bring this app into the background or exit to terminate it.";
110-
111107 /**
112108 * Set the screen window mode. If screenFullSize is true, then the
113109 * notification bar and title bar are removed and the screen covers the
@@ -116,20 +112,17 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
116112 * false, then the title bar is also displayed under the notification bar.
117113 */
118114 protected boolean screenFullScreen = true;
119-
120115 /**
121116 * if screenShowTitle is true while screenFullScreen is false, then the
122117 * title bar is also displayed under the notification bar
123118 */
124119 protected boolean screenShowTitle = true;
125-
126120 /**
127121 * Splash Screen picture Resource ID. If a Splash Screen is desired, set
128122 * splashPicID to the value of the Resource ID (i.e. R.drawable.picname). If
129123 * splashPicID = 0, then no splash screen will be displayed.
130124 */
131125 protected int splashPicID = 0;
132-
133126 /**
134127 * Set the screen orientation, default is SENSOR
135128 * ActivityInfo.SCREEN_ORIENTATION_* constants package
@@ -200,7 +193,10 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
200193 settings.setEmulateMouse(mouseEventsEnabled);
201194 settings.setEmulateMouseFlipAxis(mouseEventsInvertX, mouseEventsInvertY);
202195 settings.setUseJoysticks(joystickEventsEnabled);
196+// settings.setSamples(antiAliasingSamples);
203197 settings.setResolution(disp.getWidth(), disp.getHeight());
198+ settings.put(AndroidConfigChooser.SETTINGS_CONFIG_TYPE, eglConfigType);
199+
204200
205201 // Create application instance
206202 try {
@@ -221,7 +217,7 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
221217 }
222218
223219 ctx = (OGLESContext) app.getContext();
224- view = ctx.createView(eglConfigType, eglConfigVerboseLogging);
220+ view = ctx.createView();
225221 // AndroidHarness wraps the app as a SystemListener.
226222 ctx.setSystemListener(this);
227223 layoutDisplay();
@@ -401,7 +397,6 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
401397 switch (evt.getType()) {
402398 case KEY_UP:
403399 runOnUiThread(new Runnable() {
404-
405400 @Override
406401 public void run() {
407402 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
438433 }
439434
440435 if (view.getParent() != null) {
441- ((ViewGroup)view.getParent()).removeView(view);
436+ ((ViewGroup) view.getParent()).removeView(view);
442437 }
443438 frameLayout.addView(view);
444439
445440 if (splashImageView.getParent() != null) {
446- ((ViewGroup)splashImageView.getParent()).removeView(splashImageView);
441+ ((ViewGroup) splashImageView.getParent()).removeView(splashImageView);
447442 }
448443 frameLayout.addView(splashImageView, lp);
449444
@@ -461,7 +456,6 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
461456 if (frameLayout != null) {
462457 if (splashImageView != null) {
463458 this.runOnUiThread(new Runnable() {
464-
465459 @Override
466460 public void run() {
467461 splashImageView.setVisibility(View.INVISIBLE);
--- a/engine/src/android/com/jme3/system/android/AndroidConfigChooser.java
+++ b/engine/src/android/com/jme3/system/android/AndroidConfigChooser.java
@@ -2,6 +2,8 @@ package com.jme3.system.android;
22
33 import android.graphics.PixelFormat;
44 import android.opengl.GLSurfaceView.EGLConfigChooser;
5+import com.jme3.system.AppSettings;
6+import java.util.logging.Level;
57 import java.util.logging.Logger;
68 import javax.microedition.khronos.egl.EGL10;
79 import javax.microedition.khronos.egl.EGLConfig;
@@ -15,11 +17,12 @@ import javax.microedition.khronos.egl.EGLDisplay;
1517 public class AndroidConfigChooser implements EGLConfigChooser {
1618
1719 private static final Logger logger = Logger.getLogger(AndroidConfigChooser.class.getName());
20+ public final static String SETTINGS_CONFIG_TYPE = "configType";
1821 protected int clientOpenGLESVersion = 0;
1922 protected EGLConfig bestConfig = null;
2023 protected EGLConfig fastestConfig = null;
2124 protected EGLConfig choosenConfig = null;
22- protected ConfigType type;
25+ protected AppSettings settings;
2326 protected int pixelFormat;
2427 protected boolean verbose = false;
2528 private final static int EGL_OPENGL_ES2_BIT = 4;
@@ -29,24 +32,59 @@ public class AndroidConfigChooser implements EGLConfigChooser {
2932 /**
3033 * RGB565, 0 alpha, 16 depth, 0 stencil
3134 */
32- FASTEST,
35+ FASTEST(5, 6, 5, 0, 16, 0, 5, 6, 5, 0, 16, 0),
3336 /**
3437 * RGB???, 0 alpha, >=16 depth, 0 stencil
3538 */
36- BEST,
39+ BEST(8, 8, 8, 0, 32, 0, 8, 8, 8, 0, 16, 0),
3740 /**
3841 * Turn off config chooser and use hardcoded
3942 * setEGLContextClientVersion(2); setEGLConfigChooser(5, 6, 5, 0, 16,
4043 * 0);
4144 */
42- LEGACY,
45+ LEGACY(5, 6, 5, 0, 16, 0, 5, 6, 5, 0, 16, 0),
4346 /**
4447 * RGB???, 8 alpha, >=16 depth, 0 stencil
4548 */
46- BEST_TRANSLUCENT,}
49+ BEST_TRANSLUCENT(8, 8, 8, 8, 32, 0, 8, 8, 8, 8, 16, 0);
50+ /**
51+ * red, green, blue, alpha, depth, stencil
52+ */
53+ int r, g, b, a, d, s;
54+ /**
55+ * fallback
56+ */
57+ int fbr, fbg, fbb, fba, fbd, fbs;
58+
59+ 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) {
60+ this.r = r;
61+ this.g = g;
62+ this.b = b;
63+ this.a = a;
64+ this.d = d;
65+ this.s = s;
66+ this.fbr = fbr;
67+ this.fbg = fbg;
68+ this.fbb = fbb;
69+ this.fba = fba;
70+ this.fbd = fbd;
71+ this.fbs = fbs;
72+ }
73+ }
4774
75+ /**
76+ *
77+ * @param type
78+ * @deprecated use AndroidConfigChooser(AppSettings settings)
79+ */
80+ @Deprecated
4881 public AndroidConfigChooser(ConfigType type) {
49- this.type = type;
82+ this.settings = new AppSettings(true);
83+ settings.put(SETTINGS_CONFIG_TYPE, type);
84+ }
85+
86+ public AndroidConfigChooser(AppSettings settings) {
87+ this.settings = settings;
5088 }
5189
5290 /**
@@ -66,34 +104,42 @@ public class AndroidConfigChooser implements EGLConfigChooser {
66104 * @param display
67105 * @return true if successfull, false if no config was found
68106 */
69- public boolean findConfig(EGL10 egl, EGLDisplay display) {
70- ComponentSizeChooser compChooser = null;
71- switch (type) {
72- case BEST:
73- compChooser = new ComponentSizeChooser(8, 8, 8, 0, 32, 0);
74- choosenConfig = compChooser.chooseConfig(egl, display);
75- if (choosenConfig == null) {
76- compChooser = new ComponentSizeChooser(8, 8, 8, 0, 16, 0);
77- choosenConfig = compChooser.chooseConfig(egl, display);
78- }
79- logger.fine("JME3 using best EGL configuration available here: ");
80- break;
81- case BEST_TRANSLUCENT:
82- compChooser = new ComponentSizeChooser(8, 8, 8, 8, 32, 0);
83- choosenConfig = compChooser.chooseConfig(egl, display);
84- if (choosenConfig == null) {
85- compChooser = new ComponentSizeChooser(8, 8, 8, 8, 16, 0);
86- choosenConfig = compChooser.chooseConfig(egl, display);
87- }
88- logger.fine("JME3 using best EGL configuration available here with translucent pixels: ");
89- break;
90- case FASTEST:
91- compChooser = new ComponentSizeChooser(5, 6, 5, 0, 16, 0);
92- choosenConfig = compChooser.chooseConfig(egl, display);
93- logger.fine("JME3 using fastest EGL configuration available here: ");
94- break;
95-
107+ public boolean findConfig(EGL10 egl, EGLDisplay display) {
108+ ConfigType type = (ConfigType) settings.get(SETTINGS_CONFIG_TYPE);
109+
110+ ComponentSizeChooser compChooser = new ComponentSizeChooser(type.r, type.g, type.b, type.a, type.d, type.s, 4,1,2);
111+ choosenConfig = compChooser.chooseConfig(egl, display);
112+ if (choosenConfig == null) {
113+ compChooser = new ComponentSizeChooser(type.fbr, type.fbg, type.fbb, type.fba, type.fbd, type.fbs);
114+ choosenConfig = compChooser.chooseConfig(egl, display);
96115 }
116+ logger.log(Level.FINE, "JME3 using {0} EGL configuration available here: ", type.name());
117+// switch (type) {
118+// case BEST:
119+// compChooser = new ComponentSizeChooser(8, 8, 8, 0, 32, 0);
120+// choosenConfig = compChooser.chooseConfig(egl, display);
121+// if (choosenConfig == null) {
122+// compChooser = new ComponentSizeChooser(8, 8, 8, 0, 16, 0);
123+// choosenConfig = compChooser.chooseConfig(egl, display);
124+// }
125+// logger.fine("JME3 using best EGL configuration available here: ");
126+// break;
127+// case BEST_TRANSLUCENT:
128+// compChooser = new ComponentSizeChooser(8, 8, 8, 8, 32, 0);
129+// choosenConfig = compChooser.chooseConfig(egl, display);
130+// if (choosenConfig == null) {
131+// compChooser = new ComponentSizeChooser(8, 8, 8, 8, 16, 0);
132+// choosenConfig = compChooser.chooseConfig(egl, display);
133+// }
134+// logger.fine("JME3 using best EGL configuration available here with translucent pixels: ");
135+// break;
136+// case FASTEST:
137+// compChooser = new ComponentSizeChooser(5, 6, 5, 0, 16, 0);
138+// choosenConfig = compChooser.chooseConfig(egl, display);
139+// logger.fine("JME3 using fastest EGL configuration available here: ");
140+// break;
141+//
142+// }
97143
98144 if (choosenConfig != null) {
99145 logger.fine("JME3 using choosen config: ");
@@ -173,6 +219,12 @@ public class AndroidConfigChooser implements EGLConfigChooser {
173219
174220 egl.eglGetConfigAttrib(display, conf, EGL10.EGL_SURFACE_TYPE, value);
175221 logger.fine(String.format("EGL_SURFACE_TYPE = %d", value[0]));
222+
223+ egl.eglGetConfigAttrib(display, conf, EGL10.EGL_SAMPLE_BUFFERS, value);
224+ logger.fine(String.format("EGL_SAMPLE_BUFFERS = %d", value[0]));
225+
226+ egl.eglGetConfigAttrib(display, conf, EGL10.EGL_SAMPLES, value);
227+ logger.fine(String.format("EGL_SAMPLES = %d", value[0]));
176228 }
177229
178230 public int getClientOpenGLESVersion() {
@@ -277,6 +329,9 @@ public class AndroidConfigChooser implements EGLConfigChooser {
277329 protected int mAlphaSize;
278330 protected int mDepthSize;
279331 protected int mStencilSize;
332+ protected int mRenderableType;
333+ protected int mSampleBuffers;
334+ protected int mSamples;
280335
281336 public ComponentSizeChooser(int redSize, int greenSize, int blueSize,
282337 int alphaSize, int depthSize, int stencilSize) {
@@ -297,6 +352,31 @@ public class AndroidConfigChooser implements EGLConfigChooser {
297352 mStencilSize = stencilSize;
298353 }
299354
355+ public ComponentSizeChooser(int redSize, int greenSize, int blueSize,
356+ int alphaSize, int depthSize, int stencilSize, int renderableType, int sampleBuffers, int samples) {
357+ super(new int[]{
358+ EGL10.EGL_RED_SIZE, redSize,
359+ EGL10.EGL_GREEN_SIZE, greenSize,
360+ EGL10.EGL_BLUE_SIZE, blueSize,
361+ EGL10.EGL_ALPHA_SIZE, alphaSize,
362+ EGL10.EGL_DEPTH_SIZE, depthSize,
363+ EGL10.EGL_STENCIL_SIZE, stencilSize,
364+ EGL10.EGL_RENDERABLE_TYPE, renderableType,
365+ EGL10.EGL_SAMPLE_BUFFERS, sampleBuffers,
366+ EGL10.EGL_SAMPLES, samples,
367+ EGL10.EGL_NONE});
368+ mValue = new int[1];
369+ mRedSize = redSize;
370+ mGreenSize = greenSize;
371+ mBlueSize = blueSize;
372+ mAlphaSize = alphaSize;
373+ mDepthSize = depthSize;
374+ mStencilSize = stencilSize;
375+ mRenderableType = renderableType;
376+ mSampleBuffers = sampleBuffers;
377+ mSamples = samples;
378+ }
379+
300380 @Override
301381 public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display, EGLConfig[] configs) {
302382
@@ -315,11 +395,9 @@ public class AndroidConfigChooser implements EGLConfigChooser {
315395 int s = findConfigAttrib(egl, display, config,
316396 EGL10.EGL_STENCIL_SIZE, 0);
317397
318- if ((
319- r == mRedSize) && (g == mGreenSize)
398+ if ((r == mRedSize) && (g == mGreenSize)
320399 && (b == mBlueSize) && (a == mAlphaSize)
321- && (d == mDepthSize) && (s == mStencilSize)
322- ) {
400+ && (d == mDepthSize) && (s == mStencilSize)) {
323401 return config;
324402 }
325403 }
--- a/engine/src/android/com/jme3/system/android/OGLESContext.java
+++ b/engine/src/android/com/jme3/system/android/OGLESContext.java
@@ -66,7 +66,7 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex
6666 protected final AtomicBoolean created = new AtomicBoolean(false);
6767 protected final AtomicBoolean renderable = new AtomicBoolean(false);
6868 protected final AtomicBoolean needClose = new AtomicBoolean(false);
69- protected final AppSettings settings = new AppSettings(true);
69+ protected AppSettings settings = new AppSettings(true);
7070
7171 /*
7272 * >= OpenGL ES 2.0 (Android 2.2+)
@@ -91,24 +91,41 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex
9191 public Type getType() {
9292 return Type.Display;
9393 }
94-
94+
9595 /**
96- * <code>createView</code> creates the GLSurfaceView that the
97- * renderer will draw to.
98- * <p>
99- * The result GLSurfaceView will receive input events and forward
100- * them to the Application. Any rendering will be done into
101- * the GLSurfaceView. Only one GLSurfaceView can be created at this time.
102- * The given configType specifies how to determine the display configuration.
96+ * <code>createView</code> creates the GLSurfaceView that the renderer will
97+ * draw to. <p> The result GLSurfaceView will receive input events and
98+ * forward them to the Application. Any rendering will be done into the
99+ * GLSurfaceView. Only one GLSurfaceView can be created at this time. The
100+ * given configType specifies how to determine the display configuration.
103101 *
104102 *
105103 * @param configType ConfigType.FASTEST (Default) | ConfigType.LEGACY |
106104 * ConfigType.BEST
107105 * @param eglConfigVerboseLogging if true show all found configs
108106 * @return GLSurfaceView The newly created view
107+ * @deprecated AndroidGLSurfaceView createView()
108+ * and put the configType in the appSettigs with the key AndroidConfigChoose.SETTINGS_CONFIG_TYPE
109109 */
110+ @Deprecated
110111 public AndroidGLSurfaceView createView(ConfigType configType, boolean eglConfigVerboseLogging) {
111- AndroidGLSurfaceView view;
112+ settings.put(AndroidConfigChooser.SETTINGS_CONFIG_TYPE, configType);
113+ return this.createView();
114+ }
115+ /**
116+ * <code>createView</code> creates the GLSurfaceView that the renderer will
117+ * draw to. <p> The result GLSurfaceView will receive input events and
118+ * forward them to the Application. Any rendering will be done into the
119+ * GLSurfaceView. Only one GLSurfaceView can be created at this time. The
120+ * given configType specifies how to determine the display configuration.
121+ *
122+ *
123+ * @param eglConfigVerboseLogging if true show all found configs
124+ * @return GLSurfaceView The newly created view
125+ */
126+ public AndroidGLSurfaceView createView() {
127+ AndroidGLSurfaceView view;
128+ ConfigType configType = (ConfigType)settings.get(AndroidConfigChooser.SETTINGS_CONFIG_TYPE);
112129
113130 // Start to set up the view
114131 view = new AndroidGLSurfaceView(JmeAndroidSystem.getActivity().getApplication());
@@ -136,7 +153,7 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex
136153
137154 try {
138155 // Create a config chooser
139- AndroidConfigChooser configChooser = new AndroidConfigChooser(configType);
156+ AndroidConfigChooser configChooser = new AndroidConfigChooser(settings);
140157 // Init chooser
141158 if (!configChooser.findConfig(egl, display)) {
142159 listener.handleError("Unable to find suitable EGL config", null);
@@ -196,7 +213,6 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex
196213
197214 // Setup unhandled Exception Handler
198215 Thread.currentThread().setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
199-
200216 public void uncaughtException(Thread thread, Throwable thrown) {
201217 listener.handleError("Exception thrown in " + thread.toString(), thrown);
202218 }
@@ -399,7 +415,6 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex
399415
400416 final Activity activity = JmeAndroidSystem.getActivity();
401417 activity.runOnUiThread(new Runnable() {
402-
403418 @Override
404419 public void run() {
405420
@@ -436,7 +451,6 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex
436451
437452 AlertDialog dialogTextInput = new AlertDialog.Builder(activity).setTitle(title).setView(layoutTextDialogInput).setPositiveButton("OK",
438453 new DialogInterface.OnClickListener() {
439-
440454 public void onClick(DialogInterface dialog, int whichButton) {
441455 /* User clicked OK, send COMPLETE action
442456 * and text */
@@ -444,7 +458,6 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex
444458 }
445459 }).setNegativeButton("Cancel",
446460 new DialogInterface.OnClickListener() {
447-
448461 public void onClick(DialogInterface dialog, int whichButton) {
449462 /* User clicked CANCEL, send CANCEL action
450463 * and text */