Hello Robert,

I do not claim to be a master either, however, I did have a hard time setting up VBOs in PyOpenGL without using the provided VBO class.

In the end, what worked for me was to convert my arrays to numpy.array and then using PyOpenGL's AbstractDatatype class to pass the data in as a void *.

Maybe something similar could work for you:

from OpenGL import *
from OpenGL.arrays import ArrayDatatype as ADT

...

vertices = numpy.array(generate_vertex_list(), numpy.float32)
glEnableClientState(GL_VERTEX_ARRAY)
glVertexPointer(3, GL_FLOAT, ADT.voidDataPointer(vertices))

Hope this helps!

Alejandro.-

On Sat, May 1, 2010 at 5:57 AM, Leo Hourvitz <leovitch@gmail.com> wrote:
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()
        glEnableClientState(GL_VERTEX_ARRAY)
        glVertexPointer(3,GL_FLOAT,0,self._vertexPositionStr)

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

Leo

 

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

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)
   glEnableClientState(GL_VERTEX_ARRAY)
   glVertexPointer(2, GL_FLOAT, 0, vertices)
   glDrawArrays(GL_TRIANGLES, 0, 3)
   glDisableClientState(GL_VERTEX_ARRAY)

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


------------------------------------------------------------------------------
_______________________________________________
PyOpenGL Homepage
http://pyopengl.sourceforge.net
_______________________________________________
PyOpenGL-Users mailing list
PyOpenGL-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyopengl-users


------------------------------------------------------------------------------


_______________________________________________
PyOpenGL Homepage
http://pyopengl.sourceforge.net
_______________________________________________
PyOpenGL-Users mailing list
PyOpenGL-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyopengl-users




--
Alejandro Segovia Azapian
Director, Algorithmia: Visualization & Acceleration
http://web.algorithmia.net