On 20/09/2007, at 10:36 AM, fccoelho wrote:
> > Hi Alex, > > I am Using Pyglet to browse (interactively) the contents of an Object > database such as ZODB. Cool! Be great if you can post a screenshot/link when it's going. > Since it is impracticable to send you the > database, I am sending you a script that, shows the problem, which > seems to be related to assigning long strings to text objects. > > I understand that this problem may not necessarily be minimizable, > since pyglet is not meant to be a text editor. Thanks, that demonstrates the problem fine. The performance problem stems from (as you guessed) assigning a long string to the Text object. When you do this, it needs to do a non-trivial amount of work to re-layout the text... moreso if you have enabled word- wrapping (which you have, by specifying a width). Luckily, your case should be very simple to optimise... * At the moment you're not actually getting any word-wrapping behaviour because there are no spaces in the data. If this is not just an artifact of the example program you've given, leave out the width= keyword so it knows not to bother trying to wordwrap. * Very few of the 160,000 characters you are asking pyglet to layout will actually be visible, unless you have a gigantic monitor the world has never seen. See if you can trim this down to a reasonable size before assigning it. * If you don't want to preemptively trim the string, you could subclass Text and implement some clipping so that layout stops when the known window size is exceeded. * In this example, you're changing the text every frame. I can't imagine any use-case in which this will actually be useful... layout is performed lazily only when text is changed, so if your data only changes every 100ms or more, most frames can be drawn quickly without having to re-layout the text. Check out the clock.schedule_interval function for a possibly-useful hook for this. If you're still unhappy with this performance, consider writing your own layout procedure. There are many optimisations you could make based on the specific nature of what you're doing (for example, using a monospaced font would speed things up, or knowing the word breaks in advance). If you find that you get layout done quickly but due to the amount of text you're rendering performance is still sub-optimal, wrap the Text in a GL display list, or subclass and use vertex buffer objects (this is on my TODO... eventually) instead of system memory arrays. One final note from your code which you may already have been aware of: the clock.set_fps_limit() has no effect unless you're calling clock.tick() every frame. Good luck Alex. (BTW, no need for the "newbie" tag in subject line, we're all newbies here with pyglet, by definition, including me!) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
