Re: [PyOpenGL-Users] Missing VBO function
Brought to you by:
mcfletch
From: Ian M. <geo...@gm...> - 2010-07-16 18:48:19
|
That *was* a complete example of how to use the functions :-) Here, I've added enough surrounding code to be self-explanatory. #Import it: from OpenGL.arrays import vbo import numpy as np ... #Create a vertex buffer object vertices = [ [0,0,0],[0,1,0],[1,0,0], [2,0,0],[0,3,0],[4,9,6], [7,8,1],...] vertex_buffer_object = vbo.VBO(np.array(vertices,"f"),usage='GL_STATIC_DRAW') ... #Draw VBO glEnableClientState(GL_VERTEX_ARRAY); glVertexPointerf(vertex_buffer_object) glDrawArrays(GL_TRIANGLES,0,len(vertices)/3) glDisableClientState(GL_VERTEX_ARRAY); glBindBuffer(GL_ARRAY_BUFFER,0) Normal, and texture VBOs work very similarly. Vertex attribute VBOs require you to specify a shader, but you'll only need those for things like normal mapping, etc. If you need more explanation, try: http://pyopengl.sourceforge.net/context/tutorials/shader_1.xhtml, or Google: "from OpenGL.arrays import vbo". My implementation is here: http://www.pygame.org/project-glLib+Reloaded-1326-.html, in glLib/glLibObjects.py (class glLibObject) but it's probably too convoluted for a tutorial. Ian |