On 5/27/08, gzy <[EMAIL PROTECTED]> wrote: > > I managed to get gldrawelements in a similiar fashion: > > > self.cverts = ascontiguousarray(self.vertarray) > > self.indices = array(range(4*40), dtype=int32) > self.cindices = ascontiguousarray(self.indices) > #glDrawArrays(GL_QUADS,0,4*50) > > glDrawElements(GL_QUADS, len(self.indices), GL_UNSIGNED_INT, > self.cindices.ctypes.data_as(ctypes.POINTER(ctypes.c_int)) ) > > > this works, and now I would like to try vbo's, but that can wait. > this get's ugly pretty soon and it seams this is the kind of tasks > pyglet should help with. > I'm using pyglet.graphics.draw_indexed now, but probably pyglet must > parse my lists at each frame. > > Could someone point me to some examples of using for example an > IndexedVertexList? > I imagine I could create it once, and just call it's draw() method. > > To drag the numpy thread a bit more: > What is the suggested approach to dealing with flattening lists? I > want my vertices as an array of arrays so I can use > all the vector operations on them, at the same time pyglet want's a > flat list. > If reshape it for the VertexList creation, can I reshape it back and > modify it's .vertices property without breaking anything?
If the array is contiguous, then yes. The reshape functions return arrays that share the same underlying data in this case, so you don't need to continually reshape it for pyglet and then for yourself, just once during initialisation. If you're really serious about using numpy with pyglet.graphics, your best bet is probably to subclass pyglet.graphics.vertexbuffer.AbstractBuffer to use a numpy array as the underlying storage (anything else, and you will need to always copy data into pyglet's internal array or the VBO). If done correctly, the rest of the pyglet.graphics abstractions should fit over this numpy array/buffer without modification (I think). Hooking your subclassed buffer into the Batch as the default class may require a little hacking (I can provide hooks for this in future releases if it turns out to be useful). 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 -~----------~----~----~----~------~----~------~--~---
