What I've been learning while working with openFrameworks. This is a personal documentation, not the official thing. Find me @MatthiasEsterl
Don't wanna be here? Send us removal request.
Text
ofLog has moved.
ofLog as moved to madcity.at. See you over there.
0 notes
Text
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:
ofSetEscapeQuitsApp(false);
ofSetEscapeQuitsApp reference on openFrameworks.cc
Tested with openFrameworks 0.8.0
2 notes
·
View notes
Text
Setting a title for the openFrameworks window.
Usually, the title of an oF application is empty. This can be changed as follows:
ofSetWindowTitle("Title goes here.");
ofSetWindowTitle reference on openFrameworks.cc
It is possible to alter the title in runtime, which gives the posibillity, to keep track of a certain status (i.e. "ofApp - Connected to 127.0.0.1" or "ofApp - Not Connected").
Tested with openFrameworks 0.8.0
0 notes
Text
Difference between Debug and Release scheme.
Debug
Debug is useful when developing your project, as it will provide the most information about where and why something crashed.
Release
Release is useful when you're done developing your project. Release will create a smaller, faster app -- but it won't give you much information if it crashes.
Source: github / openFrameworks / docs / osx
0 notes
Text
Preprocessor to tell debug and release scheme apart.
I've started a topic at the openFrameworks forum, but as nobody has replied yet, I assume, that there is no oF-native way of telling apart the debug and release scheme from inside the code.
A simple solution is to add a preprocessor macro to one of the schemes. I've decided to add IS_DEBUG to the debug-scheme.
Now you can use the IS_DEBUG preprocessor as follows:
#ifndef IS_DEBUG // Load Settings when in productive setup XML.loadFile("settings.xml"); #endif
Tested with openFrameworks 0.8.0 and xcode 5
0 notes
Text
Building an analog clock face.
Tested with openFrameworks 0.7.4 (but should work fine with 0.8.x too)
0 notes
Text
Random direction: 1 or -1?
int direction = (round(ofRandomuf())*2)-1;
The variable direction now either holds 1 or -1.
Tested with openFrameworks 0.8.0
0 notes
Text
Possible random.
The obvious: Random
openFrameworks offers a function called ofRandom to generates a complete random float value between two given numbers.
Example:
ofRandom(25) could give you 14.7587. Or 5.4464. Or 0.0001
ofRandom(10, 11) would maybe be 10.0032, 10.9544, ...
Having a look into an ongoing discussion on GitHub, the result of the first example can be up to 24.9999, but can't be 25 itself.
There are also some shorthands for the ofRandom function:
ofRandomf() generates a random float between -1 and 1
ofRandomuf() generates a random float between 0 and 1
The natural: Perin Noise
The Perin Noise is integrated in openFrameworks with the ofNoise function. Shiffman did a great introduction on this algorithm as part of his Nature of Code series.
The return value of the function will be a float between 0 on 1.
Example:
t += 0.01;
ofNoise(t) would give you something like 0.700621, 0.70035, 0.699634, 0.698481, ...
Additionally, to generate noise signed values between -1 and 0, the function ofSignedNoise() can be used.
The missing: Gaussian Random Numbers
As until now, the openFrameworks core does not support the generation of gaussian numbers. Luckily, Andy Lambert created an addon called ofxGaussian to add this functionality. I had no chance to test it my self, but the code looks quite clean.
Again Shiffman, to give a short introduction on gaussian numbers.
Tested with openFrameworks 0.8.0
1 note
·
View note
Text
Draw the current frame rate on the screen.
Tested with openFrameworks 0.8.0
0 notes
Text
Packing the data-folder into an application.
Nick Hardemann wrote a short tutorial about this topic, which can be found here.
[...] 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.
[...]
ofSetDataPathRoot reference on openFrameworks.cc
Tested with openFrameworks 0.8.0
0 notes
Text
Import a picture from cam to ofImage when using a separate thread.
ofThread reference on openFrameworks.cc
setUseTexture reference on openFrameworks.cc
initGrabber reference on openFrameworks.cc
Example project (ofxDocuApp) on GitHub
0 notes
Text
Find cam by device name instead of id when using ofVideoGrabber
0 notes
Text
Adding an icon to an app.
openFrameworks App and XCode tricks from roxlu
Tested with openFrameworks 0.8.0
0 notes