Drawing thousands of sprites with a single draw call.

XavyerXavyer MDMember ✭✭

Hello.
I have a working project written in OpenGL ES 2.0 where i draw several thousands of sprites on a screen in a form of one huge graph and then can scroll/zoom around it. This is done by filling VBOs and using single draw call to draw them all. When i needed to scroll/zoom i just transformed matrix and call the draw again. Performance is perfect on any emulator or device. I am trying to migrate this to CocosSharp.
I've done the flowing test in the AddedToScene:

var texture = new CCTexture2D("Texture.jpg");
var frame = new CCSpriteFrame(texture, new CCRect(0, 0, 30, 30));
for (int i = 1; i < 4000; i++)
     {
      var sprite = new CCSprite(frame);
      sprite.Position = new CCPoint(i, 0);
      AddChild(sprite);
     }  

When i then try to change Layer's transform during TouchMoved event i see that drawing is very slow, and it gets slower the more sprites i add to a layer. This lead me to believe it is calling draw per sprite, or per bunch of sprites but not a one draw for all of them as it should for all sprites coming from single texture.
So my question is : What is the correct way to draw thousands of sprites in one Draw call?

P.S. Using CocosSharp version 1.7.1 for Xamarin Forms, testing on Genymotion emulator Android 5.1

Posts

Sign In or Register to comment.