7 changed files with 121 additions and 121 deletions
@ -1,26 +1,26 @@ |
|||
#include "CrossSource.h" |
|||
|
|||
CrossSource::CrossSource() { |
|||
name = "Cross FBO Source"; |
|||
allocate(500, 500); |
|||
CrossSource::CrossSource(){ |
|||
name = "Cross FBO Source"; |
|||
allocate(500, 500); |
|||
} |
|||
|
|||
void CrossSource::draw() { |
|||
ofClear(0); |
|||
ofSetColor(255, 255, 0, 255); |
|||
ofRect(0, 0, getWidth(), getHeight()); |
|||
|
|||
ofSetColor(0, 0, 0, 255); |
|||
ofSetLineWidth(5); |
|||
|
|||
float y = sin( float(ofGetFrameNum()) / 10.0f ) * 100.0f; |
|||
|
|||
ofPoint startPoint = ofPoint(10, y); |
|||
ofPoint endPoint = ofPoint(getWidth() - 10, getHeight() - y); |
|||
ofLine(startPoint, endPoint); |
|||
|
|||
float tempY = startPoint.y; |
|||
startPoint.y = endPoint.y; |
|||
endPoint.y = tempY; |
|||
ofLine(startPoint, endPoint); |
|||
void CrossSource::draw(){ |
|||
ofClear(0); |
|||
ofSetColor(255, 255, 0, 255); |
|||
ofRect(0, 0, getWidth(), getHeight()); |
|||
|
|||
ofSetColor(0, 0, 0, 255); |
|||
ofSetLineWidth(5); |
|||
|
|||
float y = sin(float(ofGetFrameNum()) / 10.0f) * 100.0f; |
|||
|
|||
ofPoint startPoint = ofPoint(10, y); |
|||
ofPoint endPoint = ofPoint(getWidth() - 10, getHeight() - y); |
|||
ofLine(startPoint, endPoint); |
|||
|
|||
float tempY = startPoint.y; |
|||
startPoint.y = endPoint.y; |
|||
endPoint.y = tempY; |
|||
ofLine(startPoint, endPoint); |
|||
} |
@ -1,42 +1,42 @@ |
|||
#include "CustomSource.h" |
|||
|
|||
CustomSource::CustomSource() { |
|||
// Give our source a decent name
|
|||
name = "Custom FBO Source"; |
|||
|
|||
// Allocate our FBO source, decide how big it should be
|
|||
allocate(500, 500); |
|||
|
|||
// 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++) { |
|||
rects.push_back(ofRectangle(0, |
|||
ofRandom(fbo->getHeight()), |
|||
fbo->getWidth(), |
|||
ofRandom(20))); |
|||
rectSpeeds.push_back((1.0f + ofRandom(5))); |
|||
} |
|||
CustomSource::CustomSource(){ |
|||
// Give our source a decent name
|
|||
name = "Custom FBO Source"; |
|||
|
|||
// Allocate our FBO source, decide how big it should be
|
|||
allocate(500, 500); |
|||
|
|||
// 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++){ |
|||
rects.push_back(ofRectangle(0, |
|||
ofRandom(fbo->getHeight()), |
|||
fbo->getWidth(), |
|||
ofRandom(20))); |
|||
rectSpeeds.push_back((1.0f + ofRandom(5))); |
|||
} |
|||
} |
|||
|
|||
// Don't do any drawing here
|
|||
void CustomSource::update() { |
|||
// Move rects
|
|||
for (int i = 0; i < rects.size(); i++) { |
|||
rects[i].y += rectSpeeds[i]; |
|||
if (rects[i].y > fbo->getHeight()) { |
|||
rects[i].y = -rects[i].getHeight(); |
|||
} |
|||
} |
|||
void CustomSource::update(){ |
|||
// Move rects
|
|||
for(int i = 0; i < rects.size(); i++){ |
|||
rects[i].y += rectSpeeds[i]; |
|||
if(rects[i].y > fbo->getHeight()){ |
|||
rects[i].y = -rects[i].getHeight(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
// No need to take care of fbo.begin() and fbo.end() here.
|
|||
// All within draw() is being rendered into fbo;
|
|||
void CustomSource::draw() { |
|||
// Fill FBO with our rects
|
|||
ofClear(0); |
|||
//ofBackground(0);
|
|||
ofSetColor(255); |
|||
for (int i = 0; i < rects.size(); i++) { |
|||
ofRect(rects[i]); |
|||
} |
|||
void CustomSource::draw(){ |
|||
// Fill FBO with our rects
|
|||
ofClear(0); |
|||
//ofBackground(0);
|
|||
ofSetColor(255); |
|||
for(int i = 0; i < rects.size(); i++){ |
|||
ofRect(rects[i]); |
|||
} |
|||
} |
@ -1,26 +1,26 @@ |
|||
#include "ofApp.h" |
|||
|
|||
void ofApp::setup() { |
|||
ofBackground(0); |
|||
|
|||
// Enable or disable audio for video sources globally
|
|||
// Set this to false to save resources on the Raspberry Pi
|
|||
ofx::piMapper::VideoSource::enableAudio = false; |
|||
|
|||
// Add our CustomSource to list of fbo sources of the piMapper
|
|||
// FBO sources should be added before piMapper.setup() so the
|
|||
// piMapper is able to load the source if it is assigned to
|
|||
// a surface in XML settings.
|
|||
crossSource = new CrossSource(); |
|||
customSource = new CustomSource(); |
|||
piMapper.registerFboSource(*crossSource); |
|||
piMapper.registerFboSource(*customSource); |
|||
piMapper.setup(); |
|||
|
|||
// The info layer is hidden by default, press <i> to toggle
|
|||
// piMapper.showInfo();
|
|||
void ofApp::setup(){ |
|||
ofBackground(0); |
|||
|
|||
// Enable or disable audio for video sources globally
|
|||
// Set this to false to save resources on the Raspberry Pi
|
|||
ofx::piMapper::VideoSource::enableAudio = false; |
|||
|
|||
// Add our CustomSource to list of fbo sources of the piMapper
|
|||
// FBO sources should be added before piMapper.setup() so the
|
|||
// piMapper is able to load the source if it is assigned to
|
|||
// a surface in XML settings.
|
|||
crossSource = new CrossSource(); |
|||
customSource = new CustomSource(); |
|||
piMapper.registerFboSource(*crossSource); |
|||
piMapper.registerFboSource(*customSource); |
|||
piMapper.setup(); |
|||
|
|||
// The info layer is hidden by default, press <i> to toggle
|
|||
// piMapper.showInfo();
|
|||
} |
|||
|
|||
void ofApp::draw() { |
|||
piMapper.draw(); |
|||
void ofApp::draw(){ |
|||
piMapper.draw(); |
|||
} |
Loading…
Reference in new issue