On Mon, Apr 14, 2008 at 6:06 PM, Alex Holkner <[EMAIL PROTECTED]> wrote:
>  > 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.
>
>  No, as x and y do not affect layout.
>
>
>  >  *2. I am doing begin_update() and end_update() around text changes.
>
>  Sounds good.  The purpose of these methods is just to suspend relayout
>  (which is quite expensive) while you make changes to more than one
>  layout-affecting property (such as text, font, style, width).
>
>  If you find yourself needing better performance, consider using
>  IncrementalTextLayout, which knows how to only layout the minimal
>  amount of text necessary after an update, compared to
>  Label/TextLayout, which re-lays-out the entire text after any change.

Wow.  You're always several steps ahead of me.  I will most likely
switch to IncrementalTextLayout the next time I have to revisit the
log-viewing code.  It appears that this would give me an easy way of
allowing the user to scroll back up the log window!

>  Does this completely fix the twisted+pyglet1.1 problem?

Yes, as far as I can tell my problems were entirely due to Text-object
creation performance differences in 1.0 and 1.1.

~ 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to