Skip to content

Instantly share code, notes, and snippets.

@kreigne
Forked from rc1/OSX Example
Created May 30, 2016 21:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kreigne/22605ab5c0635f85829d7bedfb683bd4 to your computer and use it in GitHub Desktop.
Save kreigne/22605ab5c0635f85829d7bedfb683bd4 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[]){
ofAppGlutWindow window; // create a window
// set width, height, mode (OF_WINDOW or OF_FULLSCREEN)
ofSetupOpenGL(&window, 1024, 768, OF_WINDOW);
testApp *app = new testApp();
app->arguments = vector<string>(argv, argv + argc);
ofRunApp(app); // start the app
}
open -n ./emptyExampleDebug.app/ --args 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