It makes perfectly sens.
Thank you,
Roland.
Le 07/18/10 22:10, Gijs a écrit :
> 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 :)
> Kind regards,
> Gijs
>
>
> 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
>> 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
>>
>>
>> ------------------------------------------------------------------------------
>> 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 Homepage
>> http://pyopengl.sourceforge.net
>> _______________________________________________
>> PyOpenGL-Users mailing list
>> PyOpenGL-Users@...
>> https://lists.sourceforge.net/lists/listinfo/pyopengl-users
>>
|