I'd like to efficiently capture a "screenshot" of my OpenGL ES iPhone game. I put screenshot in quotes because I really want to move the screen contents into a pixel buffer that I can eventually use to create a mov file using AVFoundation.
Currently I'm taking the screenshot with this method from Apple. The resulting image is great... however capturing the image causes a small stutter in my game. Looks like the call to glReadPixels
causes the stutter.
How can I capture the screen's contents more efficiently? Perhaps I can improve the efficiency of the call to glReadPixels
? Or perhaps I can populate a CMSampleBuffer or CVPixelBuffer without calling glReadPixels?
Perhaps the OpenGL ES data could be accessed directly somehow w/o having to copy the data into a buffer via glReadPixels
.
Edit #1: Perhaps a "Frame Buffer Object" could be useful? Or "rendering directly to a texture"?
ReadPixels
: Have the next frame rendered after be the frame that would have been rendered next. Your game will run slow but now you'll capture the right ones. \$\endgroup\$