Iwao myds

dev.mish.work へ移行しました.

この画面は、簡易表示です

Xcode

Xcode include

MFC や Windows に依存しないコードのテスト.
今 mac に入っているのは,Xcode Version 6.4.


Project Navigator で,対象のプロジェクトを選択.
検索の所に Search と入力して絞り込み.
Header Search Paths の /Applications/… となっている所をダブルクリック.
「+」で,/Users/Iwao/Public/Dropbox/Develop/_.SRC/__CPR_ などを追加.


VC では,「アクティブプロジェクトに設定」や「スタートアッププロジェクトの設定」にあたるもの.
ビルドや実行対象の変更は,メニューの「Product」-「Scheme」にある.
 以前と変わった?

この投稿は役に立ちましたか? 役に立った 役に立たなかった 0 人中 0 人がこの 投稿 は役に立ったと言っています。


xcode + glut

「Command Line Tool」としてプロジェクトを作成.
「GLUT」を追加.


10.9 になったこと?により出力される次の様なワーニングをでない様にするために 10.8 に.
/Users/Iwao/…/main.cpp:116:2: ‘glutInit’ is deprecated: first deprecated in OS X 10.9

インクルードパス設定場所は,「Build Settings」−「Search Paths」−「Header Search Paths」
glut.h のインクルードは以下の様にしている.
  #ifdef __APPLE_CC__
    #include <GLUT/glut.h>
  #else
    #include <GL/glut.h>
  #endif

この投稿は役に立ちましたか? 役に立った 役に立たなかった 0 人中 0 人がこの 投稿 は役に立ったと言っています。


iPhone 3D – 5

110 ページまでやってのエラー.
/…/S_Wire/ApplicationEngine.cpp:57:14: Assigning to ‘ISurface *’ from incompatible type ‘Cone *’

/…/S_Wire/ApplicationEngine.cpp:62:14: Assigning to ‘ISurface *’ from incompatible type ‘MobiusStrip *’
  ParametricSurface.hpp の ParametricSurface の定義で public ISurface が抜けていた.


ApplicationEngine.cpp::: Reference to type ‘const std::vector’ could not bind to an rvalue of type ‘Visual *’
  どうも,107 ページで与えているのが Visual になってるが,vector<Visual> となる様に変更.
  void ApplicationEngine::Render () const {
    vector<Visual> visuals ;
    Visual visual ;
    visual.Color = m_Spinning ? vec3(1,1,1) : vec3(0,1,1) ;
    visual.LowerLeft = ivec2(0,48) ;
    visual.ViewportSize = ivec2(320,432) ;
    visual.Orientation = m_Orientation ;
  // m_RenderingEngine->Render(&visual) ;
    visuals.push_back(visual) ;
    m_RenderingEngine->Render(visuals) ;
  }


今度はリンクエラー   “ES1::CreateRenderingEngine()”, referenced from:
これは,タイプミス.e が抜けている.
IRenderingEngine* CreateRenderingEngine () {
return new RenderingEngine() ;
}

この投稿は役に立ちましたか? 役に立った 役に立たなかった 0 人中 0 人がこの 投稿 は役に立ったと言っています。


iPhone 3D – 4

だいぶ時間が経ったが,
81 ページまでやっていて Cone が表示されない.

モデルビュー行列の設定で,”Modelview” が “ModelView” と大文字のタイプミス.

この投稿は役に立ちましたか? 役に立った 役に立たなかった 0 人中 0 人がこの 投稿 は役に立ったと言っています。


typedef … BOOL ;

iOS のプロジェクトでビルドすると,BOOL の定義(typedef int BOOL ;)で,
  /…/i_Define.hxx:30:18: Typedef redefinition with different types (‘int’ vs ‘signed char’)
iPhoneSimulator6.1/usr/include/objc/objc.h に以下が定義されている.
  typedef signed char BOOL;


以下の様に OBJC_BOOL_DEFINED で振り分け.
  #ifdef OBJC_BOOL_DEFINED
  #else
    typedef int BOOL ;
  #endif


i_define.hxx


他にも,Mac 64-bit でビルドすると,long のビット長の問題で幾つかワーニングになる.
いい対応方法が思いつかないので,ひとまず幾つかはそのままとする.

