ofx 061 > iPhone 3.2: need FBOs (SOLVED)


I’m coding – Xcode 3.2.3 – targeting iOS 3.2 (iPad) using of_preRelease_v0061_iPhone_FAT-pre3.

I need to use FBOs and haven’t found any source that builds cleanly or that runs without crashing at the first allocate.

Which (of the many, as discussed in this forum) fbotexture package should I use?


This is what I’m using for the iPhone. I think the only changes I made to get it building were a few of the OES function/constant names that must have changed at some point.


That did it. Thanks a lot.

:? hm, … i get an EXC_BAD_ACCESS with that version, why ?


No such problem on my side. Can you show us some of your code?

I am getting EXC_BAD_ACCESS as well.

It seems that my phone is having a problem with the isExtensionSupported function. On my 3GS I get nothing returned from glGetString(GL_EXTENSIONS).


returns (null)

The code I am using is a blank empty example with code copy and pasted from the ofxFBO header file. If I just comment out the extension check, and then input every permutation for SupportsFBO/Blit/multi as true/false, I get a blank black screen that I can’t draw to using the following code from the header file:

void testApp::draw(){  
	ofCircle(30, 30, 50);  
myFBO.draw(0, 0, ofGetWidth(), ofGetHeight());  

I remember having this problem when I would declare the fbo instance as stack-based:

ofxFBOTexture fbo;  

What I found was that the constructor for ofxFBOTexture invokes ofxFBOTexture::supportCheck(), which in turn invokes ofxFBOTexture::isExtensionSupported() which in turn invokes the OpenGL API’s glGetString(GL_EXTENSIONS). At that later point, things broke because, it seemed, openGL had not yet been initialized, hence returned nil.

Structural OFX problem or my own sparse understanding of C++ and openGL? I wasn’t sure, but I got around the problem by declaring a heap-based FBO instead:

ofxFBOTexture *fboP;  

and implementing it thus:

fboP = new ofxFBOTexture();  
fboP->allocate(ofGetWidth(), ofGetHeight(), GL_RGBA);  
fboP->clear(0, 0, 0, 0);  

Hope this helps.


thanks Alex. it works!

I don’t know if this is the right thread I should be posting in, but I have a brief followup:

I made a little sketch with a bunch of rotating blocks to test performance downscaling from 640x960 so I could get rid of some jaggies with ofxFBO – it seems I get a 20-40% fps increase by putting the code that draws to the FBO in update() and just the code to draw the FBO in draw().


void update(){  
//..move blocks around..//  
//..draw stuff..//  
void draw(){  

I know the update and draw loops are separate for a reason but is this still *bad practice* with an FBO?

attached is an image from CPU Instrument, that process there takes about 3 times as much CPU power when fbo->begin/end is in the draw() loop.

![](http://forum.openframeworks.cc/uploads/default/864/Screen shot 2010-08-17 at 5.52.38 PM.png)