Re: [PyOpenGL-Users] Missing VBO function
Brought to you by:
mcfletch
From: Roland E. <r.e...@gm...> - 2010-07-18 17:17:06
|
Thanks after a few try and error I was able to convert my code to use that class. I have anyway a question regarding VBO usage in general. What is the effect of not unbinding a VBO buffer after drawing and calling the drawing process again and again? memory leak? memory corruption? nothing? Thanks, Roland. Le 07/16/10 20:48, Ian Mallett a écrit : > 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 |