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;
}