ofBackgroundGradient inside an ofFbo

Is this possible? I’m getting artifacts when I try this. Is there another method for doing this?

Thanks,

Yes. Here is a small code example that shows the use of ofBackgroundGradient inside an ofFbo.

ofApp.h

#pragma once

#include "ofMain.h"

class ofApp : public ofBaseApp {

    public:
        void setup();
        void draw();

        ofFbo fbo;
};

ofApp.cpp

#include "ofApp.h"

//--------------------------------------------------------------
void ofApp::setup(){
    fbo.allocate(ofGetWidth(), ofGetHeight(), GL_RGB);
    fbo.begin();
    ofClear(255, 255);
    ofColor colorOne = ofColor(255, 0, 0);
    ofColor colorTwo = ofColor(0, 0, 255);
    ofBackgroundGradient(colorOne, colorTwo, OF_GRADIENT_CIRCULAR);
    fbo.end();
    ofBackground(255, 255);
}

//--------------------------------------------------------------
void ofApp::draw(){
    fbo.draw(mouseX, mouseY, ofGetWidth() / 2, ofGetHeight() / 2);
}
1 Like