Get an openFrameworks app "production ready"
This post is a re-write and combination of some short posts i've posted back on tumblr. It collects a couple of tips to polish an openFrameworks app. Some other useful information is been collected by laserpilot in his GitHub repository "Installation_Up_4evr".
Packing the data-folder into the application
He used a command that will copy your entire data folder into your resources folder relative to your application:
cp -r bin/data "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Resources";
This needs to be added to the Run Script command found in the application target.
You can check that it have been moved successfully by right clicking on the application and choosing “Show Package Contents” and it will be in Contents / Resources / data. Now that your data folder is being copied over, we need to tell OF where to look. So we need to set the path root by calling ofSetDataPathRoot("../Resources/"); in the setup function.
Build the app using the Release-scheme
I've written a separate post, called Debug & Release scheme in XCode and openFrameworks, that should give a basic idea, what the Debug- and Release-schemes are all about.
Adding an icon to the app
Setting a title for the openFrameworks window
Usually, the title of an oF application is empty. This can easily be changed with ofSetWindowTitle.
ofSetWindowTitle("Title goes here.");
It is also possible to change the title during runtime, which gives the possibility, to keep track of a certain status (i.e. "ofApp - Connected to 127.0.0.1" or "ofApp - Not Connected").
Stop an app from shutting down on ESC.
It sometimes make sense to prevent an oF app from closing on the esc-key. One single line in the setup()-Method can accomplish that:
- ofSetDataPathRoot reference on openFrameworks.cc
- ofSetWindowTitle reference on openFrameworks.cc
- ofSetEscapeQuitsApp reference on openFrameworks.cc