I’m starting up a new project and I chose openFrameworks for the job. It’s going to be a cross platform app (iOS + Android) and I wanted to share my experience thus far.
I downloaded the release packages for iOS and Android and consolidated them until I had one code repository that contains an xcodeproj AND eclipse project, with all necessary files + common cpp files for both. I’m experienced with cross platform development (using cocos-2dx) so it wasn’t too hard, but still not exactly trivial. I think it’s a good example to be shared publicly and build upon since multi platform projects are becoming more and more popular. I think there should be a unified Android/iOS package instead of separate ones, with examples for both, some of them sharing the same cpp code.
My app will require a location. I used ofxiOSCoreLocation and ofxAndroidGPS. Naturally, I wanted the same cpp code to get the location regardless of the running OS, so I created a layer of abstraction that I think could be useful. I also think that this pattern should be embraced on many add ons that offer similar functionality for iOS and Android. There shouldn’t be a separate interface for each OS. That defeats the purpose of a cross platform framework.
My next endeavour is having gesture recognition running cross platform. I see there’s a ofxGestureRecognizer that someone made for iOS that wraps up the objective C part but I haven’t checked it out yet. I haven’t found any existing code for android so I intend to develop it myself. Same goes here, I intend to consolidate the interface so that is can be used on both OS’s seamlessly. I would be happy to contribute that code to OF.
Lastly, my project is not solely open GL stuff. It contains native iOS/android UI. It also contains multiple screens, with different layouts, each one should be a different “OF app”. In iOS, the iOSNativeExample was very helpful, to understand how to make iOS the boss, and not OF, using ofxiOSViewController->initWithFrame. But for Android, I don’t see a simple solution. Basically, I want to have multiple activities inheriting from OFActivity. Now, as I see it, inside OFAndroid there are two places that needs intervention in order to do that. One is:
View view = ofActivity.getLayoutInflater().inflate(layout.getField(“main_layout”).getInt(null),null);
I will need to pass the name of the layout I want, so it won’t be hardcoded to “main_layout”.
The second location is:
that passes over jni to the cpp side. I will need to pass over which “OF app” I want to run there. It doesn’t seem that I will be able to do those changes in inheritance, and it looks like I’ll need to splice things directly in the massive OFAndroid class.
And that’s assuming that the life cycle of these objects are designed to be destructed correctly when passing between screens.
That’s all I’ve got for now. I’ll be happy to hear some feedback and advice on those directions from some OF experts, and if anyone else is in need of (or already have) solutions to those problems.