Thread: [PyOpenGL-Users] Having a problem with glBufferData
Brought to you by:
mcfletch
From: Gijs <in...@bs...> - 2009-08-30 20:18:26
|
Hey List, I'm trying to use PBOs for the first time so I'm not completely aware of what I'm doing with the code I found on this site <http://www.mathematik.uni-dortmund.de/%7Egoeddeke/gpgpu/tutorial3.html>. One thing I do know is that the code I can execute in C, I cannot execute in Python. This has to do with a piece of code that makes use of glBufferData and its 4th argument, namely "size". The C code: glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, thebuffer); glBufferData(GL_PIXEL_PACK_BUFFER_ARB,4*sizeof(float), NULL, GL_STREAM_READ); glReadPixels (0, 0, 1, 1, GL_RGBA, GL_FLOAT, 0); void* mem = glMapBuffer(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY); assert(mem); glUnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB); glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 0); Python Code: glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, thebuffer) glBufferData(GL_PIXEL_PACK_BUFFER_ARB,None, GL_STREAM_READ) glReadPixels (0, 0, 1, 1, GL_RGBA, GL_FLOAT, 0) mem = glMapBuffer(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY) glUnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB) glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 0) Since I cannot specify 4 arguments for glBufferData, as I can do in C, the code I execute in Python is doing something different than the C version. This results in an OpenGL error 1282 (invalid operation) when I call glReadPixels. I guess when the interface for this function was written, it was never expected to be called like this. A normal call would supply a variable, and PyOpenGL would be able to determine the size, so the size argument wouldn't be needed. Too bad in a case like this, it is needed, as far as I can see. Or is there some other way of accessing this function? Regards, Gijs |
From: Mike C. F. <mcf...@vr...> - 2009-09-01 19:25:22
|
Gijs wrote: > Hey List, > > I'm trying to use PBOs for the first time so I'm not completely aware > of what I'm doing with the code I found on this site > <http://www.mathematik.uni-dortmund.de/%7Egoeddeke/gpgpu/tutorial3.html>. > One thing I do know is that the code I can execute in C, I cannot > execute in Python. This has to do with a piece of code that makes use > of glBufferData and its 4th argument, namely "size". This looks like a real API failing in the wrapper. Basically I didn't realize that passing in a NULL with a real size was valid when I did that wrapper, now even if I didn't I likely wouldn't have wrapped it quite that way (i.e. I would have made a wrapper that allowed passing size or not, instead of always taking size from the array). Will have to rework the function's wrapper to allow passing in size explicitly. Thanks for pointing out the problem, Mike -- ________________________________________________ Mike C. Fletcher Designer, VR Plumber, Coder http://www.vrplumber.com http://blog.vrplumber.com |
From: Mike C. F. <mcf...@vr...> - 2009-09-11 18:03:55
|
Mike C. Fletcher wrote: > Gijs wrote: > >> Hey List, >> >> I'm trying to use PBOs for the first time so I'm not completely aware >> of what I'm doing with the code I found on this site >> <http://www.mathematik.uni-dortmund.de/%7Egoeddeke/gpgpu/tutorial3.html>. >> One thing I do know is that the code I can execute in C, I cannot >> execute in Python. This has to do with a piece of code that makes use >> of glBufferData and its 4th argument, namely "size". >> > This looks like a real API failing in the wrapper. Basically I didn't > realize that passing in a NULL with a real size was valid when I did > that wrapper, now even if I didn't I likely wouldn't have wrapped it > quite that way (i.e. I would have made a wrapper that allowed passing > size or not, instead of always taking size from the array). Will have > to rework the function's wrapper to allow passing in size explicitly. > > Thanks for pointing out the problem, > Mike > I've finally got the fix for this published on PyPI. (i.e. a new alpha release of PyOpenGL is up) Take care, Mike -- ________________________________________________ Mike C. Fletcher Designer, VR Plumber, Coder http://www.vrplumber.com http://blog.vrplumber.com |
From: Gijs <in...@bs...> - 2009-09-11 21:31:05
|
On 11-9-2009 20:03, Mike C. Fletcher wrote: > Mike C. Fletcher wrote: > >> Gijs wrote: >> >> >>> Hey List, >>> >>> I'm trying to use PBOs for the first time so I'm not completely aware >>> of what I'm doing with the code I found on this site >>> <http://www.mathematik.uni-dortmund.de/%7Egoeddeke/gpgpu/tutorial3.html>. >>> One thing I do know is that the code I can execute in C, I cannot >>> execute in Python. This has to do with a piece of code that makes use >>> of glBufferData and its 4th argument, namely "size". >>> >>> >> This looks like a real API failing in the wrapper. Basically I didn't >> realize that passing in a NULL with a real size was valid when I did >> that wrapper, now even if I didn't I likely wouldn't have wrapped it >> quite that way (i.e. I would have made a wrapper that allowed passing >> size or not, instead of always taking size from the array). Will have >> to rework the function's wrapper to allow passing in size explicitly. >> >> Thanks for pointing out the problem, >> Mike >> >> > I've finally got the fix for this published on PyPI. (i.e. a new alpha > release of PyOpenGL is up) > > Take care, > Mike > > Great, thanks for the fix, Gijs |
From: René D. <re...@gm...> - 2009-09-04 08:38:15
|
Hi, remember that you can use the OpenGL.raw.GL calls... which are more direct wrappers. Sometimes easier to use if you have a bug/can't figure out how to use the normal python wrappers. Of course then you need to know ctypes... but that's not too hard. cheers, On Sun, Aug 30, 2009 at 9:18 PM, Gijs<in...@bs...> wrote: > Hey List, > > I'm trying to use PBOs for the first time so I'm not completely aware of > what I'm doing with the code I found on this site. One thing I do know is > that the code I can execute in C, I cannot execute in Python. This has to do > with a piece of code that makes use of glBufferData and its 4th argument, > namely "size". > > The C code: > glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, thebuffer); > glBufferData(GL_PIXEL_PACK_BUFFER_ARB,4*sizeof(float), NULL, > GL_STREAM_READ); > glReadPixels (0, 0, 1, 1, GL_RGBA, GL_FLOAT, 0); > void* mem = glMapBuffer(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY); > assert(mem); > glUnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB); > glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 0); > > Python Code: > glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, thebuffer) > glBufferData(GL_PIXEL_PACK_BUFFER_ARB,None, GL_STREAM_READ) > glReadPixels (0, 0, 1, 1, GL_RGBA, GL_FLOAT, 0) > mem = glMapBuffer(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY) > glUnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB) > glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 0) > > Since I cannot specify 4 arguments for glBufferData, as I can do in C, the > code I execute in Python is doing something different than the C version. > This results in an OpenGL error 1282 (invalid operation) when I call > glReadPixels. I guess when the interface for this function was written, it > was never expected to be called like this. A normal call would supply a > variable, and PyOpenGL would be able to determine the size, so the size > argument wouldn't be needed. Too bad in a case like this, it is needed, as > far as I can see. Or is there some other way of accessing this function? > > Regards, Gijs > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus > on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > PyOpenGL Homepage > http://pyopengl.sourceforge.net > _______________________________________________ > PyOpenGL-Users mailing list > PyO...@li... > https://lists.sourceforge.net/lists/listinfo/pyopengl-users > > |