|
|
@ -1,6 +1,6 @@ |
|
|
|
#include "CustomSource.h" |
|
|
|
|
|
|
|
CustomSource::CustomSource() { |
|
|
|
CustomSource::CustomSource(){ |
|
|
|
// Give our source a decent name
|
|
|
|
name = "Custom FBO Source"; |
|
|
|
|
|
|
@ -9,7 +9,7 @@ CustomSource::CustomSource() { |
|
|
|
|
|
|
|
// Genereate rects to be rendered into the FBO
|
|
|
|
int numRects = 20; // change this to add more or less rects
|
|
|
|
for (int i = 0; i < numRects; i++) { |
|
|
|
for(int i = 0; i < numRects; i++){ |
|
|
|
rects.push_back(ofRectangle(0, |
|
|
|
ofRandom(fbo->getHeight()), |
|
|
|
fbo->getWidth(), |
|
|
@ -19,11 +19,11 @@ CustomSource::CustomSource() { |
|
|
|
} |
|
|
|
|
|
|
|
// Don't do any drawing here
|
|
|
|
void CustomSource::update() { |
|
|
|
void CustomSource::update(){ |
|
|
|
// Move rects
|
|
|
|
for (int i = 0; i < rects.size(); i++) { |
|
|
|
for(int i = 0; i < rects.size(); i++){ |
|
|
|
rects[i].y += rectSpeeds[i]; |
|
|
|
if (rects[i].y > fbo->getHeight()) { |
|
|
|
if(rects[i].y > fbo->getHeight()){ |
|
|
|
rects[i].y = -rects[i].getHeight(); |
|
|
|
} |
|
|
|
} |
|
|
@ -31,12 +31,12 @@ void CustomSource::update() { |
|
|
|
|
|
|
|
// No need to take care of fbo.begin() and fbo.end() here.
|
|
|
|
// All within draw() is being rendered into fbo;
|
|
|
|
void CustomSource::draw() { |
|
|
|
void CustomSource::draw(){ |
|
|
|
// Fill FBO with our rects
|
|
|
|
ofClear(0); |
|
|
|
//ofBackground(0);
|
|
|
|
ofSetColor(255); |
|
|
|
for (int i = 0; i < rects.size(); i++) { |
|
|
|
for(int i = 0; i < rects.size(); i++){ |
|
|
|
ofRect(rects[i]); |
|
|
|
} |
|
|
|
} |