[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 |