Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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"?

share|improve this question
    
Look into pixel buffer objects. Alternatively, create a mode for your game which does not conflict with the additional load on the bus imposed by 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. –  Steven Lu Feb 11 '12 at 11:52

2 Answers 2

Frame Buffer Object allows to create a texture where you can draw. That is Render To Texture. It is very fast (no use of CPU) and useful for mirror effects or post 2D effects. But it is a gpu object so you can access to its content with CPU; you need glReadPixels if you want to use it on CPU. the main advantage is you can set your size. So you can create a small FBO for a good framerate.

share|improve this answer

FBO is a lot faster than glReadPixels.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.