Browse Source

Change example code style using ofStyler

master
Krisjanis Rijnieks 10 years ago
parent
commit
6962935612
  1. 6
      example/src/CrossSource.cpp
  2. 14
      example/src/CustomSource.cpp
  3. 4
      example/src/CustomSource.h
  4. 18
      example/src/main.cpp
  5. 4
      example/src/ofApp.cpp
  6. 0
      example/src/ofApp.h

6
example/src/CrossSource.cpp

@ -1,11 +1,11 @@
#include "CrossSource.h" #include "CrossSource.h"
CrossSource::CrossSource() { CrossSource::CrossSource(){
name = "Cross FBO Source"; name = "Cross FBO Source";
allocate(500, 500); allocate(500, 500);
} }
void CrossSource::draw() { void CrossSource::draw(){
ofClear(0); ofClear(0);
ofSetColor(255, 255, 0, 255); ofSetColor(255, 255, 0, 255);
ofRect(0, 0, getWidth(), getHeight()); ofRect(0, 0, getWidth(), getHeight());
@ -13,7 +13,7 @@ void CrossSource::draw() {
ofSetColor(0, 0, 0, 255); ofSetColor(0, 0, 0, 255);
ofSetLineWidth(5); ofSetLineWidth(5);
float y = sin( float(ofGetFrameNum()) / 10.0f ) * 100.0f; float y = sin(float(ofGetFrameNum()) / 10.0f) * 100.0f;
ofPoint startPoint = ofPoint(10, y); ofPoint startPoint = ofPoint(10, y);
ofPoint endPoint = ofPoint(getWidth() - 10, getHeight() - y); ofPoint endPoint = ofPoint(getWidth() - 10, getHeight() - y);

14
example/src/CustomSource.cpp

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

4
example/src/CustomSource.h

@ -13,6 +13,6 @@ class CustomSource : public ofx::piMapper::FboSource {
void draw(); // You don't have to care about fbo.begin() or fbo.end() here void draw(); // You don't have to care about fbo.begin() or fbo.end() here
private: private:
vector<ofRectangle> rects; vector <ofRectangle> rects;
vector<float> rectSpeeds; vector <float> rectSpeeds;
}; };

18
example/src/main.cpp

@ -4,34 +4,34 @@
#ifdef TARGET_RASPBERRY_PI #ifdef TARGET_RASPBERRY_PI
int main(int argc, char* argv[]) { int main(int argc, char * argv[]){
bool fullscreen = false; bool fullscreen = false;
if (argc > 0) { if(argc > 0){
std::string fullscreenFlag = "-f"; std::string fullscreenFlag = "-f";
for (int i = 0; i < argc; i++) { for(int i = 0; i < argc; i++){
if (strcmp(argv[i], fullscreenFlag.c_str()) == 0) { if(strcmp(argv[i], fullscreenFlag.c_str()) == 0){
fullscreen = true; fullscreen = true;
break; break;
} }
} }
} }
if (fullscreen) { if(fullscreen){
ofSetupOpenGL(600, 500, OF_FULLSCREEN); ofSetupOpenGL(600, 500, OF_FULLSCREEN);
} else { }else{
ofSetupOpenGL(800, 450, OF_WINDOW); ofSetupOpenGL(800, 450, OF_WINDOW);
} }
ofRunApp(new ofApp()); ofRunApp(new ofApp());
} }
#else #else
int main() { int main(){
ofSetupOpenGL(800, 600, OF_WINDOW); ofSetupOpenGL(800, 600, OF_WINDOW);
ofRunApp(new ofApp()); ofRunApp(new ofApp());
} }
#endif #endif

4
example/src/ofApp.cpp

@ -1,6 +1,6 @@
#include "ofApp.h" #include "ofApp.h"
void ofApp::setup() { void ofApp::setup(){
ofBackground(0); ofBackground(0);
// Enable or disable audio for video sources globally // Enable or disable audio for video sources globally
@ -21,6 +21,6 @@ void ofApp::setup() {
// piMapper.showInfo(); // piMapper.showInfo();
} }
void ofApp::draw() { void ofApp::draw(){
piMapper.draw(); piMapper.draw();
} }

0
example/src/ofApp.h

Loading…
Cancel
Save