After hacking around a bit, I came up with this attempt:

  buffer = fleet[0]._vertex_list.domain.attribute_names['vertices'].buffer
  vertices = ctypes.cast(buffer.data_ptr, POINTER(ctypes.c_int))

And sure enough, vertices contains the points. However, writing to them
turns out to be "pointless" because batch.draw recalculates them. And
in any case it's rather abusive code relying on hidden implementation.

However, this points me in the right direction. Really I should just
forget about using high level Sprite objects and just use textures
directly instead. My computational shared library can process the
vertex array. It will be quite instantaneous since it is CUDA.


On 09/09/2010 06:37 PM, KenSeehart wrote:
> I know how to use arrays to control batches of points and lines and
> stuff. But how do I control a batch of sprites with an array?
>
> The telemetry of the sprites will be updated in a high speed shared
> library via ctypes, which will write to an array of x,y coordinates,
> compatible with a pyglet.graphics.vertex_list.
>
> My specific goal is to avoid O(n) iteration of python code for about
> 2000 sprites, so writing a python loop to copy the position data into
> the sprite objects is not fast enough, and shouldn't be necessary.
>
> In other words, I'd like to bind a vertex_list (or any kind of flat
> array) to a batch of sprites.
>
> Thanks,
>
> Ken
>
>


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