I don't claim to be a PyOpenGL master so YMMV, but when I did something similar a few years ago, I had to add a call to tostring() to prepare the array for PyOpenGL.  I was using Numeric at the time, so the relevant code fragments were:

        self.vertexPositions = Numeric.zeros((size*3,3),Numeric.Float32)
        self._vertexPositionStr = self.vertexPositions.tostring()

I haven't actually used this code much in several years though.



On Sat, May 1, 2010 at 4:08 PM, Wakefield, Robert <rjw03002@engr.uconn.edu> wrote:

I've been using PyOpenGL to try to get faster graphics in pygame, and from what I've been able to find online VBOs are the best way to optimize in my case (2D sprites and tiled backgrounds).  However, for some reason they and the vertex arrays they're based on won't work.  In even the simplest example, nothing appears, while the corresponding display list or glBegin/End call works without a hitch.  Am I missing something, or could this be a technical issue?  Any other ideas as to what's wrong?  The code I have in the draw test is listed below (I also tried to generate/bind buffers, to no effect, but I think the problem is the array):

   # shows nothing; also didn't work with GL_INT and integer types or typing in the '.0' for decimal.
   vertices = numpy.array([0,0,  0,128,  128,128], dtype=numpy.float32)
   glVertexPointer(2, GL_FLOAT, 0, vertices)
   glDrawArrays(GL_TRIANGLES, 0, 3)

   # this, however, works fine.  The data points and mode (GL_TRIANGLES) are both identical
   glVertex2f(0.0, 0.0)
   glVertex2f(0.0, 128.0)
   glVertex2f(128.0, 128.0)

PyOpenGL Homepage
PyOpenGL-Users mailing list