On Fri, Apr 11, 2008 at 5:27 PM, Alex Holkner <[EMAIL PROTECTED]> wrote: > I haven't looked at your code yet, but anything that creates Text > objects regularly can probably be optimised by creating a fixed number > of Text objects, and updating the text and style of each only when > appropriate.
I feel like an idiot. But my code runs great now! I was creating a Text object for each _line_ of my "log viewer" object, and then each time a new log line came in or whenever the log window was moved I was destroying all the Text objects and recreating all new ones in new positions. Funny that my brain-dead implementation ran so great under pyglet 1.0... I didn't realize that Text objects could be modified after creation! My new implementation: 1) Now uses text.Label objects. 2) Updates the .x and .y attributes when the window is moved [*1] 3) Uses _one_ label object for the whole log window 4) Updates the text of the existing label object when a new log line comes in. [*2] Now, instead of seeing the fps drop to near-zero whenever a log line comes in or the window is moved, there's nearly no performance impact to either operation! Not to mention that my code's quite a bit simpler. *1. Do I need to do label.begin_update() and label.end_update() when I change label.x and label.y? I'm not, currently, and it seems to work fine. *2. I am doing begin_update() and end_update() around text changes. ~ Nathan --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
