I've just now tested rendering a lot of sprites using XNA's SpriteBatch class. What I basically do is this:
Somewhere in the code, I have a list which contains all sprites that have to be rendered. I prefilled this list with 2500 Sprites, all of which have the same rotational angle, texture, position etc.
I then draw them like this:
spriteBatch.Begin();
foreach (Sprite spr in sprites)
spriteBatch.Draw(spr.Texture, spr.Position+spr.Center, spr.SourceRect, spr.Color,MathHelper.ToRadians( spr.Rotation ), spr.Center, spr.Scale, SpriteEffects.None, spr.Depth);
spriteBatch.End();
and I'm getting really poor performance. I only average about 15FPS with my Radeon HD 6850 graphics card and i5 2500k CPU.
This is very surprising to me, since I average about 70 FPS doing exactly the same thing with my own custom OpenGL engine, which uses old OpenGL rendering (meaning one draw call for every single sprite). I actually expected XNAs rendering to be a ton faster, since it draws everything in one draw call.
Am I rendering this the wrong way? Playing around with SpriteSortMode settings has made almost no difference, some of them just make it a tiny bit slower (depth sorting etc.).
sprites
every frame, or only once? Have you tried removing the+spr.Center
andMath.ToRadians
to see if the math calls are slowing it down? \$\endgroup\$Game.IsFixedTimeStep
andgraphics.SynchronizeWithVerticalRetrace
are set tofalse
. \$\endgroup\$