Problem saving iOS image & alpha in FBO

I’m having this problem with using alpha and an FBO when I’m trying to save an image (larger than screen size) into my iOS documents directory.

If I leave the fbo without an internalformat (or using GL_RGBA) it saves an image, however the objects inside the fbo with alpha (the second circle in this case) seem to subtract from the fbo making it more and more transparent and losing any color information.

Using GL_RGB however seems to fix this issue on osx which saves fine with GL_RGB. However on iOS it now displays properly but is just saving a black image.

I’m on iOS 8.4 and OF 0.9.0.
Can anyone see what I’m doing wrong I’d be very grateful, thanks a lot

void ofApp::setup()
{
    fbo.allocate(ofGetWidth()*2, ofGetHeight()*2, GL_RGB); // works with GL_RGBA
}

void ofApp::draw()
{
    fbo.begin();
    
    if(noBG){
        ofSetColor(20, 255);
        ofDrawRectangle(0,0, ofGetWidth()*2, ofGetHeight()*2);
        noBG = false;
    }
    
    ofSetBackgroundAuto(false);
    ofPoint pos = ofPoint(ofGetMouseX()*2, ofGetMouseY()*2);
    
    ofFill();
    ofSetColor(255);
    ofDrawCircle(pos, 10);
    
    ofSetColor(ofRandom(255),ofRandom(50),ofRandom(255),5); //this Alpha is giving the trouble
    ofDrawCircle(pos, 500);
    
    fbo.end();
    
    fbo.draw(0, 0, ofGetWidth(), ofGetHeight());
    
}

void ofApp::touchDoubleTap(ofTouchEventArgs & touch){
    ofPixels pixels;
    fbo.readToPixels(pixels);
    ofSaveImage(pixels, ofxiOSGetDocumentsDirectory() +ofGetTimestampString() + "_image.png");
    noBG = true;
}

Hm … not sure. @julapy any ideas?

I’m having the exact same problem that I’m battling with… Has anyone come up with a solution to this?

I don’t think OpenGL ES supports GL_RGB. I am not sure what format you are trying to save into the Photo Library but if it expects an RGB image your issue may lie in the exporting of the FBO to the format.

I tried saving in both jpeg and png formats… No dice. I was able to make it work with what I needed by not initializing a type on the FBO and was able to save properly as a jpg. I didn’t need it to have alpha on save, so it did what I needed. I had thought that an FBO initializes with GL_RGB by default anyway… guess not since it worked by not declaring that??