On 12/15/07, Andrew Straw <[EMAIL PROTECTED]> wrote:
>
> Alex Holkner wrote:
> > On 12/5/07, Tony <[EMAIL PROTECTED]> wrote:
> >
> >> Hi,
> >>
> >> I just started using pyglet after upgrading to Leopard OS X (before I
> >> was using pygame). I'm trying to display (or animate) the values of a
> >> numpy array (2D), but I haven't been able to figure out how.
> >>
> > A more efficient way to draw the entire array is to copy it into a
> > texture.  Use the pyglet.image.ImageData to create and update the data
> > in a texture, which is then drawn using the blit() method.  If your
> > numpy array is not in a format that ImageData can use, you can use the
> > glTexSubImage2D call directly, with a little more effort.
> >
> It seems a good idea to be able to create an Image without copying the
> data. As far as I can tell from a few minutes of browsing the code, this
> doesn't seem currently possible, as ImageData's _ensure_string_data()
> seems to allocate a new buffer each time. What are the prospects for
> making a code path that takes the raw data buffer, e.g. from numpy's
> my_array.ctypes.data (of course checking that the array properties are
> valid for a direct memory view, such as dimensions, strides, dtype, and
> so on)?
>
> Can you give some hints as to what would be necessary to either A)
> modify ImageData to take a buffer object (or a view of numpy data,
> although this is more specific and less general) or B) create a
> ImageData-like class that would do something similar?

The _ensure_string_data() path is skipped if the data is already in a
format supported by your video card.  Off the top of my head, this
means:

* Positive pitch (image rows are ordered bottom-up)
* Not having the subimage workaround enabled
* A format such as 'RGBA', 'RGB' or perhaps 'BGR', 'BGRA' if you have
the relevant extension.

Alex.

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