Skip to content

Instantly share code, notes, and snippets.

@rc1
Last active April 11, 2024 18:50
Show Gist options
  • Save rc1/5876289 to your computer and use it in GitHub Desktop.
Save rc1/5876289 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;
};
@JobLeonard
Copy link

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment