use of com.jme3.system.android.OGLESContext in project jmonkeyengine by jMonkeyEngine.
the class AndroidHarness method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
initializeLogHandler();
logger.fine("onCreate");
super.onCreate(savedInstanceState);
if (screenFullScreen) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
} else {
if (!screenShowTitle) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
}
}
final DataObject data = (DataObject) getLastNonConfigurationInstance();
if (data != null) {
logger.log(Level.FINE, "Using Retained App");
this.app = data.app;
} else {
// Discover the screen reolution
//TODO try to find a better way to get a hand on the resolution
WindowManager wind = this.getWindowManager();
Display disp = wind.getDefaultDisplay();
Log.d("AndroidHarness", "Resolution from Window, width:" + disp.getWidth() + ", height: " + disp.getHeight());
// Create Settings
logger.log(Level.FINE, "Creating settings");
AppSettings settings = new AppSettings(true);
settings.setEmulateMouse(mouseEventsEnabled);
settings.setEmulateMouseFlipAxis(mouseEventsInvertX, mouseEventsInvertY);
settings.setUseJoysticks(joystickEventsEnabled);
settings.setEmulateKeyboard(keyEventsEnabled);
settings.setBitsPerPixel(eglBitsPerPixel);
settings.setAlphaBits(eglAlphaBits);
settings.setDepthBits(eglDepthBits);
settings.setSamples(eglSamples);
settings.setStencilBits(eglStencilBits);
settings.setResolution(disp.getWidth(), disp.getHeight());
settings.setAudioRenderer(audioRendererType);
settings.setFrameRate(frameRate);
// Create application instance
try {
if (app == null) {
@SuppressWarnings("unchecked") Class<? extends LegacyApplication> clazz = (Class<? extends LegacyApplication>) Class.forName(appClass);
app = clazz.newInstance();
}
app.setSettings(settings);
app.start();
} catch (Exception ex) {
handleError("Class " + appClass + " init failed", ex);
setContentView(new TextView(this));
}
}
ctx = (OGLESContext) app.getContext();
view = ctx.createView(this);
// store the glSurfaceView in JmeAndroidSystem for future use
JmeAndroidSystem.setView(view);
// AndroidHarness wraps the app as a SystemListener.
ctx.setSystemListener(this);
layoutDisplay();
}
use of com.jme3.system.android.OGLESContext in project jmonkeyengine by jMonkeyEngine.
the class AndroidHarnessFragment method onCreate.
/**
* This Fragment uses setRetainInstance(true) so the onCreate method will only
* be called once. During device configuration changes, the instance of
* this Fragment will be reused in the new Activity. This method should not
* contain any View related objects. They are created and destroyed by
* other methods. View related objects should not be reused, but rather
* created and destroyed along with the Activity.
*
* @param savedInstanceState
*/
@Override
public void onCreate(Bundle savedInstanceState) {
initializeLogHandler();
logger.fine("onCreate");
super.onCreate(savedInstanceState);
// Create Settings
logger.log(Level.FINE, "Creating settings");
AppSettings settings = new AppSettings(true);
settings.setEmulateMouse(mouseEventsEnabled);
settings.setEmulateMouseFlipAxis(mouseEventsInvertX, mouseEventsInvertY);
settings.setUseJoysticks(joystickEventsEnabled);
settings.setEmulateKeyboard(keyEventsEnabled);
settings.setBitsPerPixel(eglBitsPerPixel);
settings.setAlphaBits(eglAlphaBits);
settings.setDepthBits(eglDepthBits);
settings.setSamples(eglSamples);
settings.setStencilBits(eglStencilBits);
settings.setAudioRenderer(audioRendererType);
settings.setFrameRate(frameRate);
// Create application instance
try {
if (app == null) {
@SuppressWarnings("unchecked") Class<? extends LegacyApplication> clazz = (Class<? extends LegacyApplication>) Class.forName(appClass);
app = clazz.newInstance();
}
app.setSettings(settings);
app.start();
} catch (Exception ex) {
handleError("Class " + appClass + " init failed", ex);
}
OGLESContext ctx = (OGLESContext) app.getContext();
// AndroidHarness wraps the app as a SystemListener.
ctx.setSystemListener(this);
setRetainInstance(true);
}
use of com.jme3.system.android.OGLESContext in project jmonkeyengine by jMonkeyEngine.
the class OGLESContext method initInThread.
protected void initInThread() {
created.set(true);
logger.fine("OGLESContext create");
logger.log(Level.FINE, "Running on thread: {0}", Thread.currentThread().getName());
// Setup unhandled Exception Handler
Thread.currentThread().setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
public void uncaughtException(Thread thread, Throwable thrown) {
listener.handleError("Exception thrown in " + thread.toString(), thrown);
}
});
timer = new NanoTimer();
Object gl = new AndroidGL();
// gl = GLTracer.createGlesTracer((GL)gl, (GLExt)gl);
// gl = new GLDebugES((GL)gl, (GLExt)gl);
renderer = new GLRenderer((GL) gl, (GLExt) gl, (GLFbo) gl);
renderer.initialize();
JmeSystem.setSoftTextDialogInput(this);
needClose.set(false);
}
Aggregations