Ok, I honestly don't have a deep enough knowledge of cocos/pyglet/openGL, but I managed to get my batches to do what I ask of them (respect the z-order I want), by changing the usage of pyglet Group to OrderedGroup : the only change I made is this, in batch.BatchableNode :
def set_batch(self, batch, groups=None, z=0):
self.batch = batch
if batch is None:
self.group = None
else:
group = groups.get(z)
if group is None:
import pyglet
group = pyglet.graphics.OrderedGroup(z) # this is the only line I changed
groups[z] = group
self.group = group
for childZ, child in self.children:
child.set_batch(self.batch, groups, z + childZ)
It seems that it used to be OrderedGroups, but this changed in
r807, and every commit made since that time was for licence and such... I really don't know if this change will create some other problems, some performance troubles or anything, all I know is that it's currently doing the job for my current needs.