SpriteBatch -> 2x performance improvement anyone?

  ... information about changes and new features of AndEngine,

How do you like the SpriteBatch feature?

I waited for this for my whole life!!
48
49%
I'll use it in my next project!
27
28%
I don't know... yet.
22
22%
I don't need it, can I have a beer instead?
1
1%
 
Total votes : 98

Re: SpriteBatch -> 2x performance improvement anyone?

Postby aerobowl » Wed Jun 22, 2011 7:25 am

thank you for the update :D

for my case either due to the number of sprites is small (about 50 sprites with physics body) or my poor programming skills, i only manage to get about 10% improvement which is like 20fps (old) vs 23fps (new)
aerobowl
 
Posts: 7
Joined: Tue Feb 08, 2011 3:29 am

Re: SpriteBatch -> 2x performance improvement anyone?

Postby dironto » Sat Jun 25, 2011 2:25 pm

Hi Nicolas,

I am wondering (without any openGL knowledge)...
Could a similar approach of SpriteBatch also be used for fast(er) drawing of andengine's Shapes like Line,Rectangle etc?
In my gameworld a lot of the surroundings are not sprites, but actually primitive shapes. (including a new shape: TriangleShape from SVG extensions, to allow to fill up any closed path)

Regards,

Ronald
Regards,
Ronald
dironto
 
Posts: 65
Joined: Mon May 23, 2011 12:24 am
Location: Amsterdam, The Netherlands

Re: SpriteBatch -> 2x performance improvement anyone?

Postby Nicolas Gramlich » Sat Jun 25, 2011 5:17 pm

Hi Ronald,

yes, the same approach could be applied to primitives, pretty much with the same code, excluding where TextureRegions are used.

Best Regards,
Nicolas
Nicolas Gramlich
Site Admin
 
Posts: 1734
Joined: Mon Jun 07, 2010 6:20 pm
Location: Schriesheim, Germany

Re: SpriteBatch -> 2x performance improvement anyone?

Postby While(E) » Sun Jun 26, 2011 9:14 pm

Love the idea of this class, but is there an efficient way to use it with AnimatedSprites? The real question is can you individually manipulate the animation (or current tile index) of each of them, such as if you were to initialize the sprite with a clone of the TiledTextureRegion. I haven't tested it yet, but I'm assuming that if it would work with the TiledTextureRegion which I doubt at the moment, then it would act like it doesn't clone but simply assigns and therefore all of the Sprites will be manipulated at the same time?

- Now that's alot of assumptions, which will probably make an ass of me.

- Found that this class doesn't support TiledTextureRegions, my bad! Would've been nice though, because AnimatedSprites can be very similar as well, and therefore very redundant.

- Have since formulated my own AnimatedSpriteBatch class using TiledTextureRegion, haven't fully tested yet but seems to work just fine. Kudos again Nic :geek:
While(E)
 
Posts: 155
Joined: Sat Apr 23, 2011 4:04 am

Re: SpriteBatch -> 2x performance improvement anyone?

Postby Nicolas Gramlich » Sun Jun 26, 2011 11:21 pm

HI,

While(E) wrote:Love the idea of this class, but is there an efficient way to use it with AnimatedSprites? The real question is can you individually manipulate the animation (or current tile index) of each of them, such as if you were to initialize the sprite with a clone of the TiledTextureRegion. I haven't tested it yet, but I'm assuming that if it would work with the TiledTextureRegion which I doubt at the moment, then it would act like it doesn't clone but simply assigns and therefore all of the Sprites will be manipulated at the same time?

- Now that's alot of assumptions, which will probably make an ass of me.

SpriteBatch still requires you to clone the TextureRegions of TiledSprites/AnimatedSprites.

While(E) wrote:- Found that this class doesn't support TiledTextureRegions, my bad! Would've been nice though, because AnimatedSprites can be very similar as well, and therefore very redundant.

OOps :D Changeset: http://code.google.com/p/andengine/sour ... 5d53dc1969

While(E) wrote:- Have since formulated my own AnimatedSpriteBatch class using TiledTextureRegion, haven't fully tested yet but seems to work just fine. Kudos again Nic :geek:

Note have a look a the SpriteGroup class, which might be already doing what you need!

Best Regards,
Nicolas
Nicolas Gramlich
Site Admin
 
Posts: 1734
Joined: Mon Jun 07, 2010 6:20 pm
Location: Schriesheim, Germany

Re: SpriteBatch -> 2x performance improvement anyone?

Postby djoseph » Thu Jul 07, 2011 8:00 pm

I'm using spritegroup in my game and the performance improvment is 2x times on my G1. Its amazing.

Thanks a lot for this.

Denny
djoseph
 
Posts: 46
Joined: Sat Jun 25, 2011 11:08 pm

Re: SpriteBatch -> 2x performance improvement anyone?

Postby aerobowl » Mon Jul 11, 2011 3:14 am

Nicolas Gramlich wrote:yes, the same approach could be applied to primitives, pretty much with the same code, excluding where TextureRegions are used.


if to apply on primitives, do we need to create our own class?

sorry as i still quite new with android programming
aerobowl
 
Posts: 7
Joined: Tue Feb 08, 2011 3:29 am

Re: SpriteBatch -> 2x performance improvement anyone?

Postby dironto » Mon Jul 11, 2011 11:34 am

Hi,

Yes you need a new class. If you want a SpriteRectangleBatch for example, you get almost the smae as the SpriteBatch, except that you use remove everything that does something with textures.
Regards,
Ronald
dironto
 
Posts: 65
Joined: Mon May 23, 2011 12:24 am
Location: Amsterdam, The Netherlands

Re: SpriteBatch -> 2x performance improvement anyone?

Postby tomjr » Wed Jul 20, 2011 10:37 pm

Nicolas Gramlich wrote:Note have a look a the SpriteGroup class, which might be already doing what you need!


In my game, Sprites will be added to SpriteGroup at runtime (after SpriteGroup is attached to Scene). That causes NullPointerException on onDrawSpriteBatch() because SpriteGroup has surely no children yet. Is it a bug or I just suck? :(
Anyway, I had another (very similar :D ) SpriteGroup just to make it work in my case.
TomJr

Myth of Pirates Link
Panda Jump Link
Zombie Age Link
Cosmos vs Invaders Link
tomjr
 
Posts: 15
Joined: Wed Jul 20, 2011 7:00 pm

Re: SpriteBatch -> 2x performance improvement anyone?

Postby Nicolas Gramlich » Mon Aug 01, 2011 11:29 pm

Hi,
tomjr wrote:
Nicolas Gramlich wrote:Note have a look a the SpriteGroup class, which might be already doing what you need!


In my game, Sprites will be added to SpriteGroup at runtime (after SpriteGroup is attached to Scene). That causes NullPointerException on onDrawSpriteBatch() because SpriteGroup has surely no children yet. Is it a bug or I just suck? :(
Anyway, I had another (very similar :D ) SpriteGroup just to make it work in my case.

I added a check if the children are null a couple of days ago.

Best Regards,
Nicolas
Nicolas Gramlich
Site Admin
 
Posts: 1734
Joined: Mon Jun 07, 2010 6:20 pm
Location: Schriesheim, Germany

PreviousNext

Return to Updates

Who is online

Users browsing this forum: No registered users and 4 guests