changeset 6:4c0e82b725d9

added command line arguments for window size
author Fiore Martin <f.martin@qmul.ac.uk>
date Thu, 14 Jul 2016 15:08:31 +0200
parents 75b744078d66
children a4a336624f5a
files CollidoscopeApp/src/CollidoscopeApp.cpp
diffstat 1 files changed, 33 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/CollidoscopeApp/src/CollidoscopeApp.cpp	Wed Jul 13 16:06:46 2016 +0200
+++ b/CollidoscopeApp/src/CollidoscopeApp.cpp	Thu Jul 14 15:08:31 2016 +0200
@@ -19,10 +19,12 @@
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+
 #include "cinder/app/App.h"
 #include "cinder/app/RendererGl.h"
 #include "cinder/gl/gl.h"
 #include "cinder/Exception.h"
+#include <stdexcept>
 
 
 #include "Config.h"
@@ -46,7 +48,10 @@
     void setup() override;
     void setupGraphics();
 
+    /** Receives MIDI command messages from MIDI thread */
     void receiveCommands();
+    /** Prints command line usage */
+    void usage();
 
     void keyDown( KeyEvent event ) override;
     void update() override;
@@ -122,10 +127,10 @@
     switch (c){
     case 'r' : 
         mAudioEngine.record( 0 );
-        mAudioEngine.record( 1 );
         break;
 
     case 'w': {
+
         mWaves[0]->getSelection().setSize(mWaves[0]->getSelection().getSize() + 1);
 
         size_t numSelectionChunks = mWaves[0]->getSelection().getSize();
@@ -467,9 +472,33 @@
     }
 }
 
+
 CINDER_APP( CollidoscopeApp, RendererGl, [] ( App::Settings *settings) {
-        settings->setWindowSize( 1920, 1080 );
-        settings->setMultiTouchEnabled( false );
-        settings->disableFrameRate();
+
+    const std::vector< string > args = settings->getCommandLineArgs();
+
+    int width = 0;
+    int height = 0;
+
+    try {
+        if( args.size() != 3 )
+            throw std::invalid_argument("");
+
+        width  = std::stoi( args[1] );
+        height = std::stoi( args[2] );
+
+    }
+    catch( std::invalid_argument & e ){
+        console() << "Error: invalid arguments" << std::endl;
+        console() << "Usage: ./Collidoscope window_width window_height" << std::endl;  
+        console() << "For example: ./Collidoscope 1024 768 " << std::endl;  
+
+        settings->setShouldQuit( true );
+        return;
+    }
+
+    settings->setWindowSize( width, height );
+    settings->setMultiTouchEnabled( false );
+    settings->disableFrameRate();
 
 } )