booglybob / pyglet

Automatically exported from code.google.com/p/pyglet
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Create a BatchableElement class #272

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
There are 3 kinds of items that can be added to a batch. and at least
sprites and labels that have a different way of dealing with getting added
to a batch and group.

i think it could be a good idea to have a batchable that can suppport
assignement and re assignment to different batches or groups. also, the
ability to remove the vertex_list from a batch without destroying it.

In this way i can create new kind of things that can be added or removed
from the current batch in an uniform way, just subclassing from this. also,
sprite label and textlaout should inherit from this.

also, i usually dont know the batch ill add the element when im creating
it. so having a None batch and being able to define it later would be nice.

reasonable?

Original issue reported on code.google.com by lucio.to...@gmail.com on 17 Apr 2008 at 9:18

GoogleCodeExporter commented 8 years ago
I actually tried to create something like this and wasn't able to 
satisfactorily.  An
element can't create its vertex lists until it has a batch (or knows that it 
won't
get one).  Migrating vertex lists from one batch or group to another is 
hideously
expensive (by design -- this was never intended to be an important use-case), 
which
is why only Sprite currently supports it.

Is it really so hard to create the batch first, and then add elements to it?  
Doing
it the other way around requires either a two-stage construction process (first
construct the object, then add it to the batch and create its vertex lists), or 
a
migration or recreation of vertex lists.

If you have a patch that implements this I'd be very interested to see it.  
I'll keep
this request in mind, but I don't think it will make it into pyglet 1.1, as 
it's not
trivial (and, IMO, not necessary once you adapt to a certain style of writing).

Original comment by Alex.Hol...@gmail.com on 17 Apr 2008 at 2:29

GoogleCodeExporter commented 8 years ago

Original comment by Alex.Hol...@gmail.com on 17 Apr 2008 at 2:30

GoogleCodeExporter commented 8 years ago
Its not that creating the batch is hard, its just not the way i want to do it. 
In
cocos you create an object and then add it to a layer or sprite or scene or a
batchnode. if the object you add to is a batchnode(or descendant), the added 
abjects
batch and group elements are set so that z-order is respected and composition 
also (a
batchnode, with a sprite that has a sprite.. etc).

having to have the batch in hand before creating the nodes makes it very 
different as
how everything else is created and managed. it also makes you hand manage all 
the
groups stuff that now its set up automatically.

the way i can implement it is doing a two phase creation as you said, but of a 
cocos
element, that creates a new label when it needs one. but i was hoping people 
could
still use pyglets interfaces for drawing.

Original comment by lucio.to...@gmail.com on 17 Apr 2008 at 9:18