@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_RGBAtoGL_RGBfrom 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