Thread: [PyOpenGL-Users] Missing VBO function
Brought to you by:
mcfletch
From: Roland E. <r.e...@gm...> - 2010-07-15 13:46:24
|
Hi, I am currently trying to use VBOs, but it seems that pyOpenGL 3.0.1 is lacking the functions glGenVertexArrays(), glBindVertexArray() and I suppose glDeleteVertexArray(). Below is the error I get: NameError: global name 'glGenVertexArrays' is not defined According to the OpenGL Programming Guide (the red book) seventh edition and some document I found on the official site of OpenGL, those functions exists since OpenGL 3.0. The basic question is, does pyOpenGL 3.0.1 belongs to OpenGL 3.0 or not? If yes, could it be related to the implementation for my platform or my graphics hardware? If not, to which version of OpenGL does pyOpenGL 3.0.1 belongs? Regards, Roland. |
From: Alejandro S. <as...@gm...> - 2010-07-15 15:56:26
|
Hi Roland, I don't know precisely about those specific 3.0 functions, but in my code I'm using glGenBuffers, glBindBuffer and glBufferData to populate my VBO's (PyOpenGL version 3.0.1b). I think these are core in OpenGL 2.0. Alejandro.- On Thu, Jul 15, 2010 at 10:37 AM, Roland Everaert <r.e...@gm...>wrote: > Hi, > > > I am currently trying to use VBOs, but it seems that pyOpenGL 3.0.1 is > lacking the functions glGenVertexArrays(), glBindVertexArray() and I > suppose glDeleteVertexArray(). > > Below is the error I get: > > NameError: global name 'glGenVertexArrays' is not defined > > > According to the OpenGL Programming Guide (the red book) seventh edition > and some document I found on the official site of OpenGL, those > functions exists since OpenGL 3.0. > > The basic question is, does pyOpenGL 3.0.1 belongs to OpenGL 3.0 or not? > > If yes, could it be related to the implementation for my platform or my > graphics hardware? > > If not, to which version of OpenGL does pyOpenGL 3.0.1 belongs? > > > Regards, > > > Roland. > > > ------------------------------------------------------------------------------ > 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 > PyO...@li... > https://lists.sourceforge.net/lists/listinfo/pyopengl-users > -- Alejandro Segovia Azapian Director, Algorithmia: Visualization & Acceleration http://web.algorithmia.net |
From: Roland E. <r.e...@gm...> - 2010-07-15 18:47:25
|
I am also using glGenBuffers and stuff, but glGenVertexArray and co. are supposed to allow to save the states of the vertex so I have not to call glVertexPointer and other vertex array related function for every frame. Another thing, with glBindBuffer(), if I use a constant like the one defined in the documentation, python doesn't know it, I have to postfix them with _ARB? Below is an example: glBindBuffer(GL_ARRAY_BUFFER_ARB, self.buffers[0]) Could it be that with my hardware this is an extension? Regards, Roland. Le 07/15/10 17:56, Alejandro Segovia a écrit : > Hi Roland, > > I don't know precisely about those specific 3.0 functions, but in my > code I'm using glGenBuffers, glBindBuffer and glBufferData to populate > my VBO's (PyOpenGL version 3.0.1b). I think these are core in OpenGL 2.0. > > Alejandro.- > > On Thu, Jul 15, 2010 at 10:37 AM, Roland Everaert > <r.e...@gm... <mailto:r.e...@gm...>> wrote: > > Hi, > > > I am currently trying to use VBOs, but it seems that pyOpenGL 3.0.1 is > lacking the functions glGenVertexArrays(), glBindVertexArray() and I > suppose glDeleteVertexArray(). > > Below is the error I get: > > NameError: global name 'glGenVertexArrays' is not defined > > > According to the OpenGL Programming Guide (the red book) seventh > edition > and some document I found on the official site of OpenGL, those > functions exists since OpenGL 3.0. > > The basic question is, does pyOpenGL 3.0.1 belongs to OpenGL 3.0 > or not? > > If yes, could it be related to the implementation for my platform > or my > graphics hardware? > > If not, to which version of OpenGL does pyOpenGL 3.0.1 belongs? > > > Regards, > > > Roland. > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by Sprint > What will you do first with EVO, the first 4G phone? > Visit sprint.com/first <http://sprint.com/first> -- > http://p.sf.net/sfu/sprint-com-first > _______________________________________________ > PyOpenGL Homepage > http://pyopengl.sourceforge.net > _______________________________________________ > PyOpenGL-Users mailing list > PyO...@li... > <mailto:PyO...@li...> > https://lists.sourceforge.net/lists/listinfo/pyopengl-users > > > > > -- > Alejandro Segovia Azapian > Director, Algorithmia: Visualization & Acceleration > http://web.algorithmia.net |
From: Ian M. <geo...@gm...> - 2010-07-15 20:37:37
|
Hi, Again, I recommend the array class for VBOs. It handles everything for you and is exceedingly easy to use. from OpenGL.arrays import vbo ... vertex_buffer_object = vbo.VBO(np.array(vertices,"f"),usage='GL_STATIC_DRAW') ... glVertexPointerf(vertex_buffer_object) Ian |
From: Roland E. <r.e...@gm...> - 2010-07-16 13:20:07
|
Ok, but is there any documentation about it, I was not able to found one on the pyopengl web site and I do not find a lot of complete example of its usage :( Roland. Le 07/15/10 22:37, Ian Mallett a écrit : > Hi, > > Again, I recommend the array class for VBOs. It handles everything > for you and is exceedingly easy to use. > > from OpenGL.arrays import vbo > ... > vertex_buffer_object = > vbo.VBO(np.array(vertices,"f"),usage='GL_STATIC_DRAW') > ... > glVertexPointerf(vertex_buffer_object) > > Ian |
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 |
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 |
From: Ian M. <geo...@gm...> - 2010-07-18 18:12:04
|
Hi, As long as the only thing you're doing is VBO and array drawing, I *think*it should be all right. If you do anything else, it might not work properly. Best practice is just to include it. Ian |
From: Gijs <in...@bs...> - 2010-07-18 20:10:38
|
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 > PyO...@li... > https://lists.sourceforge.net/lists/listinfo/pyopengl-users > |
From: Roland E. <r.e...@gm...> - 2010-07-18 21:29:18
|
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 >> PyO...@li... >> https://lists.sourceforge.net/lists/listinfo/pyopengl-users >> |