R.D. wrote:
Started the test, with 2000 balls nothing else changed, but when using drawEmbedded (push Space once) I get more fps

So this means no translation huh? Dammit. Rotation is not the big deal but it would be awesome if I ould be able to translate inside a start/end by manipulating the vertex data. That's what I do when making a wave animation for a set of letters. I translate the current letter and translate back after drawing it.
What is the FPS difference? GPU/system specs?
I'm not sure why it's slower on your machine. In the end both are doing one draw call per frame, but drawEmbedded needs a
lot of calls to glVertex, whereas the sprite batch does all of that in one go.
Might be that:
- Your driver optimizes for GL_QUAD, whereas the default sprite batch mode is GL_TRIANGLES (setUseTriangles changes this)
- The batch size given to glDrawArrays is too large, slowing things down
- The need to draw color info is slowing down SpriteBatch (drawEmbedded ignores it unless specified)
For typical use SpriteBatch will probably be faster than many calls to drawEmbedded as it will have fewer texture binds, render calls, etc. And for most machines it should perform far better, again I'm not sure why this isn't the case for you.
As for translation, this is definitely possible. I required it in my own game so I added a "translate" method to SpriteBatch:
http://pastebin.com/yV0NUrq7 (Ignore the VBO stuff as it isn't ready yet.)
Should work as expected.. Example:
Code:
batch.resetTranslation(); //call at beginning or end of each frame to reset the translation
batch.drawImage(img, 0, 0); //will draw at (0, 0)
batch.translate(10, 10);
batch.drawImage(img, 0, 0); //will translate to (10, 10) before drawing
batch.translate(-10, -10);
batch.drawImage(img, 0, 0); //will draw at (0, 0)
batch.flush();
Todos:
- Optional point sprite mode for faster rendering
- VBO + shader + instancing for newer GL versions
- Transform matrix to rotate/scale the batch (in addition to translate)
- Replace SpriteFont with Slick's AngelCodeFont