There certainly won't be any memory leak or corruption. This is the
default operation of most, if not all, commands of OpenGL. OpenGL works
like a big giant state-machine. You set something, and it'll stay set
until you change it or you pop/push states/settings. In your case, a
VBO buffer can be bound so that it is made active, and then the
commands that use VBO's will use the binded VBO buffer you've set
before. If you never unset it, then OpenGL will simply assume that you
still want the VBO buffer to be active.
An easier to understand example is when you want to draw a green
triangle for instance. If you need to draw a green triangle, and never
have to draw a different color, then you can simply set the color to be
green before the drawing function. Then call the drawing function, and
the color will remain green throughout the entire drawing function. You
can call the drawing function again and again, without ever having to
set the color to be green. (well, unless you are popping and pushing
states which erases states/settings you've set before).
If you understand this concept, you can make quite efficient code,
since you know you don't have to call certain functions again and
again, simply because they don't (have to) change. And OpenGL usually
doesn't change settings for you. There's only one exception to this
afaik. When you make an FBO active, it replaces the current settings
with the settings of the FBO you made active. Not all of your settings,
but the ones that have to do with the colorbuffer and viewport. If
you're not sure what settings are set at a certain point in your code,
you can get the settings with functions like glGetBooleanv,
glGetDoublev, glGetFloatv, glGetIntegerv.
Hope this helps and makes some sense :)
On 18-7-2010 19:16, Roland Everaert wrote:
Thanks after a few try and error I was able to convert my code to use
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?
Le 07/16/10 20:48, Ian Mallett a écrit :
That was a complete example of how to use the
Here, I've added enough surrounding code to be self-explanatory.
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],
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,
Google: "from OpenGL.arrays import vbo". My implementation is here: http://www.pygame.org/project-glLib+Reloaded-1326-.html,
glLib/glLibObjects.py (class glLibObject) but it's probably too
convoluted for a tutorial.
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
PyOpenGL-Users mailing list