glReadPixels for realtime video encoding

Dear Panda3d ninjas,

I’m using a video streaming rendering module that needs to read the ogl screen buffer via glReadPixels. I was wondering which is the best place to intercept Panda’s rendering loop in order to get a copy of the video buffer.

Thanks,
–Omar

You can add a draw callback, for instance on the DisplayRegion, which allows your own code to be called after the frame has been drawn. See this thread for more.

Of course, Panda already provides a mechanism to extract the frame data each frame via glReadPixels (or the equivalent DirectX call), using the render-to-texture mechanism. But if you are interfacing with a library that expects to make the glReadPixels call itself, then you will have to use the clumsier callback mechanism.

David

Thanks David,

That thread was very helpful.

Have a problem nonetheless. I modified the example showed in the thread by adding pyoengl’s glreadpixels to the display’s callback. Sadly, the program exits giving a “Segmentation fault” error.

Any ideas?.

Have you tried examining the stack traceback with gdb? That should provide some insight.

David

I’m using the Python APIs, so I imported PyOpenGL to call glReadPixels. Didn’t work this way.

Didn’t use gdb to see what was going on but I did something else. I created an extension module using Swig/C++. I put the opengl code there, and guess what?. It did work!

Look like a bizarre PyOpengl/Panda3d compatibility issue to me.