On Sun, Oct 4, 2009 at 5:04 PM, Joe Wreschnig <[email protected]>wrote:

>
> Hi,
>
> I'd like to be able to replace the image data in something that came
> from pyglet.resource.image when the on-disk file changes. I have the
> inotify/Windows file notify callbacks all working, and set up so that
> the next time you pyglet.resource.image that file, it knows to not
> used the cached version. However, I'd like to also retroactively apply
> the new image data to the object it handed back previously. Since the
> new image might be a different size, I can't just blit over the old
> one.
>
> Is there any way to do this with stock pyglet image/texture instances,
> or do I have to resort to some kind of proxy object hackery?
>
>


a naive first approach would be to do (psedocode)

def mycallback(fname):
   texture = get_texture_for_fname() # if using resources thats easy
   texture.delete()
   set_texture_for_fname(fname) # probably easy if using resources

But, a second look point to the really big problem: if the texture is used
in a batch, the batch's draw_list must need regeneration. So, a texture
would need references to all batchs where it is used.

I think you need to approach this at higher level than pyglet, something
like:

class Actor(...):
   ...
    def cbak_media_change(self,...):
        # reload the texture, as in naive approach
        ...
       # take care of propagating changes; like batch's draw_list
regeneration
       ...

--
claudio

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