Skip to content

Instantly share code, notes, and snippets.

@baku89
Forked from rc1/OSX Example
Last active September 1, 2016 11:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save baku89/ed98b7dc43548d8cc41b to your computer and use it in GitHub Desktop.
Save baku89/ed98b7dc43548d8cc41b to your computer and use it in GitHub Desktop.
Command line arguments in openFrameworks
#include "testApp.h"
#include "ofAppGlutWindow.h"
//--------------------------------------------------------------
int main(int argc, char *argv[]){
ofSetupOpenGL(1024,768,OF_WINDOW);
vector<string> myArgs;
for (int i = 0; i < argc - 1; i++) {
if (ofToString(argv[i]) == "--arguments") {
for (i++; i < argc; i++) {
myArgs.push_back(ofToString(argv[i]));
}
}
}
ofApp *app = new ofApp();
app->arguments = myArgs;
ofRunApp(app);
}
open -n ./emptyExampleDebug.app/ --args --myargs 1 2 3 4
//--------------------------------------------------------------
void testApp::draw(){
for (int i=0; i<arguments.size(); ++i){
ofDrawBitmapString(arguments.at(i), 20.0f, 20.0f*i);
}
}
#pragma once
#include "ofMain.h"
class testApp : public ofBaseApp{
public:
void setup();
void update();
void draw();
void keyPressed(int key);
void keyReleased(int key);
void mouseMoved(int x, int y);
void mouseDragged(int x, int y, int button);
void mousePressed(int x, int y, int button);
void mouseReleased(int x, int y, int button);
void windowResized(int w, int h);
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);
vector<string> arguments;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment