Widget Creation Order

Littorio

21-08-2010 14:09:28

In my game i have to display 4 different images over each enemy.
I Use a Canvas where i create the StaticImages and display them.
If i create the images in this order
for (...) {create_image1();create_image2();create_image3();create_image4();}
the batch count go really high

if instead i create them in this order
for (...) create_image1();
for (...) create_image2();
for (...) create_image3();
for (...) create_image4();
the batch count barely increase

I have tried to sort the mWidgetChild vector of the canvas afterward but it has no effect.
There is something to do to allow the creation in of static images in random order without performance loss?

my.name

23-08-2010 09:12:14

show code and screen shot.

Altren

23-08-2010 17:00:23

When you create widgets with one texture (same image) they can be rendered in one batch only when there's no other widgets between them.
So in first case you have 1 batch for each create_image*() call. In second case you have 4 batches, because same images batch together in one operation.

Littorio

26-08-2010 14:05:24

Where is stored the order of rendering of the widgets? There is a way to sort the widgets after their creation?

my.name

27-08-2010 09:22:19

Widgets aren't sorted

Littorio

28-08-2010 16:38:58

Yes they aren't sorted. That's why i'm asking where is stored the order of rendering so i can see what it is possible to do.