SpriteGroup/textexample broken

Bug #1178767 reported by tobs12
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
PyGL3Display
Fix Committed
Medium
David Griffin

Bug Description

~habilain_pygl3display_trunk-r103\pygl3display\examples>c:\Python27\python.exe textexample.py
Traceback (most recent call last):
  File "textexample.py", line 143, in <module>
    demo.run()
  File "~habilain_pygl3display_trunk-r103\pygl3display\
examples\exampleskeleton.py", line 53, in run
    self.init()
  File "textexample.py", line 87, in init
    self.text = self.font.makeString(self.string)
  File "textexample.py", line 60, in makeString
    ret = SpriteGroup(sprites)
  File "c:\Python27\lib\site-packages\pygl3display\sprites\groups.py", line 62,
in __init__
    self.add(container)
  File "c:\Python27\lib\site-packages\pygl3display\sprites\groups.py", line 127,
 in add
    self.addSprite(thing)
  File "c:\Python27\lib\site-packages\pygl3display\sprites\groups.py", line 110,
 in addSprite
    self._spritesByAtlas[spriteAtlas][1].update(sprite._rslots)
TypeError: 'GL3Slots' object is not iterable

Revision history for this message
tobs12 (hans1215) wrote :

Looks like adding iterator access to GL3Slots fixes this:

pygl3display/infrastructure.py:

class GL3Slots(object):
    def __init__(self, slots, indices):
        self.slots = tuple(slots)
        self.indices = indices

    def release(self):
        self.indices.release(self.slots)

    def upload(self, data):
        self.indices.upload(self.slots, data)

+ def __iter__(self):
+ return self.slots.__iter__()

Revision history for this message
David Griffin (habilain) wrote :

I'd go with fixing the dodgy code in spritegroups rather than adding iterator access to GL3Slots, and I've fixed it in my private branch. It will be uploaded in the next revision.

However, one thing of note is that I'm looking at killing off SpriteGroups. Not sure if this will materialise or not, but it could do. The reason is that cameras simply do everything better than SpriteGroups, so it's very hard to justify keeping them.

Revision history for this message
tobs12 (hans1215) wrote :

I just used SpriteGroups to render text as in the text example. I will look in the platformer example to find out how cameras work.

Revision history for this message
David Griffin (habilain) wrote :

Fixed in r104

And realised that SpriteGroups probably won't be killed off, but still: for very large groups of sprites, use Cameras. They're a lot faster, because all computation is done GPU side.

Changed in pygl3display:
status: New → Fix Committed
importance: Undecided → Medium
assignee: nobody → David Griffin (habilain)
Revision history for this message
tobs12 (hans1215) wrote :

I use cameras for the map with lots of sprites. I just took the example to render my own text.

Revision history for this message
tobs12 (hans1215) wrote :

Thanks for the fix. It solves my problem.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.