On Sun, Feb 1, 2009 at 5:23 AM, Kipple <[email protected]> wrote: > > I noticed that performance takes a hit when the contents of a single- > line label are changed via set_text. The pyglet ClockDisplay supports > this conclusion, both in my code and in astraea, when the score > changes. > > I googled for "pyglet performance set_text" and found no relevant > results. Has this been brought up before? Is there a different class I > should use for a frequently-changing display?
I assume you mean that set_text takes more time than you would like (not that performance is permanently degraded after calling set_text once). When you call set_text on a Label (or TextLayout that is not IncrementalTextLayout) pyglet recreates all the vertex arrays used by that label, so that subsequent drawing of that label is fast (it's optimised to be fastest for labels that don't change every frame). Recreating the vertex arrays involves re-laying out the text -- converting the unicode string into a sequence of grapheme clusters, looking up an appropriate glyph in the selected font for each cluster, measuring the extents of the glyphs, and finally setting the actual vertex data corresponding to the label. If you have vertex buffer objects enabled (they can be disabled with a debug option) and your hardware supports it, the VBO is also updated immediately. If the new text string contains glyphs that have not been rendered before (e.g., a new character that has not previously been used, or a new font has been selected), these glyphs also need to be created, converted and uploaded to the video card. So, perhaps there is more work involved in calling set_text than you expected. Although it is optimised for the case in which labels don't change every frame (by saving the vertex array that was created for the next time it's drawn), there is probably little or no gain to be made by recreating the vertex array at draw time, rather than during set_text. 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 -~----------~----~----~----~------~----~------~--~---
