Pregunta

I'm building a small game with libgdx for desktop/android. Everything works fine if run on desktop, but it has a strange issue on android.

When i switch from menu screen to game screen, I can hear soundtrack of the game screen, but the picture does not change. If i tap the screen, I hear sounds of the game, but picture stays the same (menu screen). On top of that this happens not every time - some times screen changes correctly and if it does game would run fine with no slowdowns...

Rendering code is the following and I have found out that problem goes away if I get rid of mesh rendering:

Gdx.gl.glClearColor(1, 1, 1, 1);
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

camera.update();
game.batch.setProjectionMatrix(camera.combined);

game.batch.begin();
    game.batch.draw(UI.LevelScreenSkin.getRegion("LevelBackGround"), UI.BG_TEXTURE_OFFSET_X, UI.BG_TEXTURE_OFFSET_Y, UI.BG_TEXTURE_WIDTH, UI.BG_TEXTURE_HEIGHT);
game.batch.end();

MainStage.act();
MainStage.draw();

//get updated mesh data from blocks
updateGlobalMeshData(false);
setGlobalMeshData();

//enable blending
Gdx.gl.glEnable(GL10.GL_BLEND);

//render blocks
globalMesh.render(GL10.GL_TRIANGLES, 0, ThisLevel.globalMesh.getMaxIndices());

//render blocks' borders

//enable texture binding
Gdx.graphics.getGL10().glEnable(GL10.GL_TEXTURE_2D);

//render borders
borderTexture.bind();
globalBorderMesh.render(GL10.GL_TRIANGLES, 0, globalBorderMesh.getMaxIndices());

//disable texture binding and blending
Gdx.graphics.getGL10().glDisable(GL10.GL_TEXTURE_2D);
Gdx.gl.glDisable(GL10.GL_BLEND);

Second mesh has about 2000 vertices, so first I thought maybe my device cannot process these, but in those cases when game starts, everything runs fine and rendering goes without any slowness.

¿Fue útil?

Solución

Issue was resolved when I switched to OpenGL 2 - maybe that was some glitch with backward compatibility on the device...

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top