I'm new to OpenGL ES. I'm trying to write code for screen recording of iOS apps, especially games.
I'm using the 'render to texture' method described with code in this answer to capture screen and write the video for a cocos2d game.
One modification I made was that, when I call CVOpenGLESTextureCacheCreate
then I'm using
[EAGLContext currentContext]
instead of
[[GPUImageOpenGLESContext sharedImageProcessingOpenGLESContext] context]
It does record the video but there are two issues
(1)- When it starts recording then new drawing on the screen stops. I want the app to keep on drawing on the screen too. As I'm new to OpenGL ES, I don't have deep understanding of frame buffer objects etc., so I have a hard time figuring out how to simultaneously draw on screen and capture the screen as well. I'll appreciate a code example in this regard.
(2)- The recorded video is flipped upside down. How can I get it in correct direction?
Previously I considered glReadPixels
method too, but that has performance drawbacks.
Update: a couple of ideas also came to mind. According to my little understanding,
I could simply draw my texture back to screen, but don't know how.
OR
I could have a secondary FBO and I could attach the texture to it, i.e.
glGenFramebuffersOES(1, &textureFrameBuffer);
glBindFramebufferOES(GL_FRAMEBUFFER_OES, textureFrameBuffer);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, CVOpenGLESTextureGetName(renderTexture), 0);
//Then I restore the screen FBO.
glBindFramebufferOES(GL_FRAMEBUFFER_OES, 1);
But if I do that, then how do I copy the screen-drawing to my secondary FBO?