Using SDKs with openFrameworks

It’s a little frustrating: there’s never any mid-level support and tutorials for programming online — just simple beginner stuff and complex solutions to the individual problems seasoned programmers face.

OpenFrameworks is my first foray into C++ (I’m self-taught, and besides oF have only ever programmed in Python and Javascript), so I’m not sure how C++ applications generally work outside of what’s been prescribed through oF.

How might I go about using an SDK in my apps, for example the one for the Oculus Rift
or for the Parrot AR Drone? (I’m aware these both have ofxaddons, but I’d love to access things not fully addressed with those addons, and know how to create my own addons.) I know that’s a huge question, but some direction would be super helpful.

A little more broadly, how do all of the parts of openFrameworks and c++ link together, how does Xcode handle that, and how do you extend what’s already there?

Usually the way it works is the following :

You get an SDK (oculus, kinect, whatever), that comes with basic samples. Those samples are usually source code that you can be build into a standalone program (a lot like oF examples). If you’re lucky, the sdk will come with project files for the sample and it’s a breeze to open it in Xcode. If you’re unlucky you’ll have to set up the project yourself, and then build the sample.

When you get the sample compiling, you start looking at what they do, how they do it, and try to get a grasp of how the stuff works (you can also read the documentation that goes with the sdk, a forum if there’s one, etc.)

Then, you find which feature you want to get working in oF, hopefully there’s a single sample that exhibits this feature. You then have to try to get the sample compiling into oF. Which could be take the oF empty example, copy all the source code of a given sample, find out how to update this empty project to link to the SDK. Do some black magic. And get an empty example and the sample working along side.

Unfortunately it’s pretty situation dependent. An easy use case would be a camera. The sdk show you how to create an application that shows the camera on screen. The sample would first initialize the camera, then get the pixel, then draw them on screen. You could ignore the architecture and focus on the first two tasks : how do you init the thing, and how do you get the pixels. You’d then do the init in the (oF) setup, grab the pixels in the (oF) update function and find out how to get those into a texture for the (oF) draw.

You say you’d like to extend existing addons, that might be (way?) easier. You’d first start exactly the same way as I described, but when it comes to import things into the oF world, you already have a good base with the addon you want to extend. So instead of figuring out yourself how to import the SDK into oF, you look how the addon writer did, try to understand their code (in regard of what you’ve learned by reading forums and sample code from the sdk) and then you start adding the feature you want, trying to follow the philosophy of whatever addon you have.

And as a last remark, you should always be careful to take everything with a little grain of salt. The sample code might be oversimplified to make it easy to understand, which might not be the best/proper way of doing things. The addon writer could have done things in a weird/buggy way, etc.

I hope it helps a bit, I feel I’m way to general but without a specific use case it’s hard to say the most meaningful things.