実装メモ Edit

2011/03/08 G3Dの初期設定 Edit

項目初期値
viewportメインスクリーンのサイズいっぱい
clearColorRGBA(0.0,0.0,0.0,0.0)
colorUpdateenable
clearDepth1.0
depthUpdateenable
depthComparealways
mtxProjortho l-r(-1,1) b-t(-1,1) n-f(0,1)
mtxViewidentity

2011/03/06 iOSのエントリーポイント Edit

こんな感じかな。

すべてを展開すべてを収束
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 
-
|
|
|
|
|
!
 
 
-
|
|
|
|
|
|
|
|
|
|
!
 
 
-
|
|
|
|
|
|
|
-
|
|
|
|
|
!
|
|
|
|
|
|
|
|
!
 
int main()
{
    // Macと同じように引数解釈
    // ...
    
    // C++のコードに移動
    return mainC( ... );
}
 
int mainC( Arg aArg )
{
   // xmainスレッド作成
   // ...
   
   // UIMain実行
   // ...
   
   // xmainスレッドの完了待ち
   // ...
   
   // 終了
}
 
int xmainThreadEntryPoint( Arg* aArgPtr )
{
   // 起動完了待ち
   waitSignal(); // UIMainからSignalが来るのを待つ
   
   // ここにくるのはDidFinishedLaunchのタイミング
   
   // xmain起動
   int result = 0;
   {
       // Application作成
       Application app( *aArgPtr );
       
       // xmain呼び出し
       result = xmain( app );
   }
   
   // ここにくるのはapplicationWillTerminate
   
   // UIMainに終了したことを伝達
   signalToUIMain();
   
   // 何も待たずスレッド終了
   return result;
}

スレッドでUIViewとかUIWindowを作っても表示されないところで数時間はまった。
スレッドがexitせずにsleepする状態だと怒るらしい。
スレッドを寝かす前に CATransaction::flush() で明示的にCoreAnimationを更新してやるといけた。
正しい方法かどうかは不明…。

2011/03/05 iOS対応どうやろう Edit

元々WinとMacのクロスプラットフォームで考えていましたが
流行のiOSも対応させてみるのはおもしろそうと思いちょっと考えてみました。

iOS対応となると一番ネックなのがイベントドリブン式になるということ。

didFinishLaunchingWithOptions
applicationWillTerminate
applicationWillResignActive
applicationDidBecomeActive

初期化・後始末・アクティブ化・非アクティブ化のイベント。
後は毎秒60回のイベントが流れてくると考えれば良さそうです。

…という要件からメインループを書いてみる。

すべてを展開すべてを収束
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 
-
|
|
|
|
-
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
!
!
!
 
int xmain()
{
    Application app;
 
    bool doExit = false;
    while ( !doExit )
    {
        Event event = app.eventReceive();
 
        switch( event )
        {
        case EventKind_Quit:
            doExit = true;
            break;
 
        case EventKind_BecomeActive:
            break;
 
        case EventKind_ResignActive:
            break;
 
        case EventKind_UpdateFrame:
            update();
            draw();
            break;
 
        default:
            break;
        }
    }
}

なんとかいけるかな?


    ホーム 一覧 検索 最終更新 バックアップ リンク元   ヘルプ   最終更新のRSS