Hi,
You can lock and blit to/from the backbuffer, but not using OpenGL ES isn't recommended (OpenGL ES is faster). Your FPS count will probably be in the 25-30fps range.
If you do use OpenGL ES, your game will be able to run at 60fps. If you want to capture certain parts you've already rendered in OpenGL ES, we recommend using render-to-texture.
An example on how to create and release a renderbuffer:
- Code:
//Create framebuffer and renderbuffer
GLuint fbo, renderbuffer;
unsigned long width = 64, height = 64;
glGenFramebuffersOES(1, &fbo;);
glBindFramebufferOES(GL_FRAMEBUFFER_OES, fbo);
glGenRenderbuffersOES(1, &renderbuffer;);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, renderbuffer);
glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT16_OES, width, height);
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, renderbuffer);
//Restore rendering
glBindFramebufferOES(GL_FRAMEBUFFER_OES, 1);
//Cleanup
glDeleteRenderbuffersOES(1, &renderbuffer;);
glDeleteFramebuffersOES(1, &fbo;);
And an example on how to create a rendertexture, linked to the renderbuffer:
- Code:
unsigned int texid = 0;
GLenum glformat = GL_RGB, gltype = GL_UNSIGNED_BYTE;
glGenTextures(1, &texid;);
if (texid > 0)
{
unsigned long width = 64, height = 64;
glBindFramebufferOES(GL_FRAMEBUFFER_OES, fbo);
glBindTexture(GL_TEXTURE_2D, texid);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, glformat, width, height, 0, glformat, gltype, NULL);
glFramebufferTexture2DOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_TEXTURE_2D, texid, 0);
GLenum status = glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES);
glBindFramebufferOES(GL_FRAMEBUFFER_OES, 1);
if (status != GL_FRAMEBUFFER_COMPLETE_OES)
glDeleteTextures(1, &texid;);
}
return(texid);
And finally how to set/clear this texture as a rendertexture:
- Code:
//Set render texture
unsigned long rendertexwidth = 64, rendertexheight = 64;
glBindFramebufferOES(GL_FRAMEBUFFER_OES, fbo);
glViewport(0, 0, rendertexwidth, rendertexheight);
//Clear render texture
unsigned long displaywidth = 320, displayheight = 480;
glViewport(0, 0, displaywidth, displayheight);
glBindFramebufferOES(GL_FRAMEBUFFER_OES, 1);