Last active
April 11, 2024 18:50
-
-
Save rc1/5876289 to your computer and use it in GitHub Desktop.
Command line arguments in openFrameworks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open -n ./emptyExampleDebug.app/ --args 1 2 3 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//-------------------------------------------------------------- | |
void testApp::draw(){ | |
for (int i=0; i<arguments.size(); ++i){ | |
ofDrawBitmapString(arguments.at(i), 20.0f, 20.0f*i); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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
Thank you!