Quantcast
Channel: bugs, errors - openFrameworks
Viewing all articles
Browse latest Browse all 636

Can't copy ofFbo to ofImage when allocate with GL_RGB on iOS

$
0
0

@cuinjune wrote:

If I allocate ofFbo with GL_RGBA, I can successfully copy the FBO to ofImage. But if I use GL_RGB instead, I could not properly copy FBO to ofImage.

Here's my simple test code.

in ofApp.h

ofFbo fbo;
ofImage img;

in ofApp.cpp

//--------------------------------------------------------------
void ofApp::setup(){

    ofSetBackgroundColor(0);

    //allocate an image space
    img.allocate(ofGetWidth(), ofGetHeight(), OF_IMAGE_COLOR);

    //allocate the fbo
    fbo.allocate(ofGetWidth(), ofGetHeight(), GL_RGBA);

    //draw an ellipse to the fbo
    fbo.begin();
    ofClear(0,0,0,0);
    ofSetColor(255);
    ofDrawEllipse(ofGetWidth()/2, ofGetHeight()/2, ofGetWidth(), ofGetHeight());
    fbo.end();

    //copy pixels from fbo to image
    ofPixels pixels;
    fbo.readToPixels(pixels);
    img.setFromPixels(pixels);
}

//--------------------------------------------------------------
void ofApp::update(){

}

//--------------------------------------------------------------
void ofApp::draw(){

    //draw the image
    img.draw(0, 0, ofGetWidth(), ofGetHeight());
}

If I run the code, the white ellipse appears on the black background.

But if I change GL_RGBA to GL_RGB from the code and run it, I no longer see the white ellipse but only the black background.

Does any one know why it happens and how to fix this?
Thanks in advance!!

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 636

Trending Articles