dexter86 wrote:
Yes the values are accumulated. Can you explain more about the texture switches or point me somewhere i can read about it? Is it important how many files i'm using or how many SpriteSheets? Or is it even important how many parts of that SpriteSheets i'm using. Are there ways to avoid texture changes?
The more sprites you can fit into the same texture atlas, the less binds you will need and therefore the faster your rendering will be (i.e. this means ALL image you require in your game, including HUD elements and font glyphs).
Slick's Image class is a thin wrapper around Texture. Different images may point to the same internal texture object -- you can get "shallow" copies with getSubImage(), getFlippedCopy(), getScaledCopy(), and copy().
In other words, you can have as many copies as you like of an image without losing performance as long as they all point to the same Texture object. The more Texture objects you introduce, the more binds you will require, and the more your performance will take a hit (only one Texture can be bound at a time by OpenGL).
Try using the new InternalTextureLoader.getTextureCount() method to get a better idea of what's going on under the hood (in the dev branch on
bitbucket). You'll always have 1 texture; the default font.
Also, if you want more performance, don't use Image.draw at all. Instead, always use startUse/drawEmbedded/endUse. It will reduce matrix transforms as well as glBegin/glEnd calls.
To reduce glBegin/glEnd even more, you can try a vertex array renderer -- add the following code
before you create your game container:
Code:
Renderer.setRenderer(Renderer.VERTEX_ARRAY_RENDERER);
More information and performance tips:
http://slick.cokeandcode.com/wiki/doku. ... emory_tipsviewtopic.php?p=26686#p26686