Use libGDX platform. After loading textures my application gets short and not controlled freeze.
@Override
public void render() {
float deltaTime = Gdx.graphics.getDeltaTime();
if (IS_LOG_ENGINE_SPEED_INFO) {
startTickCount = System.currentTimeMillis();
runingAppTime += deltaTime;
}
if (sceneDirector.sceneUpdate()) {
deltaTime = 0;
if (!manager.update()) {
Gdx.app.log("aaa", "Skip!");
return;
}
}
sceneDirector.getCurScene().updateLogic(deltaTime);
if (IS_LOG_ENGINE_SPEED_INFO) {
logStr = (System.currentTimeMillis() - startTickCount) + ", ";
startTickCount = System.currentTimeMillis();
}
Gdx.gl.glClearColor(1, 1, 1, 1);
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
batch.setProjectionMatrix(camera.combined);
sceneDirector.getCurScene().updateGraph(batch);
if (IS_LOG_ENGINE_SPEED_INFO) Gdx.app.log("aaa", logStr + (System.currentTimeMillis() - startTickCount));
}
What I do: If changed the scene - workout the method sceneDirector.sceneUpdate () and there is a loading of textures. Texture loading function:
public static void loadAtlas(String pngFileName, String xmlFileName, Scene scene) {
MainClass.manager.load(pngFileName, Texture.class);
MainClass.manager.finishLoading();
Texture texture = MainClass.manager.get(pngFileName, Texture.class);
scene.textures.add(texture);
texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
...
And what do we get in the end... Loading methods work out correctly. Rendering graphics is only when the texture loading. This is confirmed by the logs that show the application:
01-07 16:38:50.509: INFO/aaa(27259): LogicTime: 1712, GraphTime: 145
01-07 16:38:50.559: INFO/aaa(27259): LogicTime: 0, GraphTime: 38
01-07 16:38:50.559: INFO/aaa(27259): LogicTime: 0, GraphTime: 1
01-07 16:38:50.569: INFO/aaa(27259): LogicTime: 0, GraphTime: 3
01-07 16:38:50.579: INFO/aaa(27259): LogicTime: 1, GraphTime: 1
01-07 16:38:50.589: INFO/aaa(27259): LogicTime: 0, GraphTime: 1
01-07 16:38:50.609: INFO/aaa(27259): LogicTime: 2, GraphTime: 2
01-07 16:38:50.629: INFO/aaa(27259): LogicTime: 0, GraphTime: 1
01-07 16:38:50.649: INFO/aaa(27259): LogicTime: 0, GraphTime: 4
But! Why first and second graphics update do so long? This question is important because after loading the graphics immediately begin action on the scene.