How to specify buffer offset with PyOpenGL

What is the PyOpenGL equivalent

#define BUFFER_OFFSET(i) (reinterpret_cast<void*>(i)) glDrawElements(GL_TRIANGLE_STRIP, count, GL_UNSIGNED_SHORT, BUFFER_OFFSET(offset)) 

If the offset is 0, then

 glDrawElements(GL_TRIANGLE_STRIP, count, GL_UNSIGNED_SHORT, None) 

works, but I can't figure out how to specify a nonzero offset in the buffer object.

+4
source share
2 answers

You must pass a void ctypes pointer that can be created with

 ctypes.c_void_p(offset) 

It seems that there is a more specific PyOpenGL parameter using the VBO class, and obtained with some versions of PyOpenGL according to this .

+6
source

You can use the OpenGL.arrays.vbo.VBO class to do this:

 from OpenGL.arrays import vbo # data for your buffer buf = vbo.VBO( [ 1,2,3,4,5,...], target = GL_ELEMENT_ARRAY_BUFFER ) # calls glBindBuffer buf.bind() # starts reading at 14-th byte glDrawElements(GL_TRIANGLE_STRIP, count, GL_UNSIGNED_SHORT, buf + 14) 
+6
source

All Articles