Hey Josh,
As far as I understand it, the Batch is a group of domains that get drawn
together, or consolidated when possible. Also, it appears that there is
always a default batch, even if you don't explicitly create your own. The
additional code needed for Batch support was actually quite minimal
(assuming I didn't miss anything). In pyglet/graphics/__init__.py, I made
the following changes:
1. Added a new *Batch.add_ordered* method, underneith *Batch.add* and
*Batch.add_indexed*.
2. Modified *Batch._get_domain* so that it can create/return the
OrderedVertexDomain when requested.
3. Tweaked a few of the methods and the domain cache with an additional
*ordered=True* parameter, just like for *indexed=True*.
I accidentally left a *print("new domain")* in there, which illustrates the
consolidation that happens when the Sprites share the same TextureAtlas.
There is a bit more work to do in OrderedVertexDomain, such as the
migration code. Also, deleting vertex_lists probably won't work because of
the *OrderedVertexDomain._vertex_lists*.
On Monday, November 21, 2016 at 8:22:07 AM UTC+9, Josh wrote:
>
> Hi Ben,
>
> I like this solution for staying with the original API. Tested it with
> ordered groups and it still performs correctly. I'm missing a couple pieces
> in terms of how it works with batches, though. I can't find the code change
> that actually causes Batch to use OrderedVertexDomain - can you point me to
> it?
>
> On Saturday, November 19, 2016 at 8:30:59 AM UTC-6, Benjamin Moran wrote:
>>
>> Hi Josh,
>>
>> I took your work and ran with it a little, to see if it could be fit into
>> the existing api. So far, It seems to be going OK, but I would greatly
>> appreciate your feedback on this. I'm just kinda winging it here :)
>> You can find my "ordered_sprite" branch here:
>> https://bitbucket.org/treehousegames/pyglet/branch/ordered_sprite
>>
>> First of all, I implemented an OrderedVertexDomain which is a copy of
>> your OrderedDomain. The main difference is that it has it's own
>> vertex_lists list, and sorting method. It also has it's own "create"
>> method, which monkey patches an "order" attribute on the vertex_list, for
>> use by the sorting method. There is a simple "self.dirty" attribute that
>> determines if the vertex_lists list should be sorted automatically before
>> the next draw.
>>
>> By pushing all of that down the stack into the vertexdomain, The Sprite
>> and SpriteGroup classes could be left almost original. The only addition
>> being a "depth" property on the Sprite class which updates the vertex list
>> order attribute, and sets the domain to "dirty" so that it will be sorted
>> before the next draw.
>>
>> As for requiring all sprites to be on the same TextureAtlas for blending
>> to work correctly, that is still a requirement (no way around this in
>> OpenGL). However, it's up to the user to ensure this part. It would be
>> "automatic" if using the pyglet.resource module. If the user doesn't use a
>> single atlas, everything will still work fine - but of course sorting won't
>> work because they will be in different domains.
>>
>> I haven't tested any of it yet, but I think animations and such will work
>> fine since it's using the existing Groups and such.
>>
>> -Ben
>>
>>
>>
>> On Friday, November 18, 2016 at 5:46:52 AM UTC+9, Josh wrote:
>>>
>>> Hi Ben,
>>>
>>> There's no roadblock with migrating OrderedDomains, it's just something
>>> I skipped for now (similar to animation support). It will require going
>>> deeper into the weeds with pyglet's allocation system, and there are some
>>> aspects of that I still don't understand.
>>>
>>> Best,
>>>
>>> Josh
>>>
>>
--
You received this message because you are subscribed to the Google Groups
"pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.