Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting default frame buffer id from GLKView/GLKit

I use GLkit/GLKView in my IOS OpenGL ES 2.0 project to manage default FBO/life cycle of my app.

In desktop OpenGL in order to bind default FBO (the front buffer) I can just call glBindFrameBuffer(GL_FRAMEBUFFER,0) but this is not the case in IOS app since you have to create the default FBO yourself and it will have a unique ID;

The problem is GLKit/GLKView coding style force me to use GLKView's "bindDrawable" function to activate default FBO which make the design of my cross platform rendering system a little ugly (have to store GLKView pointer as void* in my c++ engine class and bridge cast it every time I want to perform default FBO binding)

Are there any way to get the default FBO ID that GLKit/GLKView create so that I can store and use it to bind default frame buffer any where in my code ?

At worst I can revert back to create the default FBO myself and dissing GLKit/GLKView but it such a nice framework that I would like to continue using it.

Sorry for my bad english and thank in advance for any reply.

like image 206
xanagan gtx Avatar asked Mar 17 '12 02:03

xanagan gtx


1 Answers

Perhaps you can get the "current" framebuffer ID just after your bindDrawable call, by calling something like:

GLint defaultFBO;
glGetIntegerv(GL_FRAMEBUFFER_BINDING_OES, &defaultFBO);
like image 166
Chris Livdahl Avatar answered Sep 18 '22 15:09

Chris Livdahl