[openFrameworks] with Cocoa
I’m using openFrameworks just for prototyping. I wanted to use it with Objective-C to take advantage of Mac OS X Cocoa framework.
It’s straightforward excepting conflict definitions of BOOL type between Cocoa and openFrameworks’ FreeImage library. I used #define and #undef directives to work around (ref.).
#import <foundation/Foundation.h> #define BOOL OFBOOL // work around #include "ofMain.h" #undef BOOL // work around #include "testApp.h" //======================================================================== int main( ){ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; NSLog(@"Hello, World!"); // can be OF_WINDOW or OF_FULLSCREEN // pass in width and height too: ofSetupOpenGL(1024,768, OF_WINDOW); // <-------- setup the GL context // this kicks off the running of my app ofRunApp(new testApp); [pool drain]; }
取り組んでいたプロジェクトがちょっと”待ち”状態だったので、並行してもう1つプロジェクトをやる事に。そのために転がってたeMacやらG5やら計8台をセットアップ。test patternのインスタで習得したRemote Desktopのテクが役立ってしまった。最終的にこれらのパソコンは使わないので、使い捨てプロトタイプ用にネットワークが簡単なのとWindowsのPCが転がって来る可能性を考えopenFrameworksを使う事に。maxは使い方わからないし、Flashよりは目的に合う気がする。
と言っても当面Windowsは使わなそうで、そうなると超・非生産的(特にファイルの扱いとか事務的作業において)なC++より、馴れたCocoaを使いたくなる。Objective-Cが良い言語とは思わないけれど、C++よりだいぶマシ。使用に当たってBOOLの定義がopenFrameworksの使っているFreeImageという画像系っぽいライブラリと衝突してしまったので、インポートする際にちょっと(2行!)手を加える必要がありました。