diff --git a/example/bin/.gitignore b/example/bin/.gitignore index 1002931..970655f 100644 --- a/example/bin/.gitignore +++ b/example/bin/.gitignore @@ -3,5 +3,6 @@ data/*.jpg data/settings.xml data/surfaces.xml example +example_debug libs readMe.txt diff --git a/example/bin/data/ofxpimapper.xml b/example/bin/data/ofxpimapper.xml index 69a404b..926e9ef 100644 --- a/example/bin/data/ofxpimapper.xml +++ b/example/bin/data/ofxpimapper.xml @@ -2,16 +2,16 @@ - 250.000000000 - 138.187255859 + 194.000000000 + 57.187255859 - 403.625549316 - 291.812774658 + 467.000000000 + 412.000000000 - 96.374511719 - 291.812774658 + 40.374511719 + 210.812774658 @@ -36,20 +36,20 @@ - 425.565002441 - 144.782531738 + 407.565002441 + 111.782531738 - 718.434936523 - 144.782531738 + 700.434936523 + 111.782531738 - 718.434936523 - 291.217407227 + 700.434936523 + 258.217407227 - 425.565002441 - 291.217407227 + 407.565002441 + 258.217407227 diff --git a/example/example.qbs b/example/example.qbs new file mode 100644 index 0000000..bda70b8 --- /dev/null +++ b/example/example.qbs @@ -0,0 +1,64 @@ +import qbs +import qbs.Process +import qbs.File +import qbs.FileInfo +import qbs.TextFile +import "../../../libs/openFrameworksCompiled/project/qtcreator/ofApp.qbs" as ofApp + +Project{ + property string of_root: "../../.." + + ofApp { + name: { return FileInfo.baseName(path) } + + files: [ + "src/CrossSource.cpp", + "src/CrossSource.h", + "src/CustomSource.cpp", + "src/CustomSource.h", + "src/Settings.cpp", + "src/Settings.h", + 'src/main.cpp', + 'src/ofApp.cpp', + 'src/ofApp.h', + ] + + of.addons: [ + 'ofxGui', + 'ofxPiMapper', + 'ofxXmlSettings', + ] + + // additional flags for the project. the of module sets some + // flags by default to add the core libraries, search paths... + // this flags can be augmented through the following properties: + of.pkgConfigs: [] // list of additional system pkgs to include + of.includePaths: [] // include search paths + of.cFlags: [] // flags passed to the c compiler + of.cxxFlags: [] // flags passed to the c++ compiler + of.linkerFlags: [] // flags passed to the linker + of.defines: [] // defines are passed as -D to the compiler + // and can be checked with #ifdef or #if in the code + + // other flags can be set through the cpp module: http://doc.qt.io/qbs/cpp-module.html + // eg: this will enable ccache when compiling + // + // cpp.compilerWrapper: 'ccache' + + Depends{ + name: "cpp" + } + + // common rules that parse the include search paths, core libraries... + Depends{ + name: "of" + } + + // dependency with the OF library + Depends{ + name: "openFrameworks" + } + } + + references: [FileInfo.joinPaths(of_root, "/libs/openFrameworksCompiled/project/qtcreator/openFrameworks.qbs")] +} diff --git a/example_simpler/.gitignore b/example_simpler/.gitignore new file mode 100644 index 0000000..e4d4b5d --- /dev/null +++ b/example_simpler/.gitignore @@ -0,0 +1,5 @@ +obj +*.xcworkspace +*.xcuserdatad +*~ +config.make diff --git a/example_simpler/Makefile b/example_simpler/Makefile new file mode 100644 index 0000000..8d8e4c0 --- /dev/null +++ b/example_simpler/Makefile @@ -0,0 +1,13 @@ +# Attempt to load a config.make file. +# If none is found, project defaults in config.project.make will be used. +ifneq ($(wildcard config.make),) + include config.make +endif + +# make sure the the OF_ROOT location is defined +ifndef OF_ROOT + OF_ROOT=$(realpath ../../..) +endif + +# call the project makefile! +include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk diff --git a/example_simpler/addons.make b/example_simpler/addons.make new file mode 100644 index 0000000..e72d2dd --- /dev/null +++ b/example_simpler/addons.make @@ -0,0 +1,3 @@ +ofxGui +ofxPiMapper +ofxXmlSettings diff --git a/example_simpler/bin/data/.gitkeep b/example_simpler/bin/data/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/example_simpler/bin/data/dummy-objects.png b/example_simpler/bin/data/dummy-objects.png new file mode 100644 index 0000000..9d90291 Binary files /dev/null and b/example_simpler/bin/data/dummy-objects.png differ diff --git a/example_simpler/bin/data/ofxpimapper.xml b/example_simpler/bin/data/ofxpimapper.xml new file mode 100644 index 0000000..1c44003 --- /dev/null +++ b/example_simpler/bin/data/ofxpimapper.xml @@ -0,0 +1,81 @@ + + + + + 193.000000000 + 58.187255859 + + + 466.000000000 + 413.000000000 + + + 39.374511719 + 211.812774658 + + + + + -0.006000000 + -0.014000000 + + + 1.000000000 + 1.000000000 + + + 0.000000000 + 1.000000000 + + + + image + image4.jpg + + + + + + 758.067382812 + 360.033691406 + + + 1125.932617188 + 360.033691406 + + + 1129.000000000 + 719.000000000 + + + 759.000000000 + 721.000000000 + + + + + 0.000000000 + 0.000000000 + + + 1.000000000 + 0.000000000 + + + 1.000000000 + 1.000000000 + + + 0.000000000 + 1.000000000 + + + + fbo + Custom FBO Source + + + 1 + + + diff --git a/example_simpler/bin/data/sources/images/blending.png b/example_simpler/bin/data/sources/images/blending.png new file mode 100644 index 0000000..a5c8f65 Binary files /dev/null and b/example_simpler/bin/data/sources/images/blending.png differ diff --git a/example_simpler/bin/data/sources/images/image2.jpg b/example_simpler/bin/data/sources/images/image2.jpg new file mode 100644 index 0000000..4111693 Binary files /dev/null and b/example_simpler/bin/data/sources/images/image2.jpg differ diff --git a/example_simpler/bin/data/sources/images/image4.jpg b/example_simpler/bin/data/sources/images/image4.jpg new file mode 100644 index 0000000..3291a57 Binary files /dev/null and b/example_simpler/bin/data/sources/images/image4.jpg differ diff --git a/example_simpler/bin/data/sources/videos/control-panel-and-operation.mp4 b/example_simpler/bin/data/sources/videos/control-panel-and-operation.mp4 new file mode 100644 index 0000000..ebffeba Binary files /dev/null and b/example_simpler/bin/data/sources/videos/control-panel-and-operation.mp4 differ diff --git a/example_simpler/example_simpler.qbs b/example_simpler/example_simpler.qbs new file mode 100644 index 0000000..2519050 --- /dev/null +++ b/example_simpler/example_simpler.qbs @@ -0,0 +1,62 @@ +import qbs +import qbs.Process +import qbs.File +import qbs.FileInfo +import qbs.TextFile +import "../../../libs/openFrameworksCompiled/project/qtcreator/ofApp.qbs" as ofApp + +Project{ + property string of_root: "../../.." + + ofApp { + name: { return FileInfo.baseName(path) } + + files: [ + "src/CustomSource.cpp", + "src/CustomSource.h", + "src/Settings.cpp", + "src/Settings.h", + "src/main.cpp", + "src/ofApp.cpp", + "src/ofApp.h", + ] + + of.addons: [ + 'ofxGui', + 'ofxPiMapper', + 'ofxXmlSettings', + ] + + // additional flags for the project. the of module sets some + // flags by default to add the core libraries, search paths... + // this flags can be augmented through the following properties: + of.pkgConfigs: [] // list of additional system pkgs to include + of.includePaths: [] // include search paths + of.cFlags: [] // flags passed to the c compiler + of.cxxFlags: [] // flags passed to the c++ compiler + of.linkerFlags: [] // flags passed to the linker + of.defines: [] // defines are passed as -D to the compiler + // and can be checked with #ifdef or #if in the code + + // other flags can be set through the cpp module: http://doc.qt.io/qbs/cpp-module.html + // eg: this will enable ccache when compiling + // + // cpp.compilerWrapper: 'ccache' + + Depends{ + name: "cpp" + } + + // common rules that parse the include search paths, core libraries... + Depends{ + name: "of" + } + + // dependency with the OF library + Depends{ + name: "openFrameworks" + } + } + + references: [FileInfo.joinPaths(of_root, "/libs/openFrameworksCompiled/project/qtcreator/openFrameworks.qbs")] +} diff --git a/example_simpler/example_simpler.qbs.user b/example_simpler/example_simpler.qbs.user new file mode 100644 index 0000000..a187c7a --- /dev/null +++ b/example_simpler/example_simpler.qbs.user @@ -0,0 +1,245 @@ + + + + + + EnvironmentId + {8be5f52a-5735-4165-a4b3-4f0f5d90a15e} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop + {a4d26ffb-0245-4d65-8e2f-7d8767bb05ec} + 0 + 0 + 0 + + /home/theodoros/bin/of_v0.9.8_linux64_release/addons/ofxPiMapper/build-example_simpler-Desktop-Debug + + + true + + Qbs Build + Qbs.BuildStep + false + + debug + qtc_Desktop_1976aced + + false + false + true + 8 + false + false + + 1 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + + Qbs Clean + Qbs.CleanStep + false + false + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + + Qbs.QbsBuildConfiguration + + + /home/theodoros/bin/of_v0.9.8_linux64_release/addons/ofxPiMapper/build-example_simpler-Desktop-Release + + + true + + Qbs Build + Qbs.BuildStep + false + + release + qtc_Desktop_1976aced + + false + false + true + 0 + false + false + + 1 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + + Qbs Clean + Qbs.CleanStep + false + false + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + + Qbs.QbsBuildConfiguration + + 2 + + + 0 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy locally + Qbs Install + Qbs.Deploy + + 1 + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + example_simpler + + Qbs.RunConfiguration:example_simpler.qtc_Desktop_1976aced---Qbs.RC.NameSeparator---example_simpler + + + /home/theodoros/bin/of_v0.9.8_linux64_release/addons/ofxPiMapper/example_simpler/bin + 3768 + false + true + false + false + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 18 + + + Version + 18 + + diff --git a/example_simpler/src/CustomSource.cpp b/example_simpler/src/CustomSource.cpp new file mode 100644 index 0000000..f5eb1d0 --- /dev/null +++ b/example_simpler/src/CustomSource.cpp @@ -0,0 +1,41 @@ +#include "CustomSource.h" + +void CustomSource::setup(){ + // 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(); + } + } +} + +// 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); + ofSetColor(255); + for(int i = 0; i < rects.size(); i++){ + ofDrawRectangle(rects[i]); + } +} diff --git a/example_simpler/src/CustomSource.h b/example_simpler/src/CustomSource.h new file mode 100644 index 0000000..9a3ce04 --- /dev/null +++ b/example_simpler/src/CustomSource.h @@ -0,0 +1,14 @@ +#pragma once + +#include "ofMain.h" +#include "FboSource.h" + +class CustomSource : public ofx::piMapper::FboSource { + public: + void setup(); + void update(); + void draw(); + + vector rects; + vector rectSpeeds; +}; \ No newline at end of file diff --git a/example_simpler/src/Settings.cpp b/example_simpler/src/Settings.cpp new file mode 100644 index 0000000..509371e --- /dev/null +++ b/example_simpler/src/Settings.cpp @@ -0,0 +1,22 @@ +#include "Settings.h" + +Settings * Settings::_instance = 0; + +Settings * Settings::instance(){ + if(_instance == 0){ + _instance = new Settings(); + } + return _instance; +} + +Settings::Settings(){ + _fullscreen = false; +} + +void Settings::setFullscreen(bool f){ + _fullscreen = f; +} + +bool Settings::getFullscreen(){ + return _fullscreen; +} \ No newline at end of file diff --git a/example_simpler/src/Settings.h b/example_simpler/src/Settings.h new file mode 100644 index 0000000..db3db66 --- /dev/null +++ b/example_simpler/src/Settings.h @@ -0,0 +1,18 @@ +#pragma once + +#include "ofMain.h" + +class Settings { + public: + static Settings * instance(); + + void setFullscreen(bool f); + bool getFullscreen(); + + private: + static Settings * _instance; + + Settings(); + + bool _fullscreen; +}; diff --git a/example_simpler/src/main.cpp b/example_simpler/src/main.cpp new file mode 100644 index 0000000..e5733f9 --- /dev/null +++ b/example_simpler/src/main.cpp @@ -0,0 +1,22 @@ +#include "ofMain.h" +#include "ofApp.h" +#include +#include +#include "Settings.h" + +int main(int argc, char * argv[]){ + bool fullscreen = false; + + vector arguments = vector(argv, argv + argc); + for(int i = 0; i < arguments.size(); ++i){ + if(arguments.at(i) == "-f"){ + fullscreen = true; + break; + } + } + + Settings::instance()->setFullscreen(fullscreen); + + ofSetupOpenGL(800, 450, OF_WINDOW); + ofRunApp(new ofApp()); +} diff --git a/example_simpler/src/ofApp.cpp b/example_simpler/src/ofApp.cpp new file mode 100644 index 0000000..02ba925 --- /dev/null +++ b/example_simpler/src/ofApp.cpp @@ -0,0 +1,55 @@ +#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 = true; + ofx::piMapper::VideoSource::useHDMIForAudio = 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. + customSource = new CustomSource(); + piMapper.registerFboSource(customSource); + piMapper.setup(); + + // The info layer is hidden by default, press to toggle + // piMapper.showInfo(); + + ofSetFullscreen(Settings::instance()->getFullscreen()); + ofSetEscapeQuitsApp(false); + + dummyObjects.load("dummy-objects.png"); +} + +void ofApp::update(){ + piMapper.update(); +} + +void ofApp::draw(){ + dummyObjects.draw(200,200); + piMapper.draw(); +} + +void ofApp::keyPressed(int key){ + piMapper.keyPressed(key); +} + +void ofApp::keyReleased(int key){ + piMapper.keyReleased(key); +} + +void ofApp::mousePressed(int x, int y, int button){ + piMapper.mousePressed(x, y, button); +} + +void ofApp::mouseReleased(int x, int y, int button){ + piMapper.mouseReleased(x, y, button); +} + +void ofApp::mouseDragged(int x, int y, int button){ + piMapper.mouseDragged(x, y, button); +} diff --git a/example_simpler/src/ofApp.h b/example_simpler/src/ofApp.h new file mode 100644 index 0000000..75c7f10 --- /dev/null +++ b/example_simpler/src/ofApp.h @@ -0,0 +1,28 @@ +#pragma once + +#include "ofMain.h" +#include "Settings.h" +#include "ofxPiMapper.h" +#include "CustomSource.h" +#include "VideoSource.h" + +class ofApp : public ofBaseApp { + public: + void setup(); + void update(); + void draw(); + + void keyPressed(int key); + void keyReleased(int key); + + void mousePressed(int x, int y, int button); + void mouseReleased(int x, int y, int button); + void mouseDragged(int x, int y, int button); + + ofxPiMapper piMapper; + + // By using a custom source that is derived from FboSource + // you will be able to see the source listed in sources editor + CustomSource * customSource; + ofImage dummyObjects; +};