Android: Move application initialization to the first onDrawFrame. Resolves issues where simpleInitApp gets called without the correct appsettings width and height.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10917 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
experimental
iwg..ic 11 years ago
parent 1e33d2b0f3
commit 4f75cb688f
  1. 21
      engine/src/android/com/jme3/system/android/OGLESContext.java

@ -176,7 +176,7 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex
renderer.resetGLObjects();
} else {
if (!created.get()) {
logger.fine("GL Surface created, doing JME3 init");
logger.fine("GL Surface created, initializing JME3 renderer");
initInThread();
} else {
logger.warning("GL Surface already created");
@ -201,12 +201,10 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex
renderer = new OGLESShaderRenderer();
renderer.initialize();
listener.initialize();
JmeSystem.setSoftTextDialogInput(this);
needClose.set(false);
renderable.set(true);
}
/**
@ -302,9 +300,18 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex
@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
logger.log(Level.FINE, "GL Surface changed, width: {0} height: {1}", new Object[]{width, height});
// update the application settings with the new resolution
settings.setResolution(width, height);
// reload settings in androidInput so the correct touch event scaling can be
// calculated in case the surface resolution is different than the view
androidInput.loadSettings(settings);
// if the application has already been initialized (ie renderable is set)
// then call reshape so the app can adjust to the new resolution.
if (renderable.get()) {
logger.log(Level.FINE, "App already initialized, calling reshape");
listener.reshape(width, height);
}
}
// SystemListener:update
@Override
@ -314,7 +321,13 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex
return;
}
if (renderable.get()) {
if (!renderable.get()) {
if (created.get()) {
logger.fine("GL Surface is setup, initializing application");
listener.initialize();
renderable.set(true);
}
} else {
if (!created.get()) {
throw new IllegalStateException("onDrawFrame without create");
}

Loading…
Cancel
Save