booglybob / pyglet

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

Exposing _draw_list_dirty in batch API. #687

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I propose to expose the private attribute _draw_list_dirty of 
pyglet.graphics.Batch with a method, to set _draw_list_dirty = True.

This is the only way to tell batch to re-compute the draw list when the 
ordering of groups was modified, and, currently, the private attribute must be 
set to True from outside Batch (see 
[https://groups.google.com/forum/#!topic/pyglet-users/Z0jnFmc1ydk this topic]; 
Kytten also uses this).

{{{
def re_order(self):
    self._draw_list_dirty = True
}}}

Original issue reported on code.google.com by jorgecar...@gmail.com on 26 Nov 2013 at 4:05

GoogleCodeExporter commented 8 years ago

Original comment by useboxnet on 27 Nov 2013 at 7:27

GoogleCodeExporter commented 8 years ago
I like your idea, but not that much the method name.

We're already using `invalidate` for similar behaviour, do you think we could 
use that instead of `re_order`?

Original comment by useboxnet on 28 Nov 2013 at 5:57

GoogleCodeExporter commented 8 years ago
Yes, we should; re_order was how I idealized for my situation, but the name 
should be consistent with the existing notation.

Original comment by jorgecar...@gmail.com on 28 Nov 2013 at 6:01

GoogleCodeExporter commented 8 years ago
Does this look OK to you?

diff -r f10d6873cdf3 pyglet/graphics/__init__.py
--- a/pyglet/graphics/__init__.py       Sat Nov 16 10:44:59 2013 +0000
+++ b/pyglet/graphics/__init__.py       Thu Nov 28 18:10:22 2013 +0000
@@ -332,6 +332,16 @@
         self._draw_list = []
         self._draw_list_dirty = False

+    def invalidate(self):
+        '''Force the batch to update the draw list.
+
+        This method can be used to force the batch to re-compute the draw list
+        when the ordering of groups has changed.
+
+        :since: pyglet 1.2
+        '''
+        self._draw_list_dirty = True
+
     def add(self, count, mode, group, *data):
         '''Add a vertex list to the batch.

Original comment by useboxnet on 28 Nov 2013 at 6:11

GoogleCodeExporter commented 8 years ago
I think it's great. From my side, is ready for commit.

Original comment by jorgecar...@gmail.com on 28 Nov 2013 at 6:17

GoogleCodeExporter commented 8 years ago
This issue was closed by revision 88a2e9928d5b.

Original comment by useboxnet on 28 Nov 2013 at 6:20

GoogleCodeExporter commented 8 years ago
Thanks a lot for the patch!

Original comment by useboxnet on 28 Nov 2013 at 6:21