On 9/11/08, josch <[EMAIL PROTECTED]> wrote:
>
> On Sep 10, 5:33 pm, "Alex Holkner" <[EMAIL PROTECTED]> wrote:
>
> > On 9/11/08, josch <[EMAIL PROTECTED]> wrote:
> > Use the texture target and id from the region returned by
> > resource.image. For images on a shared texture atlas (common case
> > with small images), the target and id will be the same. You can
> > safely create multiple TextureGroup's with the same target and id --
> > Batch will know that they can be grouped together efficiently if your
> > TextureGroup class correctly implements __eq__ and __hash__.
>
>
> i did this first as i saw that resource.image also returned a simple
> TextureRegion.
> I also observed that the target and id will stay the same for the
> first tiles and will change as more are added and new textures have to
> be created.
> My problem which i still do not fully understand is that when i now
> load a lot of tiles and new textures with something like this:
> images = [pyglet.roucource.image("/data/tiles/%d.png"%i) for i in
> xrange(100)]
> maybe this code will create several different Textures so that not all
> of the TextureRegions returned do have the same target and id.
> then i will create a group with a texture passed to it - or two groups
> because two textures where needed to store those images? where do i
> know that from?
> when i then do batch.add() i have to specify ONE group and this group
> will only update one texture so i kind of have to know which images i
> can group together depending on in which texture they where put by
> resource.image.
Use one group for every image, if you like. Batch will know how to
merge them back together.
> do i have to get this info manually by iterating over the created
> TextureRegions and finding out how many Textures where needed?
> you mentioned i should use several TextureGroups but this would imply
> that i do have to call batch.add() several times for each group that i
> create, right? i would then start creating one group per image loaded
> and doing a batch.add() for each image separately.
> but isnt it better to add as many vertices as possible in one
> batch.add() ?
Nope, once it's in the batch, if the groups are compatible (according
to their __eq__ and __hash__ methods), it doesn't matter how many
vertex lists were created with Batch.add; they all end up in the same
vertex domain.
Alex.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pyglet-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pyglet-users?hl=en
-~----------~----~----~----~------~----~------~--~---