Debugging glDrawElements in PyOpenGL

This page documents problems with using glDrawElements with PyOpenGL, with vertex data allocated in C. This comes in the form if an underlying C shared library (pgltGeom), an C OpenGL program for reference that uses the library, and a Python PyOpenGL that uses the ctypes-wrapped vesion of the library, and which currently doesn't work.

The underlying "pgltGeom" library comes from one .c and one .h file:

Here's how I'm making it into a shared library on mac:
gcc -c pgltGeom.c -o pgltGeom.o 
gcc -dynamiclib -o libpgltGeom.dylib pgltGeom.o

I used ctypeslib to automatically generate a ctypes wrapper around the shared library, then did some hand-editing:

The first few lines of this will likely have to be edited in order for "import pgltGeom" to work without problems.

I wrote a stand-alone C program to demonstrate use of the library:

Here's how I compiled this into an executable on a mac
gcc -framework GLUT -framework OpenGL -framework Cocoa \
  -L. -lpgltGeom pgltDemo.c -o pgltDemo
The program draws some curving tube geometry in two different ways, without vertex arrays on a yellow background, and with vertex arrays on a white background. For example:

Here's a very literal python version of the same C program, which works okay to draw the geometry without vertex arrays, but has problems when trying to use vertex arrays.