Re: [PyOpenGL-Users] Having a problem with glBufferData
Brought to you by:
mcfletch
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 > > |