PyOpenGL glVertexPointer trouble

TheDustbustr thedustbustr at aol.com
Wed May 7 20:49:26 EDT 2003


In order to figure out how to use glVertexPointer and glDrawElements, I'm
trying to set up a simple colored quad.  The glVertex3f equivalent code is
here:

         #drawcube
         glBegin(GL_QUADS)
         glColor3f(1,0,0); glVertex3f(0,0,0)
         glColor3f(1,0,1); glVertex3f(1,0,0)
         glColor3f(0,0,1); glVertex3f(1,1,0)
         glColor3f(0,1,1); glVertex3f(0,1,0)
         glEnd()

I want to port this to glVertexPointer code.  Here is what I have so far:

        glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
        glEnableClientState(GL_VERTEX_ARRAY)
        glEnableClientState(GL_COLOR_ARRAY)
        glMatrixMode(GL_MODELVIEW)
        glPushMatrix()
        glLoadIdentity()
        #glColor3f(1,1,1)
        VertexArray=[[0,0,0],[1,0,0],[1,1,0],[0,1,0]]
        #ColorArray=[[1,0,0],[1,0,1],[0,0,1],[0,1,1]]
        ColorArray=[0xFF0000, 0xFF00FF, 0x0000FF, 0x00FFFF]
        #indicelist=array('I',[0,1,2,3])
        indicelist=[0,1,2,3]
        glVertexPointer(3, GL_FLOAT, 0, VertexArray)
        glDrawElements(GL_QUADS, len(indicelist), GL_UNSIGNED_BYTE, indicelist)
        glPopMatrix()
        glFlush()
        glDisableClientState(GL_VERTEX_ARRAY)
        glDisableClientState(GL_COLOR_ARRAY)

This doesn't work... What am I doing wrong?  I have tried variations to this
code, end results have been PyGame "parachuting", PyGame segfaulting, or
nothing being displayed at all.  The glVertex3f code works exactly as expected.




More information about the Python-list mailing list