I'm making a game with Libgdx 1.6.4 and experience some lag issues on iPhone 4 and then discovered:
// in the constructor GLProfiler.enable(); ... // in the render method Gdx.app.debug("draw calls: " + GLProfiler.drawCalls); Gdx.app.debug("texture bindings: " + GLProfiler.textureBindings); GLProfiler.reset();
What the log shows is that the number of draw calls is always equal to the number of texture bindings. Do you know if this is ok?
It seems strange because I have all images as TextureRegion in only one TextureAtlas with size 1024x512. Isn't it supposed to be that I will have for example 50 draw calls and only 1-2 texture binding instead of 50 draw calls and 50 texture bindings. Can this be the source of the lag?
Another clue may be, that I use a SpriteBatch and Scene2d Stage at the same time, but they both use the same TextureAtlas. The Scene2d Skin is loading the TextureAtlas and SpriteBatch draws TextureRegions from the skins' regions.
Thank you for any help.
--- Update ---
The main SpriteBatch (it's only one) is making 9 totalRenderCalls. The value of maxSpritesInBatch is 26. These values seem normal from what I read in the Docs and the FPS during rendering with the SpriteBatch is 60 FPS. Which is ok, no problem there.
The problem with the lag is when I use a Scene2D Stage to display a Dialog above the GameScreen. The Stage has it's own batch which I don't manipulate directly. When the Dialog is displayed the frame rate drops to 49-50 and the Animations in the Dialog are crappy. I guess the problem has something to do with Texture Binding of the main SpriteBatch and the Stage's SpriteBatch.