Thanks for the quick reply!

After some stupid errors (on my part), I finally got this to work
(using the first method). It's a little slow (as you suggested), but
it'll do until I have time to dabble with the ImageData stuff.

Thanks again,
-Tony

On Dec 4, 5:10 pm, "Alex Holkner" <[EMAIL PROTECTED]> 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.
>
> > With pygame, I iterated through my array and used
> >     pygame.surface.fill(color, (x, y, w, h))
> > to fill squares (with dimensions `w` by `h`, at location `x`, `y`)
> > with a color corresponding to the value of my array. I could also have
> > used pygame.surfarray to directly display my array (after converting
> > from numpy to Numeric).
>
> > I haven't been able to figure out how to get something like this to
> > work in pyglet. I apologize if this is a stupid question. I've tried
> > searching the forums and looking through the documentation, but I
> > haven't found anything similar.
>
> All graphics with pyglet are drawn using OpenGL.  One way to draw rectangles 
> is:
>
> from pyglet.gl import *
> glColor3f(1, 0, 0) # red
> glRectf(x, y, x+w, y+h)
>
> 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.
>
> If you've never used OpenGL before this task is going to give you a
> steep learning curve -- you may want to skim some of the many
> tutorials around on the net first.
>
> You could also take a look 
> athttp://groups.google.com/group/pyglet-users/web/2d-drawing-primitives...,
> which provides some simple drawing primitives without needing to know
> OpenGL.
>
> Cheers
> 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