More Related Content
Similar to openFrameworks iOS 入門 (20)
More from Atsushi Tadokoro (19)
openFrameworks iOS 入門
- 8. 開発のための「糊」
‣ oFの構造イメージ
main.cpp
testApp.h testApp.cpp
openGL GLUT freeimage freetype
fmod rtaudio quicktime openCV
ofSimpleApp, ofGraphics, ofImage, ofTruTypeFont,
ofVidePlayer, ofVideoGrabber, ofTexture, ofSoundPlayer,
ofSoundStream, ofSerial, ofMath, ofUtils
プログラムの開始
コードを書くところ
OpenFrameworksの機能
ベースとなるライブラリ群
- 13. OpneFrameworksのコード構造
‣ さしあたって、編集するのは、testApp.hとtestApp.mm の
み!!
main.cpp
testApp.h testApp.cpp
openGL GLUT freeimage freetype
fmod rtaudio quicktime openCV
ofSimpleApp, ofGraphics, ofImage, ofTruTypeFont,
ofVidePlayer, ofVideoGrabber, ofTexture, ofSoundPlayer,
ofSoundStream, ofSerial, ofMath, ofUtils
プログラムの開始
コードを書くところ
OpenFrameworksの機能
ベースとなるライブラリ群
ココ
- 15. 2つのファイル
‣ testApp.h - ヘッダファイル
‣ プログラム全体で使用される部品 (変数、関数) を宣言
‣ 料理のレシピに例えると…
‣ 材料の一覧
‣ 料理手順の一覧
‣ testApp.mm - 実装ファイル
‣ 実際に何をするかを記述
‣ 料理のレシピに例えると…
‣ 実際の調理内容の全てを記述
- 17. #pragma once
#include "ofMain.h"
#include "ofxiPhone.h"
#include "ofxiPhoneExtras.h"
class testApp : public ofxiPhoneApp {
!
public:
! void setup();
! void update();
! void draw();
! void exit();
!
! void touchDown(ofTouchEventArgs &touch);
! void touchMoved(ofTouchEventArgs &touch);
! void touchUp(ofTouchEventArgs &touch);
! void touchDoubleTap(ofTouchEventArgs &touch);
! void touchCancelled(ofTouchEventArgs &touch);
!
! void lostFocus();
! void gotFocus();
! void gotMemoryWarning();
! void deviceOrientationChanged(int newOrientation);
!
};
testApp.h では
‣ testApp.h
準備
- 18. #pragma once
#include "ofMain.h"
#include "ofxiPhone.h"
#include "ofxiPhoneExtras.h"
class testApp : public ofxiPhoneApp {
!
public:
! void setup();
! void update();
! void draw();
! void exit();
!
! void touchDown(ofTouchEventArgs &touch);
! void touchMoved(ofTouchEventArgs &touch);
! void touchUp(ofTouchEventArgs &touch);
! void touchDoubleTap(ofTouchEventArgs &touch);
! void touchCancelled(ofTouchEventArgs &touch);
!
! void lostFocus();
! void gotFocus();
! void gotMemoryWarning();
! void deviceOrientationChanged(int newOrientation);
!
};
testApp.h では
‣ testApp.h
更新
- 19. #pragma once
#include "ofMain.h"
#include "ofxiPhone.h"
#include "ofxiPhoneExtras.h"
class testApp : public ofxiPhoneApp {
!
public:
! void setup();
! void update();
! void draw();
! void exit();
!
! void touchDown(ofTouchEventArgs &touch);
! void touchMoved(ofTouchEventArgs &touch);
! void touchUp(ofTouchEventArgs &touch);
! void touchDoubleTap(ofTouchEventArgs &touch);
! void touchCancelled(ofTouchEventArgs &touch);
!
! void lostFocus();
! void gotFocus();
! void gotMemoryWarning();
! void deviceOrientationChanged(int newOrientation);
!
};
testApp.h では
‣ testApp.h
描画
- 20. #include "testApp.h"
//--------------------------------------------------------------
void testApp::setup(){!
! // register touch events
! ofRegisterTouchEvents(this);
!
! // initialize the accelerometer
! ofxAccelerometer.setup();
!
! //iPhoneAlerts will be sent to this.
! ofxiPhoneAlerts.addListener(this);
!
! //If you want a landscape oreintation
! //iPhoneSetOrientation(OFXIPHONE_ORIENTATION_LANDSCAPE_RIGHT);
!
! ofBackground(127,127,127);
}
//--------------------------------------------------------------
void testApp::update(){
}
//--------------------------------------------------------------
void testApp::draw(){
!
}
testApp.mm では
‣ testApp.mm
準備
- 21. #include "testApp.h"
//--------------------------------------------------------------
void testApp::setup(){!
! // register touch events
! ofRegisterTouchEvents(this);
!
! // initialize the accelerometer
! ofxAccelerometer.setup();
!
! //iPhoneAlerts will be sent to this.
! ofxiPhoneAlerts.addListener(this);
!
! //If you want a landscape oreintation
! //iPhoneSetOrientation(OFXIPHONE_ORIENTATION_LANDSCAPE_RIGHT);
!
! ofBackground(127,127,127);
}
//--------------------------------------------------------------
void testApp::update(){
}
//--------------------------------------------------------------
void testApp::draw(){
!
}
testApp.mm では
‣ testApp.mm
更新
- 22. #include "testApp.h"
//--------------------------------------------------------------
void testApp::setup(){!
! // register touch events
! ofRegisterTouchEvents(this);
!
! // initialize the accelerometer
! ofxAccelerometer.setup();
!
! //iPhoneAlerts will be sent to this.
! ofxiPhoneAlerts.addListener(this);
!
! //If you want a landscape oreintation
! //iPhoneSetOrientation(OFXIPHONE_ORIENTATION_LANDSCAPE_RIGHT);
!
! ofBackground(127,127,127);
}
//--------------------------------------------------------------
void testApp::update(){
}
//--------------------------------------------------------------
void testApp::draw(){
!
}
testApp.mm では
‣ testApp.mm
描画
- 30. 色を指定するには?
‣ openFrameworks で色を指定するには?
‣ ofSetColor を使用する
‣ ofSetColor (Red, Green, Blue, Alpha);
‣ それぞれの色の範囲は 0 ∼ 255
‣ Alphaは透明度をあらわす
‣ 色を指定した以降の図形に適用される
‣ 例:
‣ ofSetColor(0, 127, 255, 127);
- 31. // 前略
void testApp::draw(){
! // 2つの円を描く
! ofEnableAlphaBlending();
! ofSetColor(0, 127, 255, 200);
! ofCircle(130, 240, 50);
! ofSetColor(255, 127, 0, 200);
! ofCircle(190, 240, 50);
}
// 後略
やってみよう!!
‣ testApp.mm - draw( )関数
変更