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: Select all
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| //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);
|
| 17 lines; 2 keywds; 7 nums; 50 ops; 0 strs; 3 coms Syntactic Coloring v0.4 - Dan East |
And an example on how to create a rendertexture, linked to the renderbuffer:
- Code: Select all
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| 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);
|
| 18 lines; 7 keywds; 10 nums; 76 ops; 0 strs; 0 coms Syntactic Coloring v0.4 - Dan East |
And finally how to set/clear this texture as a rendertexture:
- Code: Select all
1 2 3 4 5 6 7 8 9
| //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);
|
| 9 lines; 4 keywds; 9 nums; 28 ops; 0 strs; 2 coms Syntactic Coloring v0.4 - Dan East |