Re: [PyOpenGL-Users] VBO question
Brought to you by:
mcfletch
From: Henry G. <he...@ca...> - 2011-06-20 20:02:56
|
On Mon, 2011-06-20 at 12:20 -0700, Jason Hayes wrote: > # send vertices over to the GPU self.vbo_name = glGenBuffersARB( 1 ) > glBindBufferARB( GL_ARRAY_BUFFER_ARB, self.vbo_name ) > glBufferDataARB( GL_ARRAY_BUFFER_ARB, vertices, GL_STATIC_DRAW_ARB ) I'm not an expert, but don't you still need to copy the data to the buffer. I'm not quite sure how you've managed with 3 arguments there though. The docs all suggest you need 4. After that I think you need to do something like (modified from my pbo code, which is all in terms of numpy arrays, which are well laid out in memory): # Map the buffer object to a pointer vbo_pointer = ctypes.cast(\ GL.glMapBuffer(GL.GL_ARRAY_BUFFER, GL.GL_WRITE_ONLY), ctypes.POINTER(ctypes.c_ubyte)) # Turn that pointer into a numpy array that spans # the whole block.(buffer size is the size of your buffer) vbo_array = numpy.ctypeslib.as_array(vbo_pointer, (buffer_size,)) vbo_array[0:data_size_to_copy] = \ data.view(dtype='uint8').ravel() # Unmap the buffer. GL.glUnmapBuffer(GL.GL_ARRAY_BUFFER) Hope that helps. cheers, Henry |