The format for the string versions of array functions is the same as for
a C array. That is, it's the internal format of the array (not how you
would write it in a C program). For instance, the point (1.0, 2.0, 3.0)
would be represented as:
(with \x00 meaning a byte with the value (hexidecimal) 0, \x08 being a
byte with character number 8, etceteras)
(I didn't figure that out on my own by the way, I used the struct
module). You _could_ convert your data to that format by using the
struct module, but it's a lot of work to go through when the other
functions will do the conversions for you.
So, how do you use those functions? Well, here's an example:
'''Test of the glDrawArrays function'''
from OpenGLContext import testingcontext
BaseContext, MainFunction = testingcontext.getInteractive()
from OpenGL.GL import *
from Numeric import array
data = [
class TestContext( BaseContext):
def Render( self, mode = 0):
BaseContext.Render( self, mode )
glVertexPointerd( data )
glNormalPointerf([ (0,0,1)]*4 )
glDrawArrays(GL_QUADS, 0, len(data))
if __name__ == "__main__":
MainFunction ( TestContext)
That's taken from the OpenGLContext/tests directory (with a simpler set
of data in your format substituted). You can find a lot of sample code
in the tests directory that gives you examples of how to accomplish
Hope that helps,
Frank Raiser wrote:
> On Sun, Jan 06, 2002 at 11:13:24AM -0600, Tarn Weisner Burton wrote:
>>All the PyOpenGL functions are documented in merged man pages at
>>Although the only the prototypes for the decorated functions
>>(glVertexPointerf, etc.) are given in the man pages, they are described
>>in more detail in the user's manual. This documentation is also
>>distributed with 2.0, with the exception of the merged man pages which
>>will be included in the next version.
> I've checked these but couldn't really get anything new from it.
>>In short, glVertexPointer is like the C function in that it takes a
>>Python string and it respects the stride arguments (in the future it may
>>use the buffer protocol also), whereas glVertexPointerf uses a Python
>>array (or Numeric) and doesn't need stride arguments.
> How exactly does the string have to look like?
> I tried having a list vertices =  and calling vertices.extend([x,y,z])
> for each vertex, then did a repr(vertices)[1:-1].replace(',','') to get
> a string of successive "x1 y1 z1 x2 y2 z2.." vertices, but that didn't
> work at all with glVertexPointer.
>>Sorry, haven't figured out the INVALID_OPERATION problem yet.
> :( This is giving me a headache as I just can't get any more info out. I
> don't know what to check, why it is invalid.. nothing.
> Thanks for your help,
Mike C. Fletcher