強火で進め

このブログではプログラム関連の記事を中心に書いてます。

iPhoneにopenFrameworksを移植した人が登場


openFrameworksというC++向けのマルチメディアライブラリを移植した方が登場しました。

移植した方のサイトはこちら

Developing for iPhone using openFrameworks and ofxiPhone | memo.tv
http://www.memo.tv/ofxiphone

移植元の本家のサイトはこちら

openFrameworks
http://www.openframeworks.cc/

ちなみにopenFrameworksとはC++向けのマルチプラットフォーム向けのアート系(マルチメディア)ライブラリです。

こちらのサイトによると「Processing(またはproce55ing)の設計に影響を受けたC++フレームワーク」とのことです。

openFrameworksをちょっとさわってみた - gnarl、技術メモ
http://d.hatena.ne.jp/gnarl/20070503/1178119448

ビルド方法はこちらのサイトが分かり易いです。

Jeff Crouse » Archive » openFrameworks on iPhone
http://www.jeffcrouse.info/uncategorized/openframeworks-on-iphone/

svnから関連ソースを落としたあとにこちらのサイトからライブラリをDLし、libsフォルダに解凍する必要があるのに注意して下さい(こちらについても上記サイトに記載があります)。

自分がDLしたバージョンではビルドすると以下のエラーが発生しました。

error: cannot allocate an object of abstract type 'testApp'
note:   because the following virtual functions are pure within 'testApp':
note:  virtual void ofxMultiTouchListener::touchDown(float, float, int, ofxMultiTouchCustomData*)
note:  virtual void ofxMultiTouchListener::touchMoved(float, float, int, ofxMultiTouchCustomData*)
note:  virtual void ofxMultiTouchListener::touchUp(float, float, int, ofxMultiTouchCustomData*)
note:  virtual void ofxMultiTouchListener::touchDoubleTap(float, float, int, ofxMultiTouchCustomData*)

こちら仮想関数が定義されていない為に発生しているエラーです。
実際には定義されており引数が異なるために結局は定義されてない扱いになってしまっているようです。

該当の関数(メソッド)を検索し、修正を行います。ここでは例として touchDown() について説明します。

確認すると以下の様な宣言と実装となっており、仮想関数の宣言と異なり x と y の型が int であることが確認できます。

testApp.h

	void touchDown(int x, int y, int touchId, ofxMultiTouchCustomData *data = NULL);

testApp.cpp

void testApp::touchDown(int x, int y, int touchId, ofxMultiTouchCustomData *data){

これを以下の様に float に修正。
testApp.h

	void touchDown(float x, float y, int touchId, ofxMultiTouchCustomData *data = NULL);

testApp.cpp

void testApp::touchDown(float x, float y, int touchId, ofxMultiTouchCustomData *data){

サンプルとして、以下の様なものが入ってました。

「画像処理」

「文字に関する処理」

「加速度センサーを使って円が移動」