So once all sprites which reference a texture are destroyed, the
texture will be removed by itself whenever (by the gc)?
To be clear, in these scenarios:

#my object does this
sprite = pyglet.sprite.Sprite(texture)

If I have one single reference to this object and I delete this
reference, the object should be free to be garbage collected. And when
this happens the sprite should be garbage collected. I do not need to
call sprite.delete()

2#My object does this:
sprite = pyglet.sprite.Sprite(texture, batch=batch)

In this case I do need to call sprite.delete() to remove the sprite
from the sprite batch, only then can it be garbage collected.

OR is it more appropriate to do this:

sprite.batch = None

This would remove it from the batch?

On Dec 21, 11:30 pm, Casey Duncan <[email protected]> wrote:
> On Mon, Dec 21, 2009 at 3:24 PM, Jonathan Hartley <[email protected]> wrote:
> > On Dec 21, 1:12 pm, Hello3171 <[email protected]> wrote:
> [..]
> >> How are the lifetimes of sprites, text labels and sprite batches
> >> managed? Do I need to do anything (such as call sprite.delete() ) for
> >> anything?
>
> > I was wondering exactly the same thing, especially since my Sprite
> > images are dynamically generated Textures (derived from Labels to
> > accelerate text rendering) Do I need to call delete on the Texture, if
> > no other Sprites reference it, or just on the Sprite?
>
> Calling delete on the sprite deletes the vertex list and removes the
> reference to the texture from the sprite, but does not explicitly
> delete the texture from video memory because other things may still be
> using it.
>
> Note that if nothing else is referencing the texture, it will
> eventually get removed from video memory when the texture object is
> garbage collected. This is probably fine unless you know you need to
> reclaim the video memory immediately for other uses. In that case you
> should call delete on the texture yourself.
>
> -Casey

--

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