use of com.jme3.system.JmeContext in project jmonkeyengine by jMonkeyEngine.
the class JmeIosSystem method newContext.
@Override
public JmeContext newContext(AppSettings settings, JmeContext.Type contextType) {
initialize(settings);
JmeContext ctx = null;
if (settings.getRenderer() == null || settings.getRenderer().equals("NULL") || contextType == JmeContext.Type.Headless) {
ctx = new NullContext();
ctx.setSettings(settings);
} else {
ctx = new IGLESContext();
ctx.setSettings(settings);
}
return ctx;
}
use of com.jme3.system.JmeContext in project jmonkeyengine by jMonkeyEngine.
the class TestChooser method startApp.
private void startApp(final Object[] appClass) {
if (appClass == null) {
JOptionPane.showMessageDialog(rootPane, "Please select a test from the list", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
new Thread(new Runnable() {
public void run() {
for (int i = 0; i < appClass.length; i++) {
Class<?> clazz = (Class) appClass[i];
try {
if (LegacyApplication.class.isAssignableFrom(clazz)) {
Object app = clazz.newInstance();
if (app instanceof SimpleApplication) {
final Method settingMethod = clazz.getMethod("setShowSettings", boolean.class);
settingMethod.invoke(app, showSetting);
}
final Method mainMethod = clazz.getMethod("start");
mainMethod.invoke(app);
Field contextField = LegacyApplication.class.getDeclaredField("context");
contextField.setAccessible(true);
JmeContext context = null;
while (context == null) {
context = (JmeContext) contextField.get(app);
Thread.sleep(100);
}
while (!context.isCreated()) {
Thread.sleep(100);
}
while (context.isCreated()) {
Thread.sleep(100);
}
} else {
final Method mainMethod = clazz.getMethod("main", (new String[0]).getClass());
mainMethod.invoke(clazz, new Object[] { new String[0] });
}
// wait for destroy
System.gc();
} catch (IllegalAccessException ex) {
logger.log(Level.SEVERE, "Cannot access constructor: " + clazz.getName(), ex);
} catch (IllegalArgumentException ex) {
logger.log(Level.SEVERE, "main() had illegal argument: " + clazz.getName(), ex);
} catch (InvocationTargetException ex) {
logger.log(Level.SEVERE, "main() method had exception: " + clazz.getName(), ex);
} catch (InstantiationException ex) {
logger.log(Level.SEVERE, "Failed to create app: " + clazz.getName(), ex);
} catch (NoSuchMethodException ex) {
logger.log(Level.SEVERE, "Test class doesn't have main method: " + clazz.getName(), ex);
} catch (Exception ex) {
logger.log(Level.SEVERE, "Cannot start test: " + clazz.getName(), ex);
ex.printStackTrace();
}
}
}
}).start();
}
Aggregations