この投稿は役に立ちましたか? 役に立った 役に立たなかった 0 人中 0 人がこの 投稿 は役に立ったと言っています。


Xcode でのデバッグ?

Xcode でのデバッグ
::To_tstring_rz で,str[index] = sp としていたため.
  sp はデフォルトでは _T(‘\0’) で,_T(‘ ‘) なども指定できるようにしている.
  対応としては,return する前に c_str() とすることにした.

この投稿は役に立ちましたか? 役に立った 役に立たなかった 0 人中 0 人がこの 投稿 は役に立ったと言っています。


ostrstream の利用でメモリリーク

次の様なコードでメモリリーク.freeze(false) がなかったのが原因.


tstring To_tstring (const double v,const int w=0,const int p=6,const long f=0) {
  tstring str ;
  std::ostrstream strBuf ;
  if (f != 0) {
    strBuf.flags(f) ;
    }
  {
    strBuf.width(w) ;
    strBuf.precision(p) ;
    }
  {
    strBuf << v ;
    strBuf << std::ends ;
    }
  {
    str = strBuf.str() ;
  // strBuf.rdbuf()->freeze(false) ;
    }
  return str ;
  }


Detected memory leaks!
Dumping objects ->
{385} normal block at 0x00038168, 512 bytes long.
Data: < 1.05 > 20 20 31 2E 30 35 00 CD CD CD CD CD CD CD CD CD
{363} normal block at 0x00037F20, 512 bytes long.
Data: <233.50 > 32 33 33 2E 35 30 00 CD CD CD CD CD CD CD CD CD
{339} normal block at 0x00037C70, 512 bytes long.
Data: < 967 > 20 20 20 39 36 37 00 CD CD CD CD CD CD CD CD CD
{315} normal block at 0x00037A28, 512 bytes long.
Data: < 875 > 20 20 20 38 37 35 00 CD CD CD CD CD CD CD CD CD
{291} normal block at 0x000377E0, 512 bytes long.
Data: < 997 > 20 20 20 39 39 37 00 CD CD CD CD CD CD CD CD CD
{269} normal block at 0x00037598, 512 bytes long.
Data: < 1.08 > 20 20 31 2E 30 38 00 CD CD CD CD CD CD CD CD CD
{245} normal block at 0x00037350, 512 bytes long.
Data: < 955 > 20 20 20 39 35 35 00 CD CD CD CD CD CD CD CD CD
{223} normal block at 0x00037108, 512 bytes long.
Data: < 1.15 > 20 20 31 2E 31 35 00 CD CD CD CD CD CD CD CD CD
{201} normal block at 0x00036EC0, 512 bytes long.
Data: < 1.02 > 20 20 31 2E 30 32 00 CD CD CD CD CD CD CD CD CD
{169} normal block at 0x000369B8, 512 bytes long.
Data: < 1.06 > 20 20 31 2E 30 36 00 CD CD CD CD CD CD CD CD CD
{143} normal block at 0x00036770, 512 bytes long.
Data: < 1003 > 20 20 31 30 30 33 00 CD CD CD CD CD CD CD CD CD
Object dump complete.
スレッド 0xDEC 終了、終了コード 0 (0x0)。
プログラム ‘C:\…\DmpFS\Debug\DmpFS.exe’ はコード 0 (0x0) で終了しました。


MSDN strstreambuf::freeze


2013/08/26
上のコードを Xcode でビルドすると,strBuf.flags(f) の所で
    /Volumes/…/t_string.hxx:47:10: No matching member function for call to ‘flags’
  利用する前に fmtflags 型にして利用する様に変更.
    std::ios_base::fmtflags f = std::ios_base::fmtflags(f_) ;


2013/08/28
_UNICODE に対応できなかったので,ostringstream を利用する様に変更.
  tstring To_tstring (const double v,const int w=0,const int p=6,const unsigned f_=std::ios::fixed) {
    tstring str ;
  #ifdef _UNICODE
    std::wostringstream strBuf ;
  #else
    std::ostringstream strBuf ;
  #endif
    std::ios_base::fmtflags f = std::ios_base::fmtflags(f_) ;
    if (f != 0) { strBuf.flags(f) ; }
    strBuf.width(w) ;
    strBuf.precision(p) ;
    strBuf << v ;
    str = strBuf.str() ;
    return str ;
    }

