Skip to content

Instantly share code, notes, and snippets.

@tgfrerer
Created January 31, 2015 01:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tgfrerer/94a1e0443a8a62866019 to your computer and use it in GitHub Desktop.
Save tgfrerer/94a1e0443a8a62866019 to your computer and use it in GitHub Desktop.
test project for #3598
#include "ofMain.h"
class ofApp : public ofBaseApp{
public:
ofFbo mFbo;
ofFbo mFbo1;
ofFbo mFbo2;
void setup(){
// ofDisableArbTex();
ofSetSphereResolution(3);
ofFbo::Settings settings;
settings.numSamples = 4;
settings.numColorbuffers = 3;
settings.internalformat = GL_RGBA;
settings.textureTarget = GL_TEXTURE_2D;
settings.width = 256;
settings.height = 256;
mFbo.allocate(settings);
settings.numSamples = 0;
mFbo1.allocate(settings);
settings.numSamples = 16;
mFbo2.allocate(settings);
}
//--------------------------------------------------------------
void drawScene(){
glEnable(GL_MULTISAMPLE);
ofNoFill();
ofPushMatrix();
ofTranslate(128,128,0);
ofRotate(360 * (ofGetFrameNum() % 720) / 720.);
ofDrawSphere(100);
ofPopMatrix();
ofFill();
glDisable(GL_MULTISAMPLE);
}
void renderFbo(ofFbo& fbo_){
vector<int> db;
db.push_back(1);
db.push_back(2);
fbo_.begin();
fbo_.setActiveDrawBuffer(0);
ofClear(ofColor::black);
ofSetColor(ofColor::white);
drawScene();
fbo_.setActiveDrawBuffers(db);
ofClear(ofColor::green);
ofSetColor(ofColor::red);
drawScene();
fbo_.setActiveDrawBuffer(2);
ofClear(ofColor::blue);
ofSetColor(ofColor::red);
drawScene();
fbo_.end();
}
//--------------------------------------------------------------
void draw(){
renderFbo(mFbo);
renderFbo(mFbo1);
renderFbo(mFbo2);
ofSetColor(ofColor::white);
mFbo.getTexture(0).draw(20, 20);
mFbo.getTexture(1).draw(20, 20 + 256);
mFbo.getTexture(2).draw(20, 20 + 256 + 256);
mFbo1.getTexture(0).draw(20+256, 20);
mFbo1.getTexture(1).draw(20+256, 20 + 256);
mFbo1.getTexture(2).draw(20+256, 20 + 256 + 256);
mFbo2.getTexture(0).draw(20+256 * 2, 20);
mFbo2.getTexture(1).draw(20+256 * 2, 20 + 256);
mFbo2.getTexture(2).draw(20+256 * 2, 20 + 256 + 256);
}
};
//========================================================================
int main( ){
ofGLWindowSettings settings;
settings.position = ofVec2f(1000,500);
settings.width = 850;
settings.height = 850;
settings.setGLVersion(4,2);
ofCreateWindow(settings);
// this kicks off the running of my app
// can be OF_WINDOW or OF_FULLSCREEN
// pass in width and height too:
ofRunApp(new ofApp());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment