14

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.

xanagan gtx
  • 143
  • 1
  • 4

3 Answers3

24

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);
Chris Livdahl
  • 4,662
  • 2
  • 38
  • 33
0

The answer that is given is definitely the proper solution, however it does not address the error in your understanding of the conceptual difference between standard openGL and openGL for embedded systems. //----------------------------------------------- I feel it's necessary to point out here that the call to glBindFramebuffer(GL_FRAMEBUFFER, 0) does not return rendering to the main framebuffer although it would appear to be so for machines that run Windows, Unix(Mac) or Linux. Desktops and laptops have no concept of a main default system framebuffer. This idea started with handheld devices. When you make an openGL bind call with zero as the parameter then what you are doing is setting this function to NULL. It's how you disable this function. It's the same with glBindTexture(GL_TEXTURE_2D, 0); It is possible that on some handheld devices that the driver automatically activates the main system framebuffer when you set the framebuffer to NULL without activating another. This would be a choice made by the manufacturer and is not something that you should count on, this is not part of the openGL ES spec. For desktops and laptops, this is absolutely necessary since disabling the framebuffer is required to return to normal openGL rendering. But remember! this is not a return to any main framebuffer, you are shutting down the activated frame buffer.

0

The proper way to bind default framebuffer in GLKit is to call bindDrawable method on GLKview.

[self bindDrawable] or [myglkview bindDrawable] depending on the context.

grisevg
  • 250
  • 3
  • 18