この投稿は役に立ちましたか? 役に立った 役に立たなかった 0 人中 0 人がこの 投稿 は役に立ったと言っています。


CPoint と CGPoint

以前作成した MemoryStatus クラスを利用して,Win , iOS で書いてみた.
MemoryStatus の配列として,MemoryStatusAry を作成.
また,float の配列をそれぞれの点配列に変換する ::GraphGetPoint を用意.


Win
  void CMemSSDView::OnPaint()
  {
    CPaintDC dc(this);
    CRect rect ;
    GetClientRect(rect) ;
    {
      std::vector<float> grphF = MemSA.GetGraph(MemoryStatusAry::WinPhysF) ;
      std::vector<float> grphT = MemSA.GetGraph(MemoryStatusAry::WinPhysT) ;
      std::vector<float> grphP = MemSA.GetGraph(MemoryStatusAry::WinPageF) ;
      std::vector<CPoint> pntsF = ::GraphGetPoint(grphF,rect) ;
      std::vector<CPoint> pntsT = ::GraphGetPoint(grphT,rect) ;
      std::vector<CPoint> pntsP = ::GraphGetPoint(grphP,rect) ;
      {
        CPen penGreen(PS_SOLID,1,RGB(0,192,0)) ;
        CPen* oldPen = dc.SelectObject(&penGreen) ;
        dc.Polyline(&pntsF[0],pntsF.size()) ;
        CPen penRed(PS_SOLID,1,RGB(192,0,0)) ;
        oldPen = dc.SelectObject(&penRed) ;
        dc.Polyline(&pntsT[0],pntsT.size()) ;
        CPen penBlue(PS_SOLID,1,RGB(0,0,192)) ;
        oldPen = dc.SelectObject(&penBlue) ;
        dc.Polyline(&pntsP[0],pntsP.size()) ;
        dc.SelectObject(oldPen) ;
        }
      }
    }


iOS
  - (void)drawRect:(CGRect)rect
  {
    _context = UIGraphicsGetCurrentContext() ;
    {
      std::vector<float> grphP = MemSA.GetGraph(MemoryStatusAry::MacPFree) ;
      std::vector<float> grphA = MemSA.GetGraph(MemoryStatusAry::MacInact) ;
      std::vector<float> grphW = MemSA.GetGraph(MemoryStatusAry::MacWired) ;
      std::vector<CGPoint> pntsP = ::GraphGetPoint(grphP,rect) ;
      std::vector<CGPoint> pntsA = ::GraphGetPoint(grphA,rect) ;
      std::vector<CGPoint> pntsW = ::GraphGetPoint(grphW,rect) ;
      {
        [self setColor_r:0 g:192 b:0] ;
        CGContextAddLines (_context,&pntsP[0],pntsP.size()) ;
        CGContextStrokePath (_context) ;
        [self setColor_r:0 g:0 b:192] ;
        CGContextAddLines (_context,&pntsA[0],pntsA.size()) ;
        CGContextStrokePath (_context) ;
        [self setColor_r:192 g:0 b:0] ;
        CGContextAddLines (_context,&pntsW[0],pntsW.size()) ;
        CGContextStrokePath (_context) ;
        }
      }
    }

この投稿は役に立ちましたか? 役に立った 役に立たなかった 0 人中 0 人がこの 投稿 は役に立ったと言っています。


UIView のサイズ

MFC の CWnd::GetClientRect にあたるもの?
  drawRect の引数の rect
  self.bounds , self.frame
画面の向きに対して自動的に反映させるには
  self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight ;


MoveTo , LineTo
  CGContextMoveToPoint , CGContextAddLineToPoint
  CGPathMoveToPoint , CGPathAddLineToPoint
Polyline
  CGContextAddLines
  CGPathAddLines

この投稿は役に立ちましたか? 役に立った 役に立たなかった 0 人中 0 人がこの 投稿 は役に立ったと言っています。